* gdb.trace/actions.exp: Use standard_testfile.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / interrupted-hand-call.exp
CommitLineData
c5a57081
JB
1# Copyright (C) 2004, 2007-2008, 2010-2012 Free Software Foundation,
2# Inc.
b89667eb
DE
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
20set NR_THREADS 4
21
b89667eb
DE
22set testfile "interrupted-hand-call"
23set srcfile ${testfile}.c
24set binfile ${objdir}/${subdir}/${testfile}
25
26if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}" "additional_flags=-DNR_THREADS=$NR_THREADS"]] != "" } {
27 return -1
28}
29
30# Some targets can't do function calls, so don't even bother with this
31# test.
32if [target_info exists gdb,cannot_call_functions] {
33 setup_xfail "*-*-*" 2416
34 fail "This target can not call functions"
35 continue
36}
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43if { ![runto_main] } {
44 fail "Can't run to main"
45 return 0
46}
47
48gdb_test "break all_threads_running" \
49 "Breakpoint 2 at .*: file .*${srcfile}, line .*" \
50 "breakpoint on all_threads_running"
51
52# Run the program and make sure GDB reports that we stopped after
53# hitting breakpoint 2 in all_threads_running().
54
55gdb_test "continue" \
56 ".*Breakpoint 2, all_threads_running ().*" \
57 "run to all_threads_running"
58
59# NOTE: Don't turn on scheduler-locking here.
60# We want the main thread (hand_call_with_signal) and
61# thread 1 (sigabrt_handler) to both run.
62
63gdb_test "call hand_call_with_signal()" \
64 ".*in another thread.*" \
65 "hand-call interrupted by signal in another thread"
66
67# Verify dummy stack frame is still present.
68
69gdb_test "maint print dummy-frames" ".*stack=.*" "dummy stack frame present"
70
71# Continuing now should exit the hand-call and pop the dummy frame.
72
f6978de9 73gdb_test "continue" ".*" "finish hand-call"
b89667eb
DE
74
75gdb_test_multiple "maint print dummy-frames" "dummy frame popped" {
76 -re ".*stack=.*$gdb_prompt $" {
77 fail "dummy frame popped"
78 }
79 -re ".*$gdb_prompt $" {
80 pass "dummy frame popped"
81 }
82}
83
84# Continue one last time, the program should exit normally.
85
eceb0c5f 86gdb_continue_to_end "" continue 1
b89667eb
DE
87
88return 0
This page took 0.543719 seconds and 4 git commands to generate.