public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug tdep/31486] New: [gdb/tdep, aarch64] Hang when hitting access watchpoint on M1
Date: Thu, 14 Mar 2024 12:39:31 +0000	[thread overview]
Message-ID: <bug-31486-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 31486
           Summary: [gdb/tdep, aarch64] Hang when hitting access
                    watchpoint on M1
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: tdep
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

With commit 9a03f218534 ("[gdb/tdep] Fix gdb.base/watchpoint-unaligned.exp on
aarch64"), things have improved for regular watchpoints on the M1 aarch64 SOC,
but the problem reported in PR29423 still exists for other watchpoints.

For instance, this works ok:
...
$ gdb -q -batch -iex "set trace-commands on" \
    outputs/gdb.base/watchpoint-unaligned/watchpoint-unaligned \
    -ex "awatch data.u.size8twice[0]" \
    -ex run
+awatch data.u.size8twice[0]
Hardware access (read/write) watchpoint 1: data.u.size8twice[0]
+run
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Hardware access (read/write) watchpoint 1: data.u.size8twice[0]

Old value = 0
New value = 1
write_size8twice () at
/home/vries/gdb/src/gdb/testsuite/gdb.base/watchpoint-unaligned.c:56
56      }
...
but this doesn't:
...
$ gdb -q -batch -iex "set trace-commands on" \
    outputs/gdb.base/watchpoint-unaligned/watchpoint-unaligned \
    -ex "awatch data.u.size8twice[1]" \
    -ex run
+awatch data.u.size8twice[1]
Hardware access (read/write) watchpoint 1: data.u.size8twice[1]
+run
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
<hangs>
...

Luis mentioned an idea for trying to handle this here (
https://sourceware.org/pipermail/gdb-patches/2024-March/207259.html ).

Another idea for a fix explores the fact that on the one hand it's trivial to
fix this by doing:
...
index 802bab6d682..f22840dd914 100644
--- a/gdb/aarch64-nat.c
+++ b/gdb/aarch64-nat.c
@@ -292,7 +292,7 @@ aarch64_stopped_data_address (const struct
aarch64_debug_reg_state *state,
           RK3399 SOC). But it also can be p (observed on M1 SOC).  Checking
           for this situation introduces the possibility of false positives,
           so we only do this for hw_write watchpoints.  */
-       const CORE_ADDR max_access_size = type == hw_write ? 16 : 8;
+       const CORE_ADDR max_access_size = type == hw_write ? 16 : 16;
        const CORE_ADDR addr_watch_base = addr_watch_aligned -
          (max_access_size - AARCH64_HWP_MAX_LEN_PER_REG);
        if (!(addr_trap >= addr_watch_base
...
but on the other hand that runs the risk of false positives.  It may not be
acceptable to expose the user to this unprompted, but it may be acceptable if
the user does so explicitly, by say "maint set imprecise-watchpoint-window 16".

Also, it seems to me that if the kernel would communicate the watchpoint
register values (DBGBCRn_EL1 and DBGBVRn_EL1) for which it reports a trigger to
user space, it would make it trivial to determine whether and which watchpoint
triggered (well, according to the kernel, which may still be wrong).  We should
probably file a linux kernel PR for this.

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

             reply	other threads:[~2024-03-14 12:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 12:39 vries at gcc dot gnu.org [this message]
2024-03-14 12:39 ` [Bug tdep/31486] " vries at gcc dot gnu.org
2024-03-19  9:04 ` vries at gcc dot gnu.org
2024-03-19 12:42 ` vries at gcc dot gnu.org
2024-03-20  9:50 ` luis.machado at arm dot com
2024-03-22 16: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-31486-4717@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).