From: Tom de Vries Date: Fri, 22 Nov 2024 12:37:24 +0000 (+0100) Subject: [gdb/testsuite] Fix gdb.base/bg-exec-sigint-bp-cond.exp for signal merging X-Git-Tag: gdb-16-branchpoint~369 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b200576fa04421d4c8e8da3082afcbfb986aac45;p=thirdparty%2Fbinutils-gdb.git [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 --- 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 ce2231d4b38..7168a7305c1 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 " - # 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 + } } } }