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