]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/boards/native-extended-gdbserver.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / boards / native-extended-gdbserver.exp
1 # Copyright 2011-2024 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 # This file is a dejagnu "board file" and is used to run the testsuite
17 # natively with gdbserver, in extended-remote mode.
18 #
19 # To use this file:
20 # bash$ cd ${build_dir}/gdb
21 # bash$ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver"
22
23 load_generic_config "extended-gdbserver"
24 load_board_description "gdbserver-base"
25 load_board_description "local-board"
26
27 # We will be using the extended GDB remote protocol.
28 set_board_info gdb_protocol "extended-remote"
29
30 send_user "configuring for gdbserver local testing (extended-remote)\n"
31
32 # We must load this explicitly here, and rename the procedures we want
33 # to override. If we didn't do this, given that mi-support.exp is
34 # loaded later in the test files, the procedures loaded then would
35 # override our definitions.
36 load_lib mi-support.exp
37
38 # Overriden in order to start a "gdbserver --multi" instance whenever
39 # GDB is started. Note nothing is needed for gdb_exit, since
40 # gdbserver is started with --once, causing it to exit once GDB
41 # disconnects.
42 proc gdb_start { } {
43 # Spawn GDB.
44 default_gdb_start
45
46 # And then GDBserver, ready for extended-remote mode.
47 gdbserver_start_multi
48
49 return 0
50 }
51
52 # Likewise, for MI.
53 #
54 if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
55 rename mi_gdb_start extended_gdbserver_mi_gdb_start
56 }
57 proc mi_gdb_start { args } {
58 global gdbserver_reconnect_p
59
60 # Spawn GDB.
61 set res [eval extended_gdbserver_mi_gdb_start $args]
62 if { $res } {
63 return $res
64 }
65
66 # And then spawn GDBserver and connect to it in extended-remote
67 # mode, unless the test wants to explicitly test reconnection.
68 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
69 mi_gdbserver_start_multi
70 }
71 return 0
72 }
73
74 # Helper that runs "set remote exec-file" with the last loaded file.
75
76 proc extended_gdbserver_load_last_file {} {
77 global gdb_prompt
78 global last_loaded_file
79
80 send_gdb "set remote exec-file $last_loaded_file\n"
81 gdb_expect {
82 -re "$gdb_prompt $" {}
83 timeout {
84 perror "couldn't set the remote exec-file (timed out)."
85 return -1
86 }
87 }
88
89 return 0
90 }
91
92 # Overriden in order to set the remote exec-file whenever a file is
93 # loaded to gdb.
94 #
95 if { [info procs extended_gdbserver_gdb_file_cmd] == "" } {
96 rename gdb_file_cmd extended_gdbserver_gdb_file_cmd
97 }
98 proc gdb_file_cmd { arg {kill_flag 1} } {
99 if [extended_gdbserver_gdb_file_cmd $arg $kill_flag] {
100 return -1
101 }
102 return [extended_gdbserver_load_last_file]
103 }
104
105 proc gdb_reload { {inferior_args {}} } {
106 return [extended_gdbserver_load_last_file]
107 }
108
109 # With the two procedure overrides above, it shouldn't be necessary to
110 # override this one too. However, not doing so regresses
111 # gdb.base/dbx.exp. See comments above gdb.base/dbx.exp:gdb_file_cmd.
112 # Once testing of the "symbol-file"/"exec-file" commands is moved out
113 # to a separate non-dbx testcase, we should be able to remove this.
114 proc gdb_load { arg } {
115 if { $arg != "" } {
116 if {[gdb_file_cmd $arg]} { return -1 }
117 }
118
119 return [extended_gdbserver_load_last_file]
120 }
121
122
123 # Likewise, for MI.
124 #
125 if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
126 rename mi_gdb_load extended_gdbserver_mi_gdb_load
127 }
128 proc mi_gdb_load { arg } {
129 global mi_gdb_prompt
130
131 set res [extended_gdbserver_mi_gdb_load $arg]
132 if {$res} { return -1 }
133
134 send_gdb "100-gdb-set remote exec-file $arg\n"
135 gdb_expect 10 {
136 -re ".*100-gdb-set remote exec-file $arg\r\n100\\\^done\r\n$mi_gdb_prompt$" {
137 verbose "set the remote exec-file to $arg."
138 }
139 timeout {
140 perror "couldn't set the remote exec-file (timed out)."
141 }
142 }
143
144 return 0
145 }