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