public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug tdep/29423] [gdb, tdep/aarch64] FAIL: gdb.base/watchpoint-unaligned.exp: continue (timeout)
Date: Thu, 14 Mar 2024 10:24:22 +0000	[thread overview]
Message-ID: <bug-29423-4717-t08QdzCKOf@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29423-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29423

--- Comment #25 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9a03f2185347bd8f20da9bf535bc68a8d0f18ce8

commit 9a03f2185347bd8f20da9bf535bc68a8d0f18ce8
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Mar 14 11:25:10 2024 +0100

    [gdb/tdep] Fix gdb.base/watchpoint-unaligned.exp on aarch64

    On aarch64-linux, with test-case gdb.base/watchpoint-unaligned.exp I run
into:
    ...
    (gdb) watch data.u.size8twice[1]^M
    Hardware watchpoint 241: data.u.size8twice[1]^M
    (gdb) PASS: gdb.base/watchpoint-unaligned.exp: watch data.u.size8twice[1]
    continue^M
    Continuing.^M
    FAIL: gdb.base/watchpoint-unaligned.exp: continue (timeout)
    FAIL: gdb.base/watchpoint-unaligned.exp: size8twice write
    ...

    This happens as follows.

    We start the exec and set an 8-byte hardware watchpoint on
    data.u.size8twice[1] at address 0x440048:
    ...
    (gdb) p sizeof (data.u.size8twice[1])
    $1 = 8
    (gdb) p &data.u.size8twice[1]
    $2 = (uint64_t *) 0x440048 <data+16>
    ...

    We continue execution, and a 16-byte write at address 0x440040 triggers the
    hardware watchpoint:
    ...
      4101c8:       a9000801        stp     x1, x2, [x0]
    ...

    When checking whether a watchpoint has triggered in
    aarch64_stopped_data_address, we check against address 0x440040 (passed in
    parameter addr_trap).  This behaviour is documented:
    ...
              /* ADDR_TRAP reports the first address of the memory range
                 accessed by the CPU, regardless of what was the memory
                 range watched.  ...  */
    ...
    and consequently the matching logic compares against an addr_watch_aligned:
    ...
              && addr_trap >= addr_watch_aligned
              && addr_trap < addr_watch + len)
    ...

    However, the comparison fails:
    ...
    (gdb) p /x addr_watch_aligned
    $3 = 0x440048
    (gdb) p addr_trap >= addr_watch_aligned
    $4 = false
    ...

    Consequently, aarch64_stopped_data_address returns false, and
    stopped_by_watchpoint returns false, and watchpoints_triggered returns 0,
    which make infrun think it's looking at a delayed hardware
    breakpoint/watchpoint trap:
    ...
      [infrun] handle_signal_stop: stop_pc=0x4101c8
      [infrun] handle_signal_stop: delayed hardware breakpoint/watchpoint trap,
ignoring
    ...
    Infrun then ignores the trap and continues, but runs into the same
situation
    again and again, causing a hang which then causes the test timeout.

    Fix this by allowing a match 8 bytes below addr_watch_aligned.  This
    introduces the possibility for false positives, so we only do this for
regular
    "value changed" watchpoints.

    An earlier version of this patch worked by aligning addr_watch_aligned to
16
    instead of 8:
    ...
    -  const CORE_ADDR addr_watch_aligned = align_down (state->dr_addr_wp[i],
8);
    +  const CORE_ADDR addr_watch_aligned = align_down (state->dr_addr_wp[i],
16);
    ...
    but while that fixed the test-case, it didn't fix the problem completely,
so
    extend the test-case to check more scenarios.

    Tested on aarch64-linux.

    Tested-By: Luis Machado <luis.machado@arm.com>
    Approved-By: Luis Machado <luis.machado@arm.com>

    PR tdep/29423
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29423

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-03-14 10:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 11:39 [Bug tdep/29423] New: " vries at gcc dot gnu.org
2022-07-28 11:39 ` [Bug tdep/29423] " vries at gcc dot gnu.org
2022-07-28 11:50 ` vries at gcc dot gnu.org
2022-07-28 12:24 ` vries at gcc dot gnu.org
2022-07-28 12:36 ` luis.machado at arm dot com
2022-07-28 12:41 ` vries at gcc dot gnu.org
2022-07-28 12:47 ` luis.machado at arm dot com
2022-07-28 14:15 ` vries at gcc dot gnu.org
2022-07-28 15:25 ` vries at gcc dot gnu.org
2022-07-28 15:26 ` vries at gcc dot gnu.org
2022-07-29 14:23 ` vries at gcc dot gnu.org
2023-04-11 16:51 ` ahajkova at redhat dot com
2023-04-11 16:52 ` ahajkova at redhat dot com
2023-04-11 22:07 ` luis.machado at arm dot com
2023-04-12  7:51 ` ahajkova at redhat dot com
2023-04-12  8:27 ` luis.machado at arm dot com
2023-04-12  8:27 ` luis.machado at arm dot com
2023-04-12  8:31 ` luis.machado at arm dot com
2023-04-12 12:55 ` ahajkova at redhat dot com
2023-04-12 13:12 ` luis.machado at arm dot com
2023-04-12 13:54 ` luis.machado at arm dot com
2023-04-12 17:12 ` tromey at sourceware dot org
2023-04-12 17:54 ` luis.machado at arm dot com
2023-04-12 20:59 ` ahajkova at redhat dot com
2024-01-05 15:08 ` vries at gcc dot gnu.org
2024-02-20 20:55 ` vries at gcc dot gnu.org
2024-03-14 10:24 ` cvs-commit at gcc dot gnu.org [this message]
2024-03-14 10:26 ` vries at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29423-4717-t08QdzCKOf@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).