Copyright year update in most files of the GDB Project.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / interrupted-hand-call.exp
1 # Copyright (C) 2004, 2007-2008, 2010-2012 Free Software Foundation,
2 # Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 # Test recovering from a hand function call that gets interrupted
18 # by a signal in another thread.
19
20 set NR_THREADS 4
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set testfile "interrupted-hand-call"
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
29
30 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}" "additional_flags=-DNR_THREADS=$NR_THREADS"]] != "" } {
31 return -1
32 }
33
34 # Some targets can't do function calls, so don't even bother with this
35 # test.
36 if [target_info exists gdb,cannot_call_functions] {
37 setup_xfail "*-*-*" 2416
38 fail "This target can not call functions"
39 continue
40 }
41
42 gdb_exit
43 gdb_start
44 gdb_reinitialize_dir $srcdir/$subdir
45 gdb_load ${binfile}
46
47 if { ![runto_main] } {
48 fail "Can't run to main"
49 return 0
50 }
51
52 gdb_test "break all_threads_running" \
53 "Breakpoint 2 at .*: file .*${srcfile}, line .*" \
54 "breakpoint on all_threads_running"
55
56 # Run the program and make sure GDB reports that we stopped after
57 # hitting breakpoint 2 in all_threads_running().
58
59 gdb_test "continue" \
60 ".*Breakpoint 2, all_threads_running ().*" \
61 "run to all_threads_running"
62
63 # NOTE: Don't turn on scheduler-locking here.
64 # We want the main thread (hand_call_with_signal) and
65 # thread 1 (sigabrt_handler) to both run.
66
67 gdb_test "call hand_call_with_signal()" \
68 ".*in another thread.*" \
69 "hand-call interrupted by signal in another thread"
70
71 # Verify dummy stack frame is still present.
72
73 gdb_test "maint print dummy-frames" ".*stack=.*" "dummy stack frame present"
74
75 # Continuing now should exit the hand-call and pop the dummy frame.
76
77 gdb_test "continue" ".*" "finish hand-call"
78
79 gdb_test_multiple "maint print dummy-frames" "dummy frame popped" {
80 -re ".*stack=.*$gdb_prompt $" {
81 fail "dummy frame popped"
82 }
83 -re ".*$gdb_prompt $" {
84 pass "dummy frame popped"
85 }
86 }
87
88 # Continue one last time, the program should exit normally.
89
90 gdb_continue_to_end "" continue 1
91
92 return 0
This page took 0.0332 seconds and 5 git commands to generate.