]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2008-2024 Free Software Foundation, Inc. |
b89667eb DE |
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 | ||
7879fba3 | 16 | # Test use of unwind-on-signal when a hand function call that gets interrupted |
b89667eb DE |
17 | # by a signal in another thread. |
18 | ||
19 | set NR_THREADS 4 | |
20 | ||
0efbbabc | 21 | standard_testfile interrupted-hand-call.c |
b89667eb | 22 | |
b89667eb DE |
23 | # Some targets can't do function calls, so don't even bother with this |
24 | # test. | |
450d26c8 TT |
25 | require {!target_info exists gdb,cannot_call_functions} |
26 | ||
27 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-DNR_THREADS=$NR_THREADS"]] != "" } { | |
28 | return -1 | |
b89667eb DE |
29 | } |
30 | ||
0efbbabc | 31 | clean_restart ${binfile} |
b89667eb DE |
32 | |
33 | if { ![runto_main] } { | |
b89667eb DE |
34 | return 0 |
35 | } | |
36 | ||
37 | gdb_test "break all_threads_running" \ | |
38 | "Breakpoint 2 at .*: file .*${srcfile}, line .*" \ | |
39 | "breakpoint on all_threads_running" | |
40 | ||
41 | # Run the program and make sure GDB reports that we stopped after | |
42 | # hitting breakpoint 2 in all_threads_running(). | |
43 | ||
44 | gdb_test "continue" \ | |
45 | ".*Breakpoint 2, all_threads_running ().*" \ | |
46 | "run to all_threads_running" | |
47 | ||
48 | # NOTE: Don't turn on scheduler-locking here. | |
49 | # We want the main thread (hand_call_with_signal) and | |
50 | # thread 1 (sigabrt_handler) to both run. | |
51 | ||
7879fba3 | 52 | # Do turn on unwind-on-signal. |
b89667eb DE |
53 | # We want to test gdb handling of the current thread changing when |
54 | # unwindonsignal is in effect. | |
7879fba3 | 55 | gdb_test_no_output "set unwind-on-signal on" \ |
b89667eb | 56 | "setting unwindonsignal" |
7879fba3 | 57 | gdb_test "show unwind-on-signal" \ |
b89667eb DE |
58 | "Unwinding of stack .* is on." \ |
59 | "showing unwindonsignal" | |
60 | ||
61 | gdb_test "call hand_call_with_signal()" \ | |
62 | "The program received a signal.*" \ | |
63 | "hand-call interrupted by signal in another thread" | |
64 | ||
65 | # Verify dummy stack frame is still present. | |
66 | # ??? Should unwindonsignal still apply even if the program stops | |
67 | # because of a signal in another thread? | |
68 | ||
69 | gdb_test "maint print dummy-frames" ".*stack=.*" "dummy stack frame present" | |
70 | ||
71 | # GDB 6.8 would perform the unwindonsignal, but on the thread that stopped, | |
72 | # not the thread with the hand-called function. | |
73 | # This is tested by verifying only one thread has main in its backtrace. | |
74 | ||
75 | gdb_test_multiple "thread apply all bt" "wrong thread not unwound" { | |
76 | -re ".* in main .* in main .*$gdb_prompt $" { | |
77 | fail "wrong thread not unwound" | |
78 | } | |
79 | -re ".* in main .*$gdb_prompt $" { | |
80 | pass "wrong thread not unwound" | |
81 | } | |
82 | } | |
83 | ||
84 | # Continuing now should exit the hand-call and pop the dummy frame. | |
85 | ||
f6978de9 | 86 | gdb_test "continue" ".*" "finish hand-call" |
b89667eb DE |
87 | |
88 | gdb_test_multiple "maint print dummy-frames" "dummy frame popped" { | |
89 | -re ".*stack=.*$gdb_prompt $" { | |
90 | fail "dummy frame popped" | |
91 | } | |
92 | -re ".*$gdb_prompt $" { | |
93 | pass "dummy frame popped" | |
94 | } | |
95 | } | |
96 | ||
97 | # Continue one last time, the program should exit normally. | |
98 | ||
eceb0c5f | 99 | gdb_continue_to_end "" continue 1 |