Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright (C) 2014-2021 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 | if [target_info exists gdb,nosignals] { | |
17 | verbose "Skipping ${testfile}.exp because of nosignals." | |
18 | return -1 | |
19 | } | |
20 | ||
21 | standard_testfile | |
22 | ||
23 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ | |
24 | executable { debug }] != "" } { | |
25 | return -1 | |
26 | } | |
27 | ||
28 | # Run test proper. COMMAND indicates whether to resume the inferior | |
29 | # with "signal 0" or "continue". | |
30 | ||
31 | proc test { command } { | |
32 | global srcfile binfile | |
33 | ||
34 | with_test_prefix "$command" { | |
35 | clean_restart ${binfile} | |
36 | ||
37 | if ![runto_main] then { | |
bc6c7af4 | 38 | fail "can't run to main" |
70509625 PA |
39 | return 0 |
40 | } | |
41 | ||
42 | gdb_test "handle SIGUSR1 stop print pass" | |
43 | ||
f303dbd6 | 44 | gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1" |
70509625 PA |
45 | |
46 | set pattern "\\\* 2\[ \t\]+Thread.*" | |
47 | ||
48 | gdb_test "info threads" $pattern "thread 2 intercepted signal" | |
49 | ||
50 | gdb_test "break handler" "Breakpoint .* at .*$srcfile.*" | |
51 | ||
52 | gdb_test "thread 1" "Switching to thread 1.*" | |
53 | ||
54 | if { $command == "continue" } { | |
55 | gdb_test "continue" "handler .*" | |
56 | } elseif { $command == "signal 0" } { | |
57 | set queried 0 | |
58 | set test "signal 0 queries" | |
59 | gdb_test_multiple "signal 0" $test { | |
60 | -re "stopped with.*stopped with.*Continue anyway.*y or n. $" { | |
61 | fail "$test (multiple threads noted)" | |
62 | set queried 1 | |
63 | } | |
64 | -re "stopped with signal SIGUSR1.*\r\nContinuing .*still deliver .*Continue anyway.*y or n. $" { | |
65 | pass $test | |
66 | set queried 1 | |
67 | } | |
68 | -re "Continue anyway.*y or n. $" { | |
69 | fail "$test (no threads noted)" | |
70 | set queried 1 | |
71 | } | |
72 | } | |
73 | ||
74 | if {$queried} { | |
75 | gdb_test "y" "handler .*" "signal is delivered" | |
76 | } | |
77 | } | |
78 | ||
79 | gdb_test "info threads" $pattern "thread 2 got the signal" | |
80 | } | |
81 | } | |
82 | ||
83 | foreach command {"continue" "signal 0"} { | |
84 | test $command | |
85 | } |