Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright (C) 2011-2018 Free Software Foundation, Inc. |
d137e6dc 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 | # Test that GDB doesn't inadvertently resume the stepped thread when a | |
17 | # signal arrives while stepping over the breakpoint that last caused a | |
18 | # stop, when the thread that hit that breakpoint is not the stepped | |
19 | # thread. | |
20 | ||
21 | standard_testfile | |
22 | set executable ${testfile} | |
23 | ||
24 | if [target_info exists gdb,nosignals] { | |
25 | verbose "Skipping ${testfile}.exp because of nosignals." | |
26 | return -1 | |
27 | } | |
28 | ||
d137e6dc PA |
29 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ |
30 | executable [list debug "incdir=${objdir}"]] != "" } { | |
31 | return -1 | |
32 | } | |
33 | ||
34 | proc get_value {var test} { | |
35 | global expect_out | |
36 | global gdb_prompt | |
37 | global decimal | |
38 | ||
39 | set value -1 | |
40 | gdb_test_multiple "print $var" "$test" { | |
41 | -re ".*= ($decimal).*\r\n$gdb_prompt $" { | |
42 | set value $expect_out(1,string) | |
43 | pass "$test" | |
44 | } | |
45 | } | |
46 | return ${value} | |
47 | } | |
48 | ||
49 | # Start with a fresh gdb. | |
50 | ||
51 | clean_restart $executable | |
52 | ||
53 | if ![runto_main] { | |
54 | return -1 | |
55 | } | |
56 | ||
57 | gdb_breakpoint [gdb_get_line_number "set wait-thread-2 breakpoint here"] | |
58 | gdb_continue_to_breakpoint "run to wait-thread-2 breakpoint" | |
59 | gdb_test "info threads" "" "info threads with thread 2" | |
60 | ||
61 | gdb_breakpoint [gdb_get_line_number "set wait-thread-3 breakpoint here"] | |
62 | gdb_continue_to_breakpoint "run to breakpoint" | |
63 | gdb_test "info threads" "" "info threads with thread 3" | |
64 | ||
d137e6dc PA |
65 | gdb_test "set scheduler-locking on" |
66 | ||
67 | gdb_breakpoint [gdb_get_line_number "set breakpoint child_two here"] | |
68 | gdb_breakpoint [gdb_get_line_number "set breakpoint child_one here"] | |
69 | ||
70 | gdb_test "thread 3" "" "switch to thread 3 to run to its breakpoint" | |
71 | gdb_continue_to_breakpoint "run to breakpoint in thread 3" | |
72 | ||
73 | gdb_test "thread 2" "" "switch to thread 2 to run to its breakpoint" | |
74 | gdb_continue_to_breakpoint "run to breakpoint in thread 2" | |
75 | ||
76 | delete_breakpoints | |
77 | ||
78 | gdb_test "b *\$pc" "" "set breakpoint to be stepped over" | |
79 | # Make sure the first loop breaks without hitting the breakpoint | |
80 | # again. | |
81 | gdb_test "p *myp = 0" " = 0" "force loop break in thread 2" | |
82 | ||
83 | # We want "print" to make sure the target reports the signal to the | |
84 | # core. | |
85 | gdb_test "handle SIGUSR1 print nostop pass" "" "" | |
86 | ||
9f5e1e02 PA |
87 | gdb_test "thread 1" "" "switch to thread 1 to queue signal in thread 2" |
88 | gdb_test "next 2" "pthread_join .*" "queue signal in thread 2" | |
d137e6dc PA |
89 | |
90 | gdb_test "thread 3" "" "switch to thread 3 for stepping" | |
91 | set my_number [get_value "my_number" "get my_number"] | |
92 | set cnt_before [get_value "args\[$my_number\]" "get count before step"] | |
93 | gdb_test "set scheduler-locking off" | |
94 | ||
95 | # Make sure we're exercising the paths we want to. | |
96 | gdb_test "set debug infrun 1" | |
97 | ||
9ee41772 PA |
98 | set test "step" |
99 | gdb_test_sequence $test $test { | |
100 | "need to step-over" | |
101 | "resume \\(step=1" | |
102 | "signal arrived while stepping over breakpoint" | |
9ee41772 PA |
103 | "stepped to a different line" |
104 | "callme" | |
105 | } | |
d137e6dc PA |
106 | |
107 | set cnt_after [get_value "args\[$my_number\]" "get count after step"] | |
108 | ||
109 | # Test that GDB doesn't inadvertently resume the stepped thread when a | |
110 | # signal arrives while stepping over a breakpoint in another thread. | |
111 | ||
9ee41772 | 112 | gdb_assert { $cnt_before + 1 == $cnt_after } "stepped thread under control" |