Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2013-2020 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 | ||
81f47ac2 AH |
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 | if [gdb_debug_enabled] { | |
19 | untested "debug is enabled" | |
20 | return 0 | |
21 | } | |
22 | ||
776f04fa PA |
23 | standard_testfile |
24 | set executable ${testfile} | |
25 | ||
26 | if { [gdb_compile_pthreads \ | |
27 | "${srcdir}/${subdir}/${srcfile}" \ | |
28 | "${binfile}" \ | |
29 | executable {debug}] != "" } { | |
84c93cd5 | 30 | untested "failed to compile" |
776f04fa PA |
31 | return -1 |
32 | } | |
33 | ||
34 | clean_restart $executable | |
35 | ||
36 | # Start the second thread. | |
37 | if ![runto start] { | |
38 | return -1 | |
39 | } | |
40 | ||
41 | # Go back to the main thread, and leave it in the loop, where we're | |
42 | # reasonably sure we don't have 'conditional jmp $pc'-like | |
43 | # instructions. We wouldn't be able to detect whether a stepi makes | |
44 | # progress over those. | |
45 | gdb_test_no_output "set scheduler-locking on" | |
46 | gdb_test "thread 1" "Switching to .*" | |
47 | gdb_breakpoint $srcfile:[gdb_get_line_number "set break 2 here"] | |
48 | gdb_continue_to_breakpoint "loop" ".* set break 2 here .*" | |
49 | ||
50 | # Now back to thread 2, and let it queue a signal in thread 1. | |
51 | gdb_test "thread 2" "Switching to .*" | |
52 | gdb_breakpoint $srcfile:[gdb_get_line_number "set break here"] | |
53 | gdb_continue_to_breakpoint "after pthread_kill" ".* set break here .*" | |
54 | ||
55 | # We're now ready to stepi thread 1. It should immediately dequeue | |
56 | # the signal. | |
57 | gdb_test "thread 1" "Switching to .*" "thread 1 again" | |
58 | ||
59 | # No longer need these. | |
60 | delete_breakpoints | |
61 | ||
62 | # Turn on infrun debugging, so we can tell whether the signal is | |
63 | # really dequeued and that GDB sees it. | |
64 | gdb_test_no_output "set debug infrun 1" | |
65 | ||
b5ee5a50 PA |
66 | # Make sure the target backend reports the signal to GDB core. Some |
67 | # backends (like Linux) skip reporting a signal if set to | |
68 | # pass/nostop/noprint, resuming the thread immediately instead. | |
69 | gdb_test "handle SIGCHLD print" | |
70 | ||
776f04fa PA |
71 | # Helper to extract the current PC. PREFIX is used to make each call |
72 | # have its own unique test name. | |
73 | ||
74 | proc get_pc { prefix } { | |
75 | with_test_prefix "$prefix" { | |
76 | return [get_hexadecimal_valueof "\$pc" ""] | |
77 | } | |
78 | } | |
79 | ||
80 | set prev_addr [get_pc "before stepi"] | |
81 | if {$prev_addr == ""} { | |
82 | return | |
83 | } | |
84 | ||
85 | # True if we saw the infrun path we want to test be exercised. | |
86 | set seen 0 | |
87 | ||
88 | set test "stepi" | |
89 | if {[gdb_test_multiple "stepi" "$test" { | |
90 | -re "infrun: random signal" { | |
91 | set seen 1 | |
92 | exp_continue | |
93 | } | |
94 | -re "$gdb_prompt $" { | |
95 | } | |
96 | }] != 0} { | |
97 | return | |
98 | } | |
99 | ||
100 | if {$seen} { | |
101 | pass "$test" | |
102 | } else { | |
103 | fail "$test (no random signal)" | |
104 | } | |
105 | ||
106 | set addr [get_pc "after stepi"] | |
107 | if {$addr == ""} { | |
108 | return | |
109 | } | |
110 | ||
111 | set test "stepi interfered by signal makes progress" | |
112 | if {$addr == $prev_addr} { | |
113 | fail "$test" | |
114 | } else { | |
115 | pass "$test" | |
116 | } |