gdb/remote: do not check for null_ptid in stop reply
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 1 Apr 2020 14:57:39 +0000 (16:57 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 1 Apr 2020 14:57:39 +0000 (16:57 +0200)
A gdbserver does not report a ptid in a 'W' or 'X' packet if multi-process
extensions are not supported or turned off.  See

https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html#multiprocess-extensions
https://sourceware.org/gdb/current/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-Reply-Packets

GDB's remote packet parser checks for whether a stop-reply packet
contains a ptid if the target is non-stop, and issues an error if no
ptid is included:

  if (target_is_non_stop_p () && event->ptid == null_ptid)
    error (_("No process or thread specified in stop reply: %s"), buf);

This leads to the following error when the non-stop
mode is turned on but multi-process extensions are off:

  $ gdb
  (gdb) set non-stop on
  (gdb) set remote multiprocess-feature-packet off
  (gdb) target remote | gdbserver - ./foo
  Remote debugging using | gdbserver - ./foo
  stdin/stdout redirected
  Process ./foo created; pid = 3712
  ...
  (gdb) continue
  Continuing.
  ...
  No process or thread specified in stop reply: W2a
  (gdb)

Because the check is done for stop reply packets in general, a similar
situation occurs if the 'T' or 'Tthread' packet is disabled in
gdbserver (i.e.  via --disable-packet=T).  E.g:

  $ gdb
  (gdb) set non-stop on
  (gdb) target remote | gdbserver --disable-packet=Tthread - ./foo
  ...
  No process or thread specified in stop reply: T0506:0000000000000000;07:10e2ffffff7f0000;10:9060ddf7ff7f0000;

or

  $ gdb
  (gdb) set non-stop on
  (gdb) target remote | gdbserver --disable-packet=T - ./foo
  ...
  No process or thread specified in stop reply: S05

The commit

  commit cada5fc921e39a1945c422eea055c8b326d8d353
  Date:   Wed Mar 11 12:30:13 2020 +0000

      gdb: Handle W and X remote packets without giving a warning

and its predecessor

  commit 24ed6739b699f329c2c45aedee5f8c7d2f54e493
  Date:   Thu Jan 30 14:35:40 2020 +0000

      gdb/remote: Restore support for 'S' stop reply packet

added warnings for when GDB has to make a guess for a missing ptid in
case of multiple threads/inferiors.  These warnings should suffice.
So, the simple solution is to remove the check completely.

Regression-tested on X86_64 Linux.

gdb/ChangeLog:
2020-04-01  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* remote.c (remote_target::remote_parse_stop_reply): Remove the
check for no ptid in the stop reply when the target is non-stop.

gdb/testsuite/ChangeLog:
2020-04-01  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.server/stop-reply-no-thread.exp: Enhance the test
scenario to cover execution until the end and also the case
when no packet is disabled when starting gdbserver.

gdb/ChangeLog
gdb/remote.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.server/stop-reply-no-thread.exp

index 8afad21c9ec878f179a8055a1f5e7a4f48039cd7..f8b95c9a7eee4207851f0c59b9e8c82dfbabc26d 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-01  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       * remote.c (remote_target::remote_parse_stop_reply): Remove the
+       check for no ptid in the stop reply when the target is non-stop.
+
 2020-04-01  Tom Tromey  <tromey@adacore.com>
 
        * symtab.h (class lookup_name_info) <lookup_name_info>: Change
 2020-04-01  Tom Tromey  <tromey@adacore.com>
 
        * symtab.h (class lookup_name_info) <lookup_name_info>: Change
index 72f1728ecbc4434e1c6e134c8a7a84ac1b2589fb..bfbc0bc21d34e7faf830a53c2b712ed6f6ea64ad 100644 (file)
@@ -7561,9 +7561,6 @@ Packet: '%s'\n"),
       event->ptid = minus_one_ptid;
       break;
     }
       event->ptid = minus_one_ptid;
       break;
     }
