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