binutils-gdb/gdb/testsuite/config/sim.exp
Pedro Alves 78b2db9e7f gdb sim testing, set gdb_protocol to "sim"
Bernd reported that when testing with riscv-unknown-elf target using
the simulator, before commit c7a2ee6491 ("gdb_is_target_native ->
gdb_protocol_is_native"), he had:

 PASS: gdb.base/load-command.exp: probe for target native
 PASS: gdb.base/load-command.exp: check initial value of the_variable
 PASS: gdb.base/load-command.exp: manually change the_variable
 PASS: gdb.base/load-command.exp: check manually changed value of the_variable
 PASS: gdb.base/load-command.exp: reload: re-load binary
 PASS: gdb.base/load-command.exp: reload: check initial value of the_variable

and now:

 UNSUPPORTED: gdb.base/load-command.exp: the native target does not support the load command

The problem is that the sim board/config isn't setting gdb_protocol
anywhere, so gdb_protocol_is_native returns true.

This commit fixes it by making gdb/testsuite/config/sim.exp set
gdb_protocol to "sim".

Reported-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Tested-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Change-Id: I48a7afed004a3517b90220674fe5bc856fe7d09a
2024-05-10 11:48:57 +01:00

80 lines
2 KiB
Text

# Test Framework Driver for GDB driving a builtin simulator
# Copyright 1994-2024 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/>.
# If we left this empty, the core of the testsuite would think we were
# connecting to the native target.
set_board_info gdb_protocol "sim"
#
# gdb_target_sim
# Set gdb to target the simulator
#
proc gdb_target_sim { } {
global gdb_prompt
set target_sim_options "[board_info target gdb,target_sim_options]"
send_gdb "target sim $target_sim_options\n"
gdb_expect 60 {
-re "Connected to the simulator.*$gdb_prompt $" {
verbose "Set target to sim"
}
timeout {
perror "Couldn't set target for simulator."
return -1
}
}
return 0
}
#
# gdb_load -- load a file into the debugger.
# return a -1 if anything goes wrong.
#
proc gdb_load { arg } {
global verbose
global loadpath
global loadfile
global GDB
global gdb_prompt
if { $arg != "" } {
if {[gdb_file_cmd $arg]} { return -1 }
}
if {[gdb_target_sim]} { return -1 }
send_gdb "load\n"
gdb_expect 2400 {
-re ".*$gdb_prompt $" {
if {$verbose > 1} {
send_user "Loaded $arg into $GDB\n"
}
return 0
}
-re "$gdb_prompt $" {
if {$verbose > 1} {
perror "GDB couldn't load."
}
}
timeout {
if {$verbose > 1} {
perror "Timed out trying to load $arg."
}
}
}
return -1
}