]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.server/ext-attach.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.server / ext-attach.exp
CommitLineData
2d717e4f
DJ
1# This testcase is part of GDB, the GNU debugger.
2
3666a048 3# Copyright 2007-2021 Free Software Foundation, Inc.
2d717e4f
DJ
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18# Test attaching to already-running programs using extended-remote.
19
20load_lib gdbserver-support.exp
a0743c90 21load_lib trace-support.exp
2d717e4f 22
b0963d73 23standard_testfile
2d717e4f
DJ
24
25if { [skip_gdbserver_tests] } {
26 return 0
27}
28
60b3033e 29if {![can_spawn_for_attach]} {
2d717e4f
DJ
30 return 0
31}
32
5b362f04 33if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
2d717e4f
DJ
34 return -1
35}
36
a1999d40
PA
37# Make sure we're disconnected, in case we're testing with an
38# extended-remote board, therefore already connected.
39gdb_test "disconnect" ".*"
40
6496a609 41set target_exec [gdbserver_download_current_prog]
2d717e4f
DJ
42gdbserver_start_extended
43
89493308 44gdb_test_no_output "set remote exec-file $target_exec" "set remote exec-file"
2d717e4f 45
2c8c5d37
PA
46set test_spawn_id [spawn_wait_for_attach $binfile]
47set testpid [spawn_id_get_pid $test_spawn_id]
2d717e4f 48
7cee1e54
PA
49gdb_test "attach $testpid" \
50 "Attaching to program: .*, process $testpid.*(in|at).*" \
2d717e4f 51 "attach to remote program 1"
a0743c90
YQ
52
53if { [gdb_target_supports_trace] } then {
54 # Test predefined TSVs are uploaded.
55 gdb_test_sequence "info tvariables" "check uploaded tsv" {
56 "\[\r\n\]+Name\[\t \]+Initial\[\t \]+Current"
57 "\[\r\n\]+\\\$trace_timestamp 0"
58 }
59}
60
2d717e4f
DJ
61gdb_test "backtrace" ".*main.*" "backtrace 1"
62
7cee1e54 63gdb_test "detach" "Detaching from program.*process.*"
2d717e4f
DJ
64gdb_test "backtrace" "No stack\\." "backtrace with no program"
65
7cee1e54
PA
66gdb_test "attach $testpid" \
67 "Attaching to program: .*, process $testpid.*(in|at).*" \
2d717e4f
DJ
68 "attach to remote program 2"
69gdb_test "backtrace" ".*main.*" "backtrace 2"
70
5ed7a928 71gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
f6978de9 72gdb_test_no_output "monitor exit"
2c8c5d37
PA
73
74kill_wait_spawned_process $test_spawn_id