445c5895d63041f469035c04f88718f29addd172
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / run-after-attach.exp
1 # Copyright (C) 2015-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 # 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
19 if ![can_spawn_for_attach] {
20 return 0
21 }
22
23 standard_testfile
24 set executable $testfile
25
26 if [prepare_for_testing "failed to prepare" $executable] {
27 return -1
28 }
29
30 set test_spawn_id [spawn_wait_for_attach $binfile]
31 set test_pid [spawn_id_get_pid $test_spawn_id]
32
33 set test "attach to process"
34 gdb_test "attach $test_pid" "Attaching to program.*" $test
35
36 set test "kill process"
37 gdb_test "kill" "" $test \
38 "Kill the program being debugged.*y or n. $" "y"
39
40 set test "restart process"
41 gdb_test "start" "Starting program.*Temporary breakpoint .*" $test
42
43 set 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.
46 set ok 0
47 gdb_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
62 kill_wait_spawned_process $test_spawn_id
This page took 0.030792 seconds and 3 git commands to generate.