]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/boards/native-extended-gdbserver.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / boards / native-extended-gdbserver.exp
CommitLineData
618f726f 1# Copyright 2011-2016 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"
048fe15a
PA
25
26# By default, dejagnu makes the board remote unless the board name
27# matches localhost. Force it to be NOT remote.
28global board
29global board_info
42d9e528
PA
30# Remove any target variant specifications from the name.
31set baseboard [lindex [split $board "/"] 0]
32set board_info($baseboard,isremote) 0
048fe15a 33
048fe15a
PA
34set_board_info sockethost "localhost:"
35
36# We will be using the extended GDB remote protocol.
37set_board_info gdb_protocol "extended-remote"
38
4ec70201 39send_user "configuring for gdbserver local testing (extended-remote)\n"
048fe15a
PA
40
41# We must load this explicitly here, and rename the procedures we want
42# to override. If we didn't do this, given that mi-support.exp is
43# loaded later in the test files, the procedures loaded then would
44# override our definitions.
45load_lib mi-support.exp
46
47# Overriden in order to start a "gdbserver --multi" instance whenever
48# GDB is started. Note nothing is needed for gdb_exit, since
49# gdbserver is started with --once, causing it to exit once GDB
50# disconnects.
51proc gdb_start { } {
52 # Spawn GDB.
53 default_gdb_start
54
55 # And then GDBserver, ready for extended-remote mode.
56 gdbserver_start_multi
57
58 return 0
59}
60
61# Likewise, for MI.
62#
63if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
64 rename mi_gdb_start extended_gdbserver_mi_gdb_start
65}
66proc mi_gdb_start { args } {
e797481d
PA
67 global gdbserver_reconnect_p
68
048fe15a
PA
69 # Spawn GDB.
70 set res [extended_gdbserver_mi_gdb_start $args]
71 if { $res } {
72 return $res
73 }
74
e797481d
PA
75 # And then spawn GDBserver and connect to it in extended-remote
76 # mode, unless the test wants to explicitly test reconnection.
77 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
78 mi_gdbserver_start_multi
79 }
048fe15a
PA
80 return 0
81}
82
83# Overriden in order to set the remote exec-file whenever a file is
84# loaded to gdb.
85#
86proc gdb_load { arg } {
87 global gdb_prompt
5b80f00d 88 global last_loaded_file
048fe15a
PA
89
90 if { $arg != "" } {
91 if [gdb_file_cmd $arg] then { return -1 }
92 }
93
5b80f00d 94 send_gdb "set remote exec-file $last_loaded_file\n"
048fe15a
PA
95 gdb_expect {
96 -re "$gdb_prompt $" {}
97 timeout {
98 perror "couldn't set the remote exec-file (timed out)."
99 return -1
100 }
101 }
102
103 return 0
104}
105
106# Likewise, for MI.
107#
108if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
109 rename mi_gdb_load extended_gdbserver_mi_gdb_load
110}
111proc mi_gdb_load { arg } {
112 global mi_gdb_prompt
113
114 set res [extended_gdbserver_mi_gdb_load $arg]
115 if { $res } then { return -1 }
116
117 send_gdb "100-gdb-set remote exec-file $arg\n"
118 gdb_expect 10 {
119 -re ".*100-gdb-set remote exec-file $arg\r\n100\\\^done\r\n$mi_gdb_prompt$" {
120 verbose "set the remote exec-file to $arg."
121 }
122 timeout {
123 perror "couldn't set the remote exec-file (timed out)."
124 }
125 }
126
127 return 0
128}