-
-  if (target_is_non_stop_p () && event->ptid == null_ptid)
-    error (_("No process or thread specified in stop reply: %s"), buf);
 }
 
 /* When the stub wants to tell GDB about a new notification reply, it
 }
 
 /* When the stub wants to tell GDB about a new notification reply, it
index bb31bcdf3ac191e4583b27f3adb8380e74723e6f..cc2335e90ac0779afe1faa3db577cf6a6669c9cd 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-01  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       * gdb.server/stop-reply-no-thread.exp: Enhance the test
+       scenario to cover execution until the end and also the case
+
 2020-03-31  Tom de Vries  <tdevries@suse.de>
 
        * gdb.base/c-linkage-name.exp: Fix test-case comment.  Set language to
 2020-03-31  Tom de Vries  <tdevries@suse.de>
 
        * gdb.base/c-linkage-name.exp: Fix test-case comment.  Set language to
index ffc1c27dcb4be85742b9eeb3ef46bedc58016ad4..7d99b0905757ba40646d38134a6ed8f60dc7671a 100644 (file)
@@ -33,7 +33,7 @@ if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
 }
 
 # Run the tests with different features of GDBserver disabled.
 }
 
 # Run the tests with different features of GDBserver disabled.
-proc run_test { disable_feature } {
+proc run_test { disable_feature target_nonstop } {
     global binfile gdb_prompt decimal
 
     clean_restart ${binfile}
     global binfile gdb_prompt decimal
 
     clean_restart ${binfile}
@@ -42,7 +42,11 @@ proc run_test { disable_feature } {
     # extended-remote board, therefore already connected.
     gdb_test "disconnect" ".*"
 
     # extended-remote board, therefore already connected.
     gdb_test "disconnect" ".*"
 
-    set res [gdbserver_start "--disable-packet=${disable_feature}" $binfile]
+    set packet_arg ""
+    if { $disable_feature != "" } {
+       set packet_arg "--disable-packet=${disable_feature}"
+    }
+    set res [gdbserver_start $packet_arg $binfile]
     set gdbserver_protocol [lindex $res 0]
     set gdbserver_gdbport [lindex $res 1]
 
     set gdbserver_protocol [lindex $res 0]
     set gdbserver_gdbport [lindex $res 1]
 
@@ -50,6 +54,9 @@ proc run_test { disable_feature } {
     gdb_test_no_output "set remote threads-packet off"
     gdb_test_no_output "set remote multiprocess-feature-packet off"
 
     gdb_test_no_output "set remote threads-packet off"
     gdb_test_no_output "set remote multiprocess-feature-packet off"
 
+    # Set target-nonstop mode.
+    gdb_test_no_output "maint set target-non-stop ${target_nonstop}"
+
     set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
     if ![gdb_assert {$res == 0} "connect"] {
        return
     set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
     if ![gdb_assert {$res == 0} "connect"] {
        return
@@ -76,6 +83,13 @@ proc run_test { disable_feature } {
     #  Cannot execute this command without a live selected thread.
     #  (gdb)
     gdb_test "c" "Breakpoint $decimal, main.*" "continue to main"
     #  Cannot execute this command without a live selected thread.
     #  (gdb)
     gdb_test "c" "Breakpoint $decimal, main.*" "continue to main"
+
+    # Continue until exit.  The server sends a 'W' with no PID.
+    # Bad GDB gave an error like below when target is nonstop:
+    #  (gdb) c
+    #  Continuing.
+    #  No process or thread specified in stop reply: W00
+    gdb_continue_to_end "" continue 1
 }
 
 # Disable different features within gdbserver:
 }
 
 # Disable different features within gdbserver:
@@ -85,6 +99,8 @@ proc run_test { disable_feature } {
 #
 # T: Start GDBserver with the entire 'T' stop reply packet disabled,
 #    GDBserver will instead send the 'S' stop reply.
 #
 # T: Start GDBserver with the entire 'T' stop reply packet disabled,
 #    GDBserver will instead send the 'S' stop reply.
-foreach_with_prefix to_disable { Tthread T } {
-    run_test $to_disable
+foreach_with_prefix to_disable { "" Tthread T } {
+    foreach_with_prefix t_nonstop { off on } {
+       run_test $to_disable $t_nonstop
+    }
 }
 }
This page took 0.041213 seconds and 4 git commands to generate.