]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/signals-state-child.exp
gdb/testsuite: remove use of then keyword from gdb.ada/*.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / signals-state-child.exp
CommitLineData
4a94e368 1# Copyright 2016-2022 Free Software Foundation, Inc.
f348d89a
PA
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 that gdb's (or gdbserver's) own signal handling does not
17# interfere with the signal actions (dispositions, etc.) and mask
18# their spawned children inherit.
19#
20# - If gdb inherits some signal set to SIG_IGN, so should the
21# inferior, even if gdb itself chooses not to ignore the signal.
22#
23# - If gdb inherits some signal set to SIG_DFL, so should the inferior
24# even if gdb itself ignores that signal.
25#
26# This requires special support in gdb/gdbserver because the exec
27# family of functions does not reset the signal disposition of signals
28# that are set to SIG_IGN, nor signal masks and flags.
29
30standard_testfile
31
3589529e
YQ
32if {![is_remote host] && ![is_remote target]} {
33 set gdb_txt [standard_output_file gdb.txt]
34 set standalone_txt [standard_output_file standalone.txt]
35 set purely_local 1
36} else {
37 set gdb_txt gdb.txt
38 set standalone_txt standalone.txt
39 set purely_local 0
40}
41
42remote_file host delete $gdb_txt
43remote_file host delete $standalone_txt
44remote_file target delete $gdb_txt
45remote_file target delete $standalone_txt
f348d89a
PA
46
47set options [list debug "additional_flags=-DOUTPUT_TXT=\"$gdb_txt\""]
48if {[build_executable $testfile.exp $testfile $srcfile $options]} {
5b362f04 49 untested "failed to compile"
f348d89a
PA
50 return -1
51}
52
53set options [list debug "additional_flags=-DOUTPUT_TXT=\"$standalone_txt\""]
54if {[build_executable $testfile.exp $testfile-standalone $srcfile $options]} {
5b362f04 55 untested "failed to compile"
f348d89a
PA
56 return -1
57}
58
59# Run the program directly, and dump its initial signal actions and
60# mask in "standalone.txt".
61
62# Use remote_spawn instead of remote_exec, like how we spawn gdb.
63# This is in order to take the same code code paths in dejagnu
64# compared to when running the program through gdb. E.g., because
65# local_exec uses -ignore SIGHUP, while remote_spawn does not, if we
66# used remote_exec, the test program would start with SIGHUP ignored
67# when run standalone, but not when run through gdb.
3589529e 68set res [remote_spawn target "$binfile-standalone"]
f348d89a
PA
69if { $res < 0 || $res == "" } {
70 untested "spawning $binfile-standalone failed"
71 return 1
f348d89a 72}
a0cfd0ca
TV
73
74set wait_status [remote_wait target 60]
75set have_standalone [expr [lindex $wait_status 0] == 0]
76gdb_assert { $have_standalone } "collect standalone signals state"
3589529e 77remote_close target
f348d89a
PA
78
79# Now run the program through gdb, and dump its initial signal actions
80# and mask in "gdb.txt".
81
82clean_restart $binfile
83
84if { ! [ runto_main ] } then {
f348d89a
PA
85 return -1
86}
87
88gdb_continue_to_end "collect signals state under gdb"
89
a0cfd0ca
TV
90set test "signals states are identical"
91if { ! $have_standalone } {
92 untested $test
93 return -1
94}
95
3589529e
YQ
96if {!$purely_local} {
97 # Copy file from target to host through build.
98 remote_download host [remote_upload target gdb.txt] gdb.txt
99 remote_download host [remote_upload target standalone.txt] standalone.txt
100}
101
f348d89a
PA
102# Diff the .txt files. They should be identical.
103gdb_test "shell diff -s $standalone_txt $gdb_txt" \
104 "Files .* are identical.*" \
a0cfd0ca 105 $test