]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/run-after-attach.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / run-after-attach.exp
CommitLineData
213516ef 1# Copyright (C) 2015-2023 Free Software Foundation, Inc.
e9756d52
PP
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# Check that forking a process after a previous process was attached to unsets
17# attach_flag. This is done indirectly by inspecting GDB's quit prompt.
18
19if ![can_spawn_for_attach] {
20 return 0
21}
22
23standard_testfile
24set executable $testfile
25
5b362f04 26if [prepare_for_testing "failed to prepare" $executable] {
e9756d52
PP
27 return -1
28}
29
30set test_spawn_id [spawn_wait_for_attach $binfile]
31set test_pid [spawn_id_get_pid $test_spawn_id]
32
33set test "attach to process"
34gdb_test "attach $test_pid" "Attaching to program.*" $test
35
36set test "kill process"
37gdb_test "kill" "" $test \
38 "Kill the program being debugged.*y or n. $" "y"
39
40set test "restart process"
41gdb_test "start" "Starting program.*Temporary breakpoint .*" $test
42
43set test "attempt kill via quit"
44# The quit prompt should warn about killing the process, not about detaching the
45# process, since this process was not attached to.
46set ok 0
47gdb_test_multiple "quit" $test {
48 -re "will be killed.*.y or n. $" {
49 set ok 1
50 send_gdb "n\n"
51 exp_continue
52 }
53 -re "will be detached.*.y or n. $" {
54 send_gdb "n\n"
55 exp_continue
56 }
57 -re "$gdb_prompt $" {
58 gdb_assert $ok $test
59 }
60}
61
62kill_wait_spawned_process $test_spawn_id