Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.threads / stepi-random-signal.exp
blob5c5229dec8bfa36c2c85957c3a1a27be4b37bc21
1 # Copyright 2013-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # Test relies on checking gdb debug output. Do not run if gdb debug is
17 # enabled as any debug will be redirected to the log.
18 require !gdb_debug_enabled
20 standard_testfile
21 set executable ${testfile}
23 if { [gdb_compile_pthreads \
24           "${srcdir}/${subdir}/${srcfile}" \
25           "${binfile}" \
26           executable {debug}] != "" } {
27     untested "failed to compile"
28     return -1
31 clean_restart $executable
33 # Start the second thread.
34 if ![runto start] {
35     return -1
38 # Go back to the main thread, and leave it in the loop, where we're
39 # reasonably sure we don't have 'conditional jmp $pc'-like
40 # instructions.  We wouldn't be able to detect whether a stepi makes
41 # progress over those.
42 gdb_test_no_output "set scheduler-locking on"
43 gdb_test "thread 1" "Switching to .*"
44 gdb_breakpoint $srcfile:[gdb_get_line_number "set break 2 here"]
45 gdb_continue_to_breakpoint "loop" ".* set break 2 here .*"
47 # Now back to thread 2, and let it queue a signal in thread 1.
48 gdb_test "thread 2" "Switching to .*"
49 gdb_breakpoint $srcfile:[gdb_get_line_number "set break here"]
50 gdb_continue_to_breakpoint "after pthread_kill" ".* set break here .*"
52 # We're now ready to stepi thread 1.  It should immediately dequeue
53 # the signal.
54 gdb_test "thread 1" "Switching to .*" "thread 1 again"
56 # No longer need these.
57 delete_breakpoints
59 # Turn on infrun debugging, so we can tell whether the signal is
60 # really dequeued and that GDB sees it.
61 gdb_test_no_output "set debug infrun 1"
63 # Make sure the target backend reports the signal to GDB core.  Some
64 # backends (like Linux) skip reporting a signal if set to
65 # pass/nostop/noprint, resuming the thread immediately instead.
66 gdb_test "handle SIGCHLD print"
68 # Helper to extract the current PC.  PREFIX is used to make each call
69 # have its own unique test name.
71 proc get_pc { prefix } {
72     with_test_prefix "$prefix" {
73         return [get_hexadecimal_valueof "\$pc" ""]
74     }
77 set prev_addr [get_pc "before stepi"]
78 if {$prev_addr == ""} {
79     return
82 # True if we saw the infrun path we want to test be exercised.
83 set seen 0
85 set test "stepi"
86 set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
87 if {[gdb_test_multiple "stepi" "$test" -prompt $prompt {
88     -re {\[infrun\] handle_signal_stop: random signal} {
89         set seen 1
90         exp_continue
91     }
92     -re "$prompt$" {
93     }
94 }] != 0} {
95     return
98 if {$seen} {
99     pass "$test"
100 } else {
101     fail "$test (no random signal)"
104 set addr [get_pc "after stepi"]
105 if {$addr == ""} {
106     return
109 set test "stepi interfered by signal makes progress"
110 if {$addr == $prev_addr} {
111     fail "$test"
112 } else {
113     pass "$test"