target_is_non_stop_p and sync targets

Message ID 20210316132643.691299-1-pedro@palves.net
State New
Headers show
Series
  • target_is_non_stop_p and sync targets
Related show

Commit Message

Pedro Alves March 16, 2021, 1:26 p.m.
gdb.base/maint-target-async-off.exp fails if you test against
gdbserver with "maint set target-non-stop on" forced.

  (gdb) run
  Starting program: build/gdb/testsuite/outputs/gdb.base/maint-target-async-off/maint-target-async-off

  Breakpoint 1, main () at src/gdb/testsuite/gdb.base/maint-target-async-off.c:21
  21        return 0;
  (gdb) FAIL: gdb.base/maint-target-async-off.exp: continue until exit (timeout)

Above, GDB just stopped listing to stdin.

Basically, GDB assumes that a target working in non-stop mode
operation also supports async mode; it's a requirement.  GDB
misbehaves badly otherwise, and even hits failed assertions.

Fix this my making target_is_non_stop_p return false if async is off.

gdb/ChangeLog:

	* target.c (target_always_non_stop_p): Also check whether the
	target can async.

Change-Id: I7e52e1061396a5b9b02ada462f68a14b76d68974
---
 gdb/target.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)


base-commit: 675da9a57e0ab1c384e0dfd20ddf715a83c18673
-- 
2.26.2

Comments

Lancelot SIX via Gdb-patches March 16, 2021, 2:29 p.m. | #1
On Tuesday, March 16, 2021 2:27 PM, Pedro Alves Wrote:
> gdb.base/maint-target-async-off.exp fails if you test against

> gdbserver with "maint set target-non-stop on" forced.

> 

>   (gdb) run

>   Starting program: build/gdb/testsuite/outputs/gdb.base/maint-target-async-off/maint-

> target-async-off

> 

>   Breakpoint 1, main () at src/gdb/testsuite/gdb.base/maint-target-async-off.c:21

>   21        return 0;

>   (gdb) FAIL: gdb.base/maint-target-async-off.exp: continue until exit (timeout)

> 

> Above, GDB just stopped listing to stdin.

> 

> Basically, GDB assumes that a target working in non-stop mode

> operation also supports async mode; it's a requirement.  GDB

> misbehaves badly otherwise, and even hits failed assertions.

> 

> Fix this my making target_is_non_stop_p return false if async is off.


"my" -> "by".

Thanks
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

Patch

diff --git a/gdb/target.c b/gdb/target.c
index 0889da82ea5..c3861209d5c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3738,10 +3738,11 @@  target_always_non_stop_p (void)
 bool
 target_is_non_stop_p ()
 {
-  return (non_stop
-	  || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
-	  || (target_non_stop_enabled == AUTO_BOOLEAN_AUTO
-	      && target_always_non_stop_p ()));
+  return ((non_stop
+	   || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
+	   || (target_non_stop_enabled == AUTO_BOOLEAN_AUTO
+	       && target_always_non_stop_p ()))
+	  && target_can_async_p ());
 }
 
 /* See target.h.  */