e6d806699f2d7fd2d1b40f536d06e309587cca32
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / interrupted-hand-call.exp
1 # Copyright (C) 2004-2021 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 recovering from a hand function call that gets interrupted
17 # by a signal in another thread.
18
19 set NR_THREADS 4
20
21 standard_testfile
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 unsupported "this target can not call functions"
31 continue
32 }
33
34 clean_restart ${binfile}
35
36 if { ![runto_main] } {
37 fail "can't run to main"
38 return 0
39 }
40
41 gdb_test "break all_threads_running" \
42 "Breakpoint 2 at .*: file .*${srcfile}, line .*" \
43 "breakpoint on all_threads_running"
44
45 # Run the program and make sure GDB reports that we stopped after
46 # hitting breakpoint 2 in all_threads_running().
47
48 gdb_test "continue" \
49 ".*Breakpoint 2, all_threads_running ().*" \
50 "run to all_threads_running"
51
52 # NOTE: Don't turn on scheduler-locking here.
53 # We want the main thread (hand_call_with_signal) and
54 # thread 1 (sigabrt_handler) to both run.
55
56 gdb_test "call hand_call_with_signal()" \
57 ".*in another thread.*" \
58 "hand-call interrupted by signal in another thread"
59
60 # Verify dummy stack frame is still present.
61
62 gdb_test "maint print dummy-frames" ".*stack=.*" "dummy stack frame present"
63
64 # Continuing now should exit the hand-call and pop the dummy frame.
65
66 gdb_test "continue" ".*" "finish hand-call"
67
68 gdb_test_multiple "maint print dummy-frames" "dummy frame popped" {
69 -re ".*stack=.*$gdb_prompt $" {
70 fail "dummy frame popped"
71 }
72 -re ".*$gdb_prompt $" {
73 pass "dummy frame popped"
74 }
75 }
76
77 # Continue one last time, the program should exit normally.
78
79 gdb_continue_to_end "" continue 1
80
81 return 0
This page took 0.034919 seconds and 3 git commands to generate.