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