Don't redefine upload/download/file in gdbserver-base
[deliverable/binutils-gdb.git] / gdb / testsuite / boards / native-extended-gdbserver.exp
CommitLineData
e2882c85 1# Copyright 2011-2018 Free Software Foundation, Inc.
048fe15a
PA
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:
048fe15a
PA
20# bash$ cd ${build_dir}/gdb
21# bash$ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver"
22
23load_generic_config "extended-gdbserver"
7c0de741 24load_board_description "gdbserver-base"
739b3f1d 25load_board_description "local-board"
048fe15a 26
048fe15a
PA
27set_board_info sockethost "localhost:"
28
29# We will be using the extended GDB remote protocol.
30set_board_info gdb_protocol "extended-remote"
31
4ec70201 32send_user "configuring for gdbserver local testing (extended-remote)\n"
048fe15a
PA
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.
38load_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.
44proc 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#
56if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
57 rename mi_gdb_start extended_gdbserver_mi_gdb_start
58}
59proc mi_gdb_start { args } {
e797481d
PA
60 global gdbserver_reconnect_p
61
048fe15a
PA
62 # Spawn GDB.
63 set res [extended_gdbserver_mi_gdb_start $args]
64 if { $res } {
65 return $res
66 }
67
e797481d
PA
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 }
048fe15a
PA
73 return 0
74}
75
f5ca0032
PA
76# Helper that runs "set remote exec-file" with the last loaded file.
77
78proc extended_gdbserver_load_last_file {} {
048fe15a 79 global gdb_prompt
5b80f00d 80 global last_loaded_file
048fe15a 81
5b80f00d 82 send_gdb "set remote exec-file $last_loaded_file\n"
048fe15a
PA
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
f5ca0032
PA
94# Overriden in order to set the remote exec-file whenever a file is
95# loaded to gdb.
96#
97if { [info procs extended_gdbserver_gdb_file_cmd] == "" } {
98 rename gdb_file_cmd extended_gdbserver_gdb_file_cmd
99}
100proc 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
107proc 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.
116proc 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
048fe15a
PA
125# Likewise, for MI.
126#
127if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
128 rename mi_gdb_load extended_gdbserver_mi_gdb_load
129}
130proc 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}
This page took 0.713133 seconds and 4 git commands to generate.