aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-01-06 10:53:22 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2021-01-06 10:53:22 -0500
commit3c55062cc1d8fdb6788164a55c1e4b773c781985 (patch)
tree495de5c3152a76bc38cc44a018c86e0c4cf8e4d7
parent4b186f88b816851dca198fc523eba4b53d4c1e5e (diff)
downloadbinutils-3c55062cc1d8fdb6788164a55c1e4b773c781985.zip
binutils-3c55062cc1d8fdb6788164a55c1e4b773c781985.tar.gz
binutils-3c55062cc1d8fdb6788164a55c1e4b773c781985.tar.bz2
gdb/testsuite: fix race in gdb.threads/signal-while-stepping-over-bp-other-thread.exp
Commit 3ec3145c5dd6 ("gdb: introduce scoped debug prints") updated some tests using "set debug infrun" to handle the fact that a debug print is now shown after the prompt, after an inferior stop. The same issue happens in gdb.threads/signal-while-stepping-over-bp-other-thread.exp. If I run it in a loop, it eventually fails like these other tests. The problem is that the testsuite expects to see $gdb_prompt followed by the end of the buffer. It happens that expect reads $gdb_prompt and the debug print at the same time, in which case the regexp never matches and we get a timeout. The fix is the same as was done in 3ec3145c5dd6, make the testsuite believe that the prompt is the standard GDB prompt followed by that debug print. Since that test uses gdb_test_sequence, and the expected prompt is in gdb_test_sequence, add a -prompt switch to gdb_test_sequence to override the prompt used for that call. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_test_sequence): Accept -prompt switch. * gdb.threads/signal-while-stepping-over-bp-other-thread.exp: Pass prompt containing debug print to gdb_test_sequence. Change-Id: I33161c53ddab45cdfeadfd50b964f8dc3caa9729
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp2
-rw-r--r--gdb/testsuite/lib/gdb.exp23
3 files changed, 28 insertions, 3 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2e47518..d3c6e95 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-06 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * lib/gdb.exp (gdb_test_sequence): Accept -prompt switch.
+ * gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
+ Pass prompt containing debug print to gdb_test_sequence.
+
2021-01-04 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/dw2-out-of-range-end-of-seq.exp: New file.
diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
index fe84253..2807485 100644
--- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
@@ -102,7 +102,7 @@ gdb_test "set scheduler-locking off"
gdb_test "set debug infrun 1"
set test "step"
-gdb_test_sequence $test $test {
+gdb_test_sequence $test $test -prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$" {
"need to step-over"
"resume_1: step=1,"
"signal arrived while stepping over breakpoint"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3f61da8..140e396 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1401,6 +1401,9 @@ proc gdb_test_no_output { args } {
# EXPECTED_OUTPUT_LIST is a list of regexps of expected output, which are
# processed in order, and all must be present in the output.
#
+# The -prompt switch can be used to override the prompt expected at the end of
+# the output sequence.
+#
# It is unnecessary to specify ".*" at the beginning or end of any regexp,
# there is an implicit ".*" between each element of EXPECTED_OUTPUT_LIST.
# There is also an implicit ".*" between the last regexp and the gdb prompt.
@@ -1413,16 +1416,32 @@ proc gdb_test_no_output { args } {
# 0 if the test passes,
# -1 if there was an internal error.
-proc gdb_test_sequence { command test_name expected_output_list } {
+proc gdb_test_sequence { args } {
global gdb_prompt
+
+ parse_args {{prompt ""}}
+
+ if { $prompt == "" } {
+ set prompt "$gdb_prompt $"
+ }
+
+ if { [llength $args] != 3 } {
+ error "Unexpected # of arguments, expecting: COMMAND TEST_NAME EXPECTED_OUTPUT_LIST"
+ }
+
+ lassign $args command test_name expected_output_list
+
if { $test_name == "" } {
set test_name $command
}
+
lappend expected_output_list ""; # implicit ".*" before gdb prompt
+
if { $command != "" } {
send_gdb "$command\n"
}
- return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
+
+ return [gdb_expect_list $test_name $prompt $expected_output_list]
}