Reapply fix for gdb.cp/var-tag.exp C++ failures.
[deliverable/binutils-gdb.git] / gdb / testsuite / boards / native-extended-gdbserver.exp
1 # Copyright 2011-2015 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
26 # By default, dejagnu makes the board remote unless the board name
27 # matches localhost. Force it to be NOT remote.
28 global board
29 global board_info
30 # Remove any target variant specifications from the name.
31 set baseboard [lindex [split $board "/"] 0]
32 set board_info($baseboard,isremote) 0
33
34 set_board_info sockethost "localhost:"
35
36 # We will be using the extended GDB remote protocol.
37 set_board_info gdb_protocol "extended-remote"
38
39 send_user "configuring for gdbserver local testing (extended-remote)\n"
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.
45 load_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.
51 proc 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 #
63 if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
64 rename mi_gdb_start extended_gdbserver_mi_gdb_start
65 }
66 proc mi_gdb_start { args } {
67 global gdbserver_reconnect_p
68
69 # Spawn GDB.
70 set res [extended_gdbserver_mi_gdb_start $args]
71 if { $res } {
72 return $res
73 }
74
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 }
80 return 0
81 }
82
83 # Overriden in order to set the remote exec-file whenever a file is
84 # loaded to gdb.
85 #
86 proc gdb_load { arg } {
87 global gdb_prompt
88 global last_loaded_file
89
90 if { $arg != "" } {
91 if [gdb_file_cmd $arg] then { return -1 }
92 }
93
94 send_gdb "set remote exec-file $last_loaded_file\n"
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 #
108 if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
109 rename mi_gdb_load extended_gdbserver_mi_gdb_load
110 }
111 proc 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 }
This page took 0.033811 seconds and 4 git commands to generate.