old-cross-binutils/gdb/testsuite/boards/native-extended-gdbserver.exp
Pedro Alves e797481d53 Fix {mi-tracepoint-changed, mi-tsv-changed}.exp with native-extended-gdbserver
Fixes:

 -FAIL: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint created
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint on marker is installed
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1


 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

These tests do something like this:

 #0 - start gdb/gdbserver normally
 #1 - setup some things in the debug session
 #2 - disconnect from gdbserver
 #3 - restart gdb
 #4 - reconnect to gdbserver

The problem is that the native-extended-gdbserver board always spawns
a new gdbserver instance in #3 (and has gdb connect to that).  So when
the test gets to #4, it connects to that new instance instead of the
old one:

 (gdb) spawn ../gdbserver/gdbserver --multi :2354
 Listening on port 2354
 target extended-remote localhost:2354
 Remote debugging using localhost:2354
 ...
 spawn ../gdbserver/gdbserver --multi :2355
 Listening on port 2355
 47-target-select extended-remote localhost:2355
 =tsv-created,name="trace_timestamp",initial="0"\n
 47^connected
 (gdb)
 ...
 47-target-select extended-remote localhost:2355
 47^connected
 (gdb)
 FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

testsuite/ChangeLog:
2015-04-16  Pedro Alves  <palves@redhat.com>

	* boards/native-extended-gdbserver.exp (mi_gdb_start): Don't start
	a new gdbserver if gdbserver_reconnect_p is set.
2015-04-16 14:36:52 +01:00

128 lines
3.7 KiB
Text

# Copyright 2011-2015 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is a dejagnu "board file" and is used to run the testsuite
# natively with gdbserver, in extended-remote mode.
#
# To use this file:
# bash$ cd ${build_dir}/gdb
# bash$ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver"
load_generic_config "extended-gdbserver"
load_board_description "gdbserver-base"
# By default, dejagnu makes the board remote unless the board name
# matches localhost. Force it to be NOT remote.
global board
global board_info
# Remove any target variant specifications from the name.
set baseboard [lindex [split $board "/"] 0]
set board_info($baseboard,isremote) 0
set_board_info sockethost "localhost:"
# We will be using the extended GDB remote protocol.
set_board_info gdb_protocol "extended-remote"
send_user "configuring for gdbserver local testing (extended-remote)\n"
# We must load this explicitly here, and rename the procedures we want
# to override. If we didn't do this, given that mi-support.exp is
# loaded later in the test files, the procedures loaded then would
# override our definitions.
load_lib mi-support.exp
# Overriden in order to start a "gdbserver --multi" instance whenever
# GDB is started. Note nothing is needed for gdb_exit, since
# gdbserver is started with --once, causing it to exit once GDB
# disconnects.
proc gdb_start { } {
# Spawn GDB.
default_gdb_start
# And then GDBserver, ready for extended-remote mode.
gdbserver_start_multi
return 0
}
# Likewise, for MI.
#
if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
rename mi_gdb_start extended_gdbserver_mi_gdb_start
}
proc mi_gdb_start { args } {
global gdbserver_reconnect_p
# Spawn GDB.
set res [extended_gdbserver_mi_gdb_start $args]
if { $res } {
return $res
}
# And then spawn GDBserver and connect to it in extended-remote
# mode, unless the test wants to explicitly test reconnection.
if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
mi_gdbserver_start_multi
}
return 0
}
# Overriden in order to set the remote exec-file whenever a file is
# loaded to gdb.
#
proc gdb_load { arg } {
global gdb_prompt
global last_loaded_file
if { $arg != "" } {
if [gdb_file_cmd $arg] then { return -1 }
}
send_gdb "set remote exec-file $last_loaded_file\n"
gdb_expect {
-re "$gdb_prompt $" {}
timeout {
perror "couldn't set the remote exec-file (timed out)."
return -1
}
}
return 0
}
# Likewise, for MI.
#
if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
rename mi_gdb_load extended_gdbserver_mi_gdb_load
}
proc mi_gdb_load { arg } {
global mi_gdb_prompt
set res [extended_gdbserver_mi_gdb_load $arg]
if { $res } then { return -1 }
send_gdb "100-gdb-set remote exec-file $arg\n"
gdb_expect 10 {
-re ".*100-gdb-set remote exec-file $arg\r\n100\\\^done\r\n$mi_gdb_prompt$" {
verbose "set the remote exec-file to $arg."
}
timeout {
perror "couldn't set the remote exec-file (timed out)."
}
}
return 0
}