Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / boards / native-extended-gdbserver.exp
CommitLineData
88b9d363 1# Copyright 2011-2022 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
27# We will be using the extended GDB remote protocol.
28set_board_info gdb_protocol "extended-remote"
29
4ec70201 30send_user "configuring for gdbserver local testing (extended-remote)\n"
048fe15a
PA
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.
36load_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.
42proc 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#
54if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
55 rename mi_gdb_start extended_gdbserver_mi_gdb_start
56}
57proc mi_gdb_start { args } {
e797481d
PA
58 global gdbserver_reconnect_p
59
048fe15a
PA
60 # Spawn GDB.
61 set res [extended_gdbserver_mi_gdb_start $args]
62 if { $res } {
63 return $res
64 }
65
e797481d
PA
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 }
048fe15a
PA
71 return 0
72}
73
f5ca0032
PA
74# Helper that runs "set remote exec-file" with the last loaded file.
75
76proc extended_gdbserver_load_last_file {} {
048fe15a 77 global gdb_prompt
5b80f00d 78 global last_loaded_file
048fe15a 79
5b80f00d 80 send_gdb "set remote exec-file $last_loaded_file\n"
048fe15a
PA
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
f5ca0032
PA
92# Overriden in order to set the remote exec-file whenever a file is
93# loaded to gdb.
94#
95if { [info procs extended_gdbserver_gdb_file_cmd] == "" } {
96 rename gdb_file_cmd extended_gdbserver_gdb_file_cmd
97}
98proc gdb_file_cmd { arg } {
99 if [extended_gdbserver_gdb_file_cmd $arg] {
100 return -1
101 }
102 return [extended_gdbserver_load_last_file]
103}
104
75d04512 105proc gdb_reload { {inferior_args {}} } {
f5ca0032
PA
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.
114proc gdb_load { arg } {
115 if { $arg != "" } {
116 if [gdb_file_cmd $arg] then { return -1 }
117 }
118
119 return [extended_gdbserver_load_last_file]
120}
121
122
048fe15a
PA
123# Likewise, for MI.
124#
125if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
126 rename mi_gdb_load extended_gdbserver_mi_gdb_load
127}
128proc mi_gdb_load { arg } {
129 global mi_gdb_prompt
130
131 set res [extended_gdbserver_mi_gdb_load $arg]
132 if { $res } then { 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}
This page took 1.28012 seconds and 4 git commands to generate.