1 # Copyright 2013-2016 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/>.
17 set executable ${testfile}
19 if { [gdb_compile_pthreads \
20 "${srcdir}/${subdir}/${srcfile}" \
22 executable {debug}] != "" } {
23 untested "failed to compile"
27 clean_restart $executable
29 # Start the second thread.
34 # Go back to the main thread, and leave it in the loop, where we're
35 # reasonably sure we don't have 'conditional jmp $pc'-like
36 # instructions. We wouldn't be able to detect whether a stepi makes
37 # progress over those.
38 gdb_test_no_output "set scheduler-locking on"
39 gdb_test "thread 1" "Switching to .*"
40 gdb_breakpoint $srcfile:[gdb_get_line_number "set break 2 here"]
41 gdb_continue_to_breakpoint "loop" ".* set break 2 here .*"
43 # Now back to thread 2, and let it queue a signal in thread 1.
44 gdb_test "thread 2" "Switching to .*"
45 gdb_breakpoint $srcfile:[gdb_get_line_number "set break here"]
46 gdb_continue_to_breakpoint "after pthread_kill" ".* set break here .*"
48 # We're now ready to stepi thread 1. It should immediately dequeue
50 gdb_test "thread 1" "Switching to .*" "thread 1 again"
52 # No longer need these.
55 # Turn on infrun debugging, so we can tell whether the signal is
56 # really dequeued and that GDB sees it.
57 gdb_test_no_output "set debug infrun 1"
59 # Make sure the target backend reports the signal to GDB core. Some
60 # backends (like Linux) skip reporting a signal if set to
61 # pass/nostop/noprint, resuming the thread immediately instead.
62 gdb_test "handle SIGCHLD print"
64 # Helper to extract the current PC. PREFIX is used to make each call
65 # have its own unique test name.
67 proc get_pc { prefix } {
68 with_test_prefix "$prefix" {
69 return [get_hexadecimal_valueof "\$pc" ""]
73 set prev_addr [get_pc "before stepi"]
74 if {$prev_addr == ""} {
78 # True if we saw the infrun path we want to test be exercised.
82 if {[gdb_test_multiple "stepi" "$test" {
83 -re "infrun: random signal" {
96 fail "$test (no random signal)"
99 set addr [get_pc "after stepi"]
104 set test "stepi interfered by signal makes progress"
105 if {$addr == $prev_addr} {