aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-11-22 13:37:24 +0100
committerTom de Vries <tdevries@suse.de>2024-11-22 13:37:24 +0100
commitb200576fa04421d4c8e8da3082afcbfb986aac45 (patch)
tree17ed614912dad99518ad6f8e81ff10b3303526c1
parentc4df8ad79cc62509af85311a6e03806d94f6c75b (diff)
downloadgdb-b200576fa04421d4c8e8da3082afcbfb986aac45.zip
gdb-b200576fa04421d4c8e8da3082afcbfb986aac45.tar.gz
gdb-b200576fa04421d4c8e8da3082afcbfb986aac45.tar.bz2
[gdb/testsuite] Fix gdb.base/bg-exec-sigint-bp-cond.exp for signal merging
The test-case gdb.base/bg-exec-sigint-bp-cond.exp sends 10 SIGINTS to gdb, and counts whether 10 have arrived. Occasionally, less than 10 arrive due to signal merging [1]. This is more likely to happen when building gdb with -fsanitize=thread. Fix this by instead, sending one SIGINT at a time, and waiting for it to arrive. This still makes the test-case fail if the fix fixing the PR that the test-case was introduced for is reverted. Tested on aarch64-linux and x86_64-linux. PR testsuite/32329 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32329 [1] https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html
-rw-r--r--gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp61
1 files changed, 36 insertions, 25 deletions
diff --git a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
index ce2231d..7168a73 100644
--- a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
+++ b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
@@ -40,39 +40,50 @@ proc test { {after_kill_cond ""} } {
set gdb_pid [exp_pid -i [board_info host fileid]]
- # Number of times the breakpoint should be hit before stopping.
- set num_hits 10
-
- # A counter used in the breakpoint's condition to ensure that it
- # causes a stop after NUM_HITS hits.
- gdb_test "p \$hit_count = 0" " = 0" "reset hit counter"
-
# Set a breakpoint with a condition that sends a SIGINT to GDB. This
# emulates pressing Ctrl-C just while GDB is evaluating the breakpoint
# condition.
gdb_test \
- "break foo if \$hit_count\+\+ == $num_hits || \$_shell(\"kill -INT $gdb_pid\") != 0 $after_kill_cond" \
+ "break foo if \$hit_count\+\+ == 1 || \$_shell(\"kill -INT $gdb_pid\") != 0 $after_kill_cond" \
"Breakpoint .*" \
"break foo if <condition>"
- # Number of times we've seen GDB print "Quit" followed by the
- # prompt. We should see that exactly $NUM_HITS times.
- set quit_count 0
+ for { set i 0 } { $i < 10 } { incr i } {
+ set done 0
+ with_test_prefix $i {
- gdb_test_multiple "c&" "SIGINT does not interrupt background execution" {
- -re "^c&\r\nContinuing\\.\r\n$::gdb_prompt " {
- exp_continue
- }
- -re "^Quit\r\n$::gdb_prompt " {
- incr quit_count
- verbose -log "quit_count=$quit_count"
- exp_continue
- }
- -re "^\r\nBreakpoint .*return 0;" {
- gdb_assert {$quit_count == $num_hits} $gdb_test_name
- }
- -re ".*Asynchronous execution not supported on this target\..*" {
- unsupported "$gdb_test_name (asynchronous execution not supported)"
+ # A counter used in the breakpoint's condition to ensure that it
+ # causes a stop after one hit.
+ gdb_test "p \$hit_count = 0" " = 0" "reset hit counter"
+
+ # Number of times we've seen GDB print "Quit" followed by the
+ # prompt. We should see that exactly one time.
+ set quit_count 0
+
+ gdb_test_multiple "c&" "SIGINT does not interrupt background execution" {
+ -re "^c&\r\nContinuing\\.\r\n$::gdb_prompt " {
+ exp_continue
+ }
+ -re "^Quit\r\n$::gdb_prompt " {
+ incr quit_count
+ verbose -log "quit_count=$quit_count"
+ exp_continue
+ }
+ -re "^\r\nBreakpoint .*return 0;" {
+ gdb_assert {$quit_count == 1} $gdb_test_name
+ }
+ -re ".*Asynchronous execution not supported on this target\..*" {
+ unsupported "$gdb_test_name (asynchronous execution not supported)"
+ }
+ timeout {
+ set done 1
+ fail "$gdb_test_name (timeout)"
+ }
+ }
+
+ if { $done } {
+ break
+ }
}
}
}