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/29868] [gdb/tdep, s390x] breakpoint.c:5784: internal-error: bpstat_stop_status_nowatch: Assertion `!target_stopped_by_watchpoint ()'
Date: Mon, 12 Dec 2022 03:14:59 +0000	[thread overview]
Message-ID: <bug-29868-4717-OAAmEjr7ri@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29868-4717@http.sourceware.org/bugzilla/>

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arnez at linux dot ibm.com,
                   |                            |ulrich.weigand at de dot ibm.com
          Component|gdb                         |tdep
            Summary|[gdb, s390x]                |[gdb/tdep, s390x]
                   |breakpoint.c:5784:          |breakpoint.c:5784:
                   |internal-error:             |internal-error:
                   |bpstat_stop_status_nowatch: |bpstat_stop_status_nowatch:
                   |Assertion                   |Assertion
                   |`!target_stopped_by_watchpo |`!target_stopped_by_watchpo
                   |int ()'                     |int ()'

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
I've added some code for debugging:
...
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 96833e804e9..654a62545f3 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -602,6 +602,9 @@ s390_linux_nat_target::low_forget_process (pid_t pid)
     }
 }

+static void
+s390_show_debug_regs (int tid, const char *where);
+
 /* linux_nat_new_fork hook.   */

 void
@@ -625,6 +628,12 @@ s390_linux_nat_target::low_new_fork (struct lwp_info
*parent, pid_t child_pid)

   child_state->watch_areas = parent_state->watch_areas;
   child_state->break_areas = parent_state->break_areas;
+
+  if (show_debug_regs)
+    {
+      s390_show_debug_regs (parent_pid, "fork -- parent");
+      s390_show_debug_regs (child_pid, "fork -- child");
+    }
 }

 /* Dump PER state.  */
@@ -656,6 +665,10 @@ s390_show_debug_regs (int tid, const char *where)
                per_info.lowcore.words.perc_atmid,
                per_info.lowcore.words.address,
                per_info.lowcore.words.access_id);
+
+  int result = (per_info.lowcore.bits.perc_storage_alteration == 1
+                && per_info.lowcore.bits.perc_store_real_address == 0);
+  debug_printf ("  stopped_by_watchpoint: %d\n", result);
 }

 bool
@@ -688,6 +701,8 @@ s390_linux_nat_target::stopped_by_watchpoint ()
       memset (&per_lowcore, 0, sizeof (per_lowcore));
       if (ptrace (PTRACE_POKEUSR_AREA, s390_inferior_tid (), &parea, 0) < 0)
        perror_with_name (_("Couldn't clear watchpoint status"));
+      if (show_debug_regs)
+       s390_show_debug_regs (s390_inferior_tid (), "clear");
     }

   return result;
...
and then get the following log:
...
$ gdbh -q -batch -ex "set trace-commands on" -x gdb.in
+file
/suse/tdevries/gdb/build/s390x/gdb/testsuite/outputs/gdb.threads/watchpoint-fork/watchpoint-fork-parent-st
+set follow-fork-mode parent
+start
Temporary breakpoint 1 at 0x1000810: file
/suse/tdevries/gdb/src/gdb/testsuite/gdb.threads/watchpoint-fork-st.c, line 49.

Temporary breakpoint 1, main () at
/suse/tdevries/gdb/src/gdb/testsuite/gdb.threads/watchpoint-fork-st.c:49
49        marker ();
+watch var
Hardware watchpoint 2: var
+break marker
Breakpoint 3 at 0x10007da: file
/suse/tdevries/gdb/src/gdb/testsuite/gdb.threads/watchpoint-fork-st.c, line 33.
+info break
Num     Type           Disp Enb Address            What
2       hw watchpoint  keep y                      var
3       breakpoint     keep y   0x00000000010007da in marker at
/suse/tdevries/gdb/src/gdb/testsuite/gdb.threads/watchpoint-fork-st.c:33
+maint set show-debug-regs 1
+continue
PER (debug) state for 55488 -- resume
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 40f0  address: 10006a4  PAID: 0
  stopped_by_watchpoint: 0
PER (debug) state for 55488 -- stop
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 40f0  address: 10006a4  PAID: 0
  stopped_by_watchpoint: 0

Breakpoint 3, marker () at
/suse/tdevries/gdb/src/gdb/testsuite/gdb.threads/watchpoint-fork-st.c:33
33      }
+continue
PER (debug) state for 55488 -- resume
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 40f0  address: 10006a4  PAID: 0
  stopped_by_watchpoint: 0
PER (debug) state for 55488 -- stop
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 40f0  address: 10006a4  PAID: 0
  stopped_by_watchpoint: 0
PER (debug) state for 55488 -- stop
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 40f0  address: 10006a4  PAID: 0
  stopped_by_watchpoint: 0
PER (debug) state for 55488 -- stop
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 20f0  address: 1000820  PAID: 0
  stopped_by_watchpoint: 1
PER (debug) state for 55488 -- clear
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 20f0  address: 1000820  PAID: 0
  stopped_by_watchpoint: 1

Hardware watchpoint 2: var

Old value = 0
New value = 1
main () at
/suse/tdevries/gdb/src/gdb/testsuite/gdb.threads/watchpoint-fork-st.c:52
52        forkoff (1);
+continue
PER (debug) state for 55488 -- resume
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 20f0  address: 1000820  PAID: 0
  stopped_by_watchpoint: 1
PER (debug) state for 55488 -- fork -- parent
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 20f0  address: 1000820  PAID: 0
  stopped_by_watchpoint: 1
PER (debug) state for 55490 -- fork -- child
  cr9-11: 0 0 0
  start, end: 0 0
  code/ATMID: 0  address: 0  PAID: 0
  stopped_by_watchpoint: 0
PER (debug) state for 55488 -- stop
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 20f0  address: 1000820  PAID: 0
  stopped_by_watchpoint: 1
PER (debug) state for 55488 -- clear
  cr9-11: 20200000 100203c 100203f
  start, end: 100203c 100203f
  code/ATMID: 20f0  address: 1000820  PAID: 0
  stopped_by_watchpoint: 1
/suse/tdevries/gdb/src/gdb/breakpoint.c:5784: internal-error:
bpstat_stop_status_nowatch: Assertion `!target_stopped_by_watchpoint ()'
failed.
...

So, the watchpoint triggers, and we try to clear the watch point status in
s390_linux_nat_target::stopped_by_watchpoint to make sure that we "Do not
report this watchpoint again".  That doesn't seem to have any effect though,
and when we stop for the fork s390_linux_nat_target::stopped_by_watchpoint
still returns true, causing the assert.

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

  parent reply	other threads:[~2022-12-12  3:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10  8:18 [Bug gdb/29868] New: [gdb, s390x -m31] " vries at gcc dot gnu.org
2022-12-10 11:25 ` [Bug gdb/29868] [gdb, s390x] " vries at gcc dot gnu.org
2022-12-12  3:14 ` vries at gcc dot gnu.org [this message]
2022-12-12  9:46 ` [Bug tdep/29868] [gdb/tdep, " vries at gcc dot gnu.org
2022-12-12  9:48 ` vries at gcc dot gnu.org
2022-12-12 12:08 ` vries at gcc dot gnu.org
2022-12-12 13:51 ` uweigand at gcc dot gnu.org
2022-12-12 15:08 ` vries at gcc dot gnu.org
2023-01-11  9: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-29868-4717-OAAmEjr7ri@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).