[gdb] Fix assert in remote_async_get_pending_events_handler
authorTom de Vries <tdevries@suse.de>
Thu, 22 Apr 2021 15:01:00 +0000 (17:01 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 22 Apr 2021 15:01:00 +0000 (17:01 +0200)
Occassionally I run into the following assert:
...
(gdb) PASS: gdb.multi/multi-target-continue.exp: inferior 5
Remote debugging from host ::1, port 49990^M
Process multi-target-continue created; pid = 31241^M
src/gdb/remote-notif.c:113: internal-error: \
  void remote_async_get_pending_events_handler(gdb_client_data): \
  Assertion `target_is_non_stop_p ()' failed.^M
...

The assert checks target_is_non_stop_p, which is related to the current
target.

Fix this by changing the assert such that it checks non-stopness related to
the event it's handling.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-04-22  Simon Marchi  <simon.marchi@polymtl.ca>
    Tom de Vries  <tdevries@suse.de>

PR remote/27710
* remote.c (remote_target_is_non_stop_p): New function.
* remote.h (remote_target_is_non_stop_p): Declare.
* remote-notif.c (remote_async_get_pending_events_handler): Fix assert
to check non-stopness using notif_state->remote rather current target.

gdb/ChangeLog
gdb/remote-notif.c
gdb/remote.c
gdb/remote.h

index 09928110954a1095bb174784a66736cb69a52260..953fe19753fa9edfb308da6f7a2db52b97861591 100644 (file)
@@ -1,3 +1,12 @@
+2021-04-22  Simon Marchi  <simon.marchi@polymtl.ca>
+           Tom de Vries  <tdevries@suse.de>
+
+       PR remote/27710
+       * remote.c (remote_target_is_non_stop_p): New function.
+       * remote.h (remote_target_is_non_stop_p): Declare.
+       * remote-notif.c (remote_async_get_pending_events_handler): Fix assert
+       to check non-stopness using notif_state->remote rather current target.
+
 2021-04-22  Tom Tromey  <tom@tromey.com>
 
        * rust-parse.c (rust_parser::parse_sizeof): Remove KW_MUT code.
index 5a3e1395b76e63df0efd9c20b409a506228e16ed..4245015ae370bcccf3ef50452d6514e2e84f6d8c 100644 (file)
@@ -110,7 +110,7 @@ remote_async_get_pending_events_handler (gdb_client_data data)
 {
   remote_notif_state *notif_state = (remote_notif_state *) data;
   clear_async_event_handler (notif_state->get_pending_events_token);
-  gdb_assert (target_is_non_stop_p ());
+  gdb_assert (remote_target_is_non_stop_p (notif_state->remote));
   remote_notif_process (notif_state, NULL);
 }
 
index 7429e1a86b389dde87184550faff263be6c83121..2e365df9bbaeb6fceb096a6215f037c720aa4b42 100644 (file)
@@ -14730,6 +14730,17 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
   return packet_check_result (rs->buf.data ()) == PACKET_OK;
 }
 
+/* Return true if remote target T is non-stop.  */
+
+bool
+remote_target_is_non_stop_p (remote_target *t)
+{
+  scoped_restore_current_thread restore_thread;
+  switch_to_target_no_thread (t);
+
+  return target_is_non_stop_p ();
+}
+
 #if GDB_SELF_TEST
 
 namespace selftests {
index 18352ddb866f438c546f2033d46248a3f3289d9d..46bfa01fc79bf03a3364dc7312564a7056d2b981 100644 (file)
@@ -77,4 +77,5 @@ extern int remote_register_number_and_offset (struct gdbarch *gdbarch,
 
 extern void remote_notif_get_pending_events (remote_target *remote,
                                             struct notif_client *np);
+extern bool remote_target_is_non_stop_p (remote_target *t);
 #endif
This page took 0.032774 seconds and 4 git commands to generate.