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 gdb/31214] [gdb, aarch64] FAIL: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 0->5: continue
Date: Sun, 07 Jan 2024 13:42:51 +0000	[thread overview]
Message-ID: <bug-31214-4717-syllUi7Bmb@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31214-4717@http.sourceware.org/bugzilla/>

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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> Put differently, aarch64_stopped_data_address should report back 0x440028
> and 0x440029 in both cases, and the caller should figure out which of the
> two is actually triggered.  Alternatively, it could report back a range
> [0x440028-0x44002a].

This tentative patch addresses it slightly differently.  It reports back no
address:
...
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 5b4e3c2bde1..624884cd375 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -972,9 +972,7 @@ aarch64_linux_nat_target::stopped_data_address (CORE_ADDR
*addr_p)
 bool
 aarch64_linux_nat_target::stopped_by_watchpoint ()
 {
-  CORE_ADDR addr;
-
-  return stopped_data_address (&addr);
+  return stopped_data_address (nullptr);
 }

 /* Implement the "can_do_single_step" target_ops method.  */
diff --git a/gdb/aarch64-nat.c b/gdb/aarch64-nat.c
index ee8c5a1e21d..2cc0a0b707c 100644
--- a/gdb/aarch64-nat.c
+++ b/gdb/aarch64-nat.c
@@ -232,6 +232,7 @@ aarch64_stopped_data_address (const struct
aarch64_debug_reg_state *state,
                              CORE_ADDR addr_trap, CORE_ADDR *addr_p)
 {
   int i;
+  bool found = false;

   for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
     {
@@ -265,12 +266,19 @@ aarch64_stopped_data_address (const struct
aarch64_debug_reg_state *state,
             range.  ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
             positive on kernels older than 4.10.  See PR
             external/20207.  */
-         *addr_p = addr_orig;
-         return true;
+
+         if (addr_p != nullptr)
+           if (found && *addr_p != addr_orig)
+             return false;
+
+         found = true;
+
+         if (addr_p != nullptr)
+           *addr_p = addr_orig;
        }
     }

-  return false;
+  return found;
 }

 /* Define AArch64 maintenance commands.  */

...

So, if called from stopped_by_watchpoint (addr_p == nullptr), if there is any
hit, it returns true.

Otherwise (addr_p != nullptr) if there are multiple hits with conflicting
addresses, it return false.

Fixes the test-case.

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

  parent reply	other threads:[~2024-01-07 13:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 11:29 [Bug gdb/31214] New: " vries at gcc dot gnu.org
2024-01-07 13:34 ` [Bug gdb/31214] " vries at gcc dot gnu.org
2024-01-07 13:42 ` vries at gcc dot gnu.org [this message]
2024-01-07 13:43 ` vries at gcc dot gnu.org
2024-01-07 13:52 ` vries at gcc dot gnu.org
2024-02-20 20:55 ` vries at gcc dot gnu.org
2024-03-12 16:04 ` [Bug tdep/31214] " vries at gcc dot gnu.org
2024-03-12 16:07 ` cvs-commit at gcc dot gnu.org
2024-03-12 16:09 ` 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-31214-4717-syllUi7Bmb@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).