[gdb/testsuite] Timeout updates in gdb.base/kill-during-detach.exp

Message ID 20261103082942.3542020-1-tdevries@suse.de
State New
Headers
Series [gdb/testsuite] Timeout updates in gdb.base/kill-during-detach.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Nov. 3, 2026, 8:29 a.m. UTC
  With a gdb 17.2 based package and test-case gdb.base/kill-during-detach.exp, I
ran into:
...
(gdb) python kill_and_detach()
FAIL: exit_p=false: checkpoint_p=false: python kill_and_detach() (timeout)
...

I didn't manage to reproduce this, but I have seen this more often.

This may either be a regular testsuite timeout, or a problem with gdb.

It could be a regular testsuite timeout.  The command that is issued:
...
def kill_and_detach():
   os.kill(inf_pid, signal.SIGKILL)
   time.sleep(1)
   gdb.execute("detach")
...
does two things (with a sleep of 1 in between) that would normally get their
own timeout window.

Let's address this by adding a timeout factor of 2.

Then there's the problem that we don't see any output after the timeout.  So
we add a simple command after the command to drain some more output.

If the problem is a testsuite timeout, the timeout factor may be sufficient to
fix this.  And if it's a gdb problem, we might get more information the next
time we run into this.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34935
---
 gdb/testsuite/gdb.base/kill-during-detach.exp | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)


base-commit: 9db3b515b964c1bbdc4d20c1202fbf27719be269
  

Patch

diff --git a/gdb/testsuite/gdb.base/kill-during-detach.exp b/gdb/testsuite/gdb.base/kill-during-detach.exp
index f5e3a902211..27584581a9b 100644
--- a/gdb/testsuite/gdb.base/kill-during-detach.exp
+++ b/gdb/testsuite/gdb.base/kill-during-detach.exp
@@ -126,10 +126,23 @@  proc run_test { exit_p checkpoint_p } {
 	# NOTE: The 'checkpoint' system in GDB appears to be a little
 	# iffy.  This detach does seem to restore the checkpoint, but
 	# it leaves the inferior stuck in a running state.
-	gdb_test_no_output "python kill_and_detach()"
+
+	# Double the timeout, to account for the fact that we're doing two
+	# things in kill_and_detach.
+	with_timeout_factor 2 {
+	    gdb_test_no_output "python kill_and_detach()"
+	}
     } else {
-	gdb_test "python kill_and_detach()" \
-	    "\\\[Inferior $::decimal \[^\r\n\]+ detached\\\]"
+	# Double the timeout, to account for the fact that we're doing two
+	# things in kill_and_detach.
+	with_timeout_factor 2 {
+	    gdb_test "python kill_and_detach()" \
+		[subst_vars {\[Inferior $::decimal [^\r\n]+ detached\]}]
+	}
+
+	# Do a simple command to drain late output of the previous command in
+	# case it timed out.
+	gdb_test "info inferiors" "<null>.*"
     }
 }