Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright (C) 2011-2015 Free Software Foundation, Inc. |
99619bea 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 steps over all breakpoints of threads not the stepping | |
17 | # thread, before actually proceeding with the stepped thread. | |
18 | ||
19 | standard_testfile | |
20 | set executable ${testfile} | |
21 | ||
22 | if [target_info exists gdb,nosignals] { | |
23 | verbose "Skipping ${testfile}.exp because of nosignals." | |
24 | return -1 | |
25 | } | |
26 | ||
27 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ | |
28 | executable [list debug "incdir=${objdir}"]] != "" } { | |
29 | return -1 | |
30 | } | |
31 | ||
f3770638 | 32 | # Prepare environment for test. |
99619bea | 33 | |
f3770638 | 34 | proc setup {} { |
99619bea | 35 | global executable |
f3770638 | 36 | global displaced |
99619bea | 37 | |
f3770638 | 38 | with_test_prefix "setup" { |
99619bea PA |
39 | clean_restart $executable |
40 | ||
41 | if ![runto_main] { | |
42 | return -1 | |
43 | } | |
44 | ||
f3770638 PA |
45 | gdb_test_no_output "set displaced-stepping $displaced" |
46 | ||
99619bea PA |
47 | gdb_breakpoint [gdb_get_line_number "set wait-threads breakpoint here"] |
48 | gdb_continue_to_breakpoint "run to breakpoint" | |
49 | gdb_test "info threads" "3 .* 2 .*\\\* 1.*" "info threads shows all threads" | |
50 | ||
51 | gdb_test_no_output "set scheduler-locking on" | |
52 | ||
53 | gdb_breakpoint [gdb_get_line_number "set breakpoint thread 3 here"] | |
54 | gdb_breakpoint [gdb_get_line_number "set breakpoint thread 2 here"] | |
55 | ||
56 | gdb_test "thread 3" "Switching.*" | |
57 | gdb_continue_to_breakpoint "run to breakpoint in thread 3" | |
58 | gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 3" | |
59 | ||
60 | gdb_test "thread 2" "Switching.*" | |
61 | gdb_continue_to_breakpoint "run to breakpoint in thread 2" | |
62 | gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 2" | |
63 | ||
f3770638 | 64 | # Disable scheduler locking. |
99619bea PA |
65 | gdb_test_no_output "set scheduler-locking off" |
66 | ||
67 | # Now all 3 threads are stopped for a breakpoint that needs to | |
68 | # be stepped over before thread 1 is resumed. | |
69 | } | |
70 | } | |
71 | ||
f3770638 PA |
72 | foreach displaced { "off" "on" } { |
73 | with_test_prefix "displaced=$displaced" { | |
74 | with_test_prefix "step" { | |
75 | setup | |
76 | gdb_test "thread 1" "Switching.*" | |
77 | gdb_test "step" "in wait_threads .*" | |
78 | } | |
79 | ||
80 | with_test_prefix "next" { | |
81 | setup | |
82 | gdb_test "thread 1" "Switching.*" | |
83 | gdb_test "next" "pthread_join.*" | |
84 | } | |
99619bea | 85 | |
f3770638 PA |
86 | with_test_prefix "continue" { |
87 | setup | |
88 | gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"] | |
89 | gdb_test "thread 1" "Switching.*" | |
90 | gdb_test "continue" "EXIT_SUCCESS.*" | |
91 | } | |
99619bea | 92 | |
f3770638 PA |
93 | # Try continuing with a queued signal in each of the threads |
94 | # (one at a time). Should stop at the signal handler, instead | |
95 | # of re-trapping the breakpoint the threads were already | |
96 | # stopped at. | |
97 | foreach thread {1 2 3} { | |
98 | with_test_prefix "signal thr$thread" { | |
99 | setup | |
100 | ||
101 | # Queue a signal in THREAD. | |
102 | gdb_test "thread $thread" "Switching.*" | |
103 | gdb_test_no_output "queue-signal SIGUSR1" | |
104 | ||
105 | # Switch back to thread 1, and continue. | |
106 | gdb_test "thread 1" "Switching.*" "switch back to thread 1" | |
107 | gdb_breakpoint "sigusr1_handler" "set break at sigusr1_handler" | |
108 | ||
109 | set msg "continue to sigusr1_handler" | |
110 | gdb_test_multiple "continue" $msg { | |
111 | -re "Breakpoint .* sigusr1_handler .*$gdb_prompt $" { | |
112 | pass $msg | |
113 | } | |
114 | -re "Breakpoint .*$gdb_prompt $" { | |
115 | if {![can_single_step_to_signal_handler] | |
116 | && $thread != 1 && $displaced == "off"} { | |
117 | setup_kfail "gdb/18214" "*-*-*" | |
118 | } | |
119 | fail $msg | |
120 | } | |
f3770638 PA |
121 | } |
122 | } | |
123 | } | |
124 | } | |
125 | } |