Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2013-2015 Free Software Foundation, Inc. |
776f04fa PA |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | standard_testfile | |
17 | set executable ${testfile} | |
18 | ||
19 | if { [gdb_compile_pthreads \ | |
20 | "${srcdir}/${subdir}/${srcfile}" \ | |
21 | "${binfile}" \ | |
22 | executable {debug}] != "" } { | |
23 | untested "Couldn't compile test program." | |
24 | return -1 | |
25 | } | |
26 | ||
27 | clean_restart $executable | |
28 | ||
29 | # Start the second thread. | |
30 | if ![runto start] { | |
31 | return -1 | |
32 | } | |
33 | ||
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 .*" | |
42 | ||
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 .*" | |
47 | ||
48 | # We're now ready to stepi thread 1. It should immediately dequeue | |
49 | # the signal. | |
50 | gdb_test "thread 1" "Switching to .*" "thread 1 again" | |
51 | ||
52 | # No longer need these. | |
53 | delete_breakpoints | |
54 | ||
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" | |
58 | ||
b5ee5a50 PA |
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" | |
63 | ||
776f04fa PA |
64 | # Helper to extract the current PC. PREFIX is used to make each call |
65 | # have its own unique test name. | |
66 | ||
67 | proc get_pc { prefix } { | |
68 | with_test_prefix "$prefix" { | |
69 | return [get_hexadecimal_valueof "\$pc" ""] | |
70 | } | |
71 | } | |
72 | ||
73 | set prev_addr [get_pc "before stepi"] | |
74 | if {$prev_addr == ""} { | |
75 | return | |
76 | } | |
77 | ||
78 | # True if we saw the infrun path we want to test be exercised. | |
79 | set seen 0 | |
80 | ||
81 | set test "stepi" | |
82 | if {[gdb_test_multiple "stepi" "$test" { | |
83 | -re "infrun: random signal" { | |
84 | set seen 1 | |
85 | exp_continue | |
86 | } | |
87 | -re "$gdb_prompt $" { | |
88 | } | |
89 | }] != 0} { | |
90 | return | |
91 | } | |
92 | ||
93 | if {$seen} { | |
94 | pass "$test" | |
95 | } else { | |
96 | fail "$test (no random signal)" | |
97 | } | |
98 | ||
99 | set addr [get_pc "after stepi"] | |
100 | if {$addr == ""} { | |
101 | return | |
102 | } | |
103 | ||
104 | set test "stepi interfered by signal makes progress" | |
105 | if {$addr == $prev_addr} { | |
106 | fail "$test" | |
107 | } else { | |
108 | pass "$test" | |
109 | } |