]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2014-2024 Free Software Foundation, Inc. |
70509625 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 an explicit "signal FOO" delivers FOO even if "handle" for | |
17 | # that same signal is set to "nopass". Also make sure the signal is | |
18 | # delivered to the right thread, even if GDB has to step over a | |
19 | # breakpoint in some other thread first. | |
20 | ||
b61f7811 HAQ |
21 | standard_testfile |
22 | ||
450d26c8 | 23 | require {!target_info exists gdb,nosignals} |
70509625 | 24 | |
70509625 PA |
25 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ |
26 | executable { debug }] != "" } { | |
27 | return -1 | |
28 | } | |
29 | ||
30 | # Run the test proper. STEP_OVER indicates whether we leave in place | |
31 | # a breakpoint that needs to be stepped over when we explicitly | |
32 | # request a signal be delivered with the "signal" command. | |
33 | ||
34 | proc test { step_over } { | |
35 | global srcfile binfile | |
36 | ||
37 | with_test_prefix "step-over $step_over" { | |
38 | clean_restart ${binfile} | |
39 | ||
b8ffa8b3 | 40 | if {![runto_main]} { |
70509625 PA |
41 | return 0 |
42 | } | |
43 | ||
44 | gdb_test "handle SIGUSR1 stop print nopass" | |
45 | ||
46 | gdb_test "b thread_function" "Breakpoint .* at .*$srcfile.*" | |
47 | gdb_test "continue" "thread_function.*" "stopped in thread" | |
48 | ||
49 | # Thread 2 is stopped at a breakpoint. If we leave the | |
50 | # breakpoint in place, GDB needs to move thread 2 past the | |
51 | # breakpoint before delivering the signal to thread 1. We | |
52 | # want to be sure that GDB doesn't mistakenly deliver the | |
53 | # signal to thread 1 while doing that. | |
54 | if { $step_over == "no" } { | |
55 | delete_breakpoints | |
56 | } | |
57 | ||
58 | gdb_test "break handler" "Breakpoint .* at .*$srcfile.*" | |
59 | ||
60 | gdb_test "thread 1" "Switching to thread 1.*" | |
61 | ||
62 | set pattern "\\\* 1\[ \t\]+Thread.*" | |
63 | ||
64 | gdb_test "info threads" $pattern "thread 1 selected" | |
65 | ||
66 | gdb_test "signal SIGUSR1" "handler .*" | |
67 | ||
cc6563d2 PA |
68 | # Make sure it was thread 1 that got the signal. Note we list |
69 | # all threads instead of just thread 1, so that if something | |
70 | # goes wrong and another thread ends up selected, we can | |
71 | # easily see which in the logs. | |
70509625 PA |
72 | gdb_test "info threads" $pattern "thread 1 got the signal" |
73 | } | |
74 | } | |
75 | ||
76 | foreach stepover {"yes" "no"} { | |
77 | test $stepover | |
78 | } |