2001-01-16 23:03:19 +00:00
|
|
|
# Test Framework Driver for GDB driving an external simulator
|
2015-01-01 09:32:14 +00:00
|
|
|
# Copyright 1999-2015 Free Software Foundation, Inc.
|
2001-01-16 23:03:19 +00:00
|
|
|
#
|
|
|
|
# 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
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2001-01-16 23:03:19 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2001-01-16 23:03:19 +00:00
|
|
|
# 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.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2001-01-16 23:03:19 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-01-16 23:03:19 +00:00
|
|
|
|
|
|
|
load_lib gdb.exp
|
|
|
|
|
|
|
|
proc sid_start {} {
|
|
|
|
global verbose
|
|
|
|
|
|
|
|
set port [lindex [split [target_info netport] ":"] 1]
|
|
|
|
|
|
|
|
# Set a default endianness
|
|
|
|
case [target_info multilib_flags] in {
|
|
|
|
{ *big-endian* *-EB* *-meb* } { set sidendian "-EB" }
|
|
|
|
{ *little-endian* *-EL* *-mel* } { set sidendian "-EL" }
|
|
|
|
default {
|
|
|
|
if {[target_info exists sim,defaultendian]} then {
|
|
|
|
set sidendian [target_info sim,defaultendian]
|
|
|
|
} else {
|
2001-08-16 14:19:54 +00:00
|
|
|
# rely on endianness settings in sid configuration defaults
|
|
|
|
set sidendian ""
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-29 20:36:06 +00:00
|
|
|
case $sidendian in {
|
|
|
|
{ -EB } { set sidendian2 {-e "set cpu endian big"} }
|
|
|
|
{ -EL } { set sidendian2 {-e "set cpu endian little"} }
|
|
|
|
default { set sidendian2 {} }
|
|
|
|
}
|
2001-01-16 23:03:19 +00:00
|
|
|
|
|
|
|
# test to see whether to use use sid in build or install tree
|
|
|
|
set use_build_tree [file exists ../../sid]
|
|
|
|
|
|
|
|
if {$use_build_tree} then {
|
|
|
|
set pre_spawn {
|
|
|
|
global env
|
|
|
|
set env(SID_LIBRARY_PATH) [join [glob "../../sid/component/*"] ":"]
|
|
|
|
set env(SID) "../../sid/main/dynamic/sid"
|
|
|
|
if {! [file exists $env(SID)]} then { error "Cannot find sid in build tree" }
|
|
|
|
}
|
2001-05-04 21:02:12 +00:00
|
|
|
if { [board_info target sim,protocol] == "sid" } {
|
2001-08-29 20:36:06 +00:00
|
|
|
set spawncmd "[target_info sim] [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
|
2002-05-06 12:19:30 +00:00
|
|
|
} elseif { [board_info target sim,protocol] == "rawsid" } {
|
|
|
|
set spawncmd "[target_info sim] [target_info sim,options] -$sidendian --gdb=$port"
|
2001-05-04 21:02:12 +00:00
|
|
|
} else {
|
2001-08-29 20:36:06 +00:00
|
|
|
set spawncmd "../../sid/bsp/[target_info sim] $sidendian --gdb=$port [target_info sim,options]"
|
2001-05-04 21:02:12 +00:00
|
|
|
}
|
2001-01-16 23:03:19 +00:00
|
|
|
set post_spawn {
|
|
|
|
global env
|
|
|
|
unset env(SID_LIBRARY_PATH)
|
|
|
|
unset env(SID)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set pre_spawn {}
|
2001-05-04 21:02:12 +00:00
|
|
|
if { [board_info target sim,protocol] == "sid" } {
|
|
|
|
# FIXME: sim,options may be from the build tree, should find
|
|
|
|
# it in the install tree.
|
2001-08-29 20:36:06 +00:00
|
|
|
set spawncmd "sid [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
|
2002-05-06 12:19:30 +00:00
|
|
|
} elseif { [board_info target sim,protocol] == "rawsid" } {
|
|
|
|
set spawncmd "[target_info sim] [target_info sim,options] -$sidendian --gdb=$port"
|
2001-05-04 21:02:12 +00:00
|
|
|
} else {
|
2001-08-29 20:36:06 +00:00
|
|
|
set spawncmd "[target_info sim] $sidendian --gdb=$port [target_info sim,options]"
|
2001-05-04 21:02:12 +00:00
|
|
|
}
|
2001-01-16 23:03:19 +00:00
|
|
|
set post_spawn {}
|
|
|
|
}
|
|
|
|
|
|
|
|
eval $pre_spawn
|
2001-05-04 21:02:12 +00:00
|
|
|
if {[catch [list remote_spawn host $spawncmd] msg]} {
|
2001-01-16 23:03:19 +00:00
|
|
|
perror $msg
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
eval $post_spawn
|
|
|
|
|
2001-08-29 20:36:06 +00:00
|
|
|
# Don't do the following any more; it breaks with "runtest ... < /dev/null"
|
|
|
|
# expect_background {
|
|
|
|
# -re \[^\n\]*\n {
|
|
|
|
# regsub "\n" $expect_out(buffer) {} msg
|
|
|
|
# verbose "SID: $msg" 2
|
|
|
|
# }
|
|
|
|
# }
|
2001-01-16 23:03:19 +00:00
|
|
|
|
|
|
|
# There should be no need to sleep to give SID time to start;
|
|
|
|
# GDB would wait for a fair while for the stub to respond.
|
|
|
|
sleep 4
|
|
|
|
|
2001-05-04 21:02:12 +00:00
|
|
|
if ![target_info exists gdb,no_push_conn] {
|
2013-06-07 17:31:09 +00:00
|
|
|
remote_push_conn host
|
2001-05-04 21:02:12 +00:00
|
|
|
}
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Handle GDB talking to SID
|
|
|
|
#
|
|
|
|
|
|
|
|
proc gdb_start {} {
|
|
|
|
sid_start
|
|
|
|
return [default_gdb_start]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc sid_exit {} {
|
2001-05-04 21:02:12 +00:00
|
|
|
if ![target_info exists gdb,no_push_conn] {
|
2013-06-07 17:31:09 +00:00
|
|
|
remote_close host
|
|
|
|
remote_pop_conn host
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proc gdb_exit {} {
|
|
|
|
set result [default_gdb_exit]
|
|
|
|
sid_exit
|
|
|
|
return $result
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# gdb_target_sid
|
|
|
|
# Set gdb to target the simulator
|
|
|
|
#
|
|
|
|
proc send_target_sid { } {
|
|
|
|
# wait a little while, giving sid time to shut down & restart its
|
|
|
|
# gdb socket
|
|
|
|
sleep 4
|
|
|
|
send_gdb "target [target_info gdb_protocol] [target_info netport]\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc gdb_target_sid { } {
|
|
|
|
global gdb_prompt
|
|
|
|
global exit_status
|
|
|
|
|
|
|
|
send_target_sid
|
|
|
|
|
|
|
|
global timeout
|
|
|
|
set prev_timeout $timeout
|
|
|
|
set timeout 60
|
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
gdb_expect {
|
2001-05-04 21:07:01 +00:00
|
|
|
-re ".*\[Ee\]rror.*$gdb_prompt $" {
|
|
|
|
perror "Couldn't set target for remote simulator."
|
|
|
|
cleanup
|
|
|
|
gdb_exit
|
|
|
|
}
|
2001-01-16 23:03:19 +00:00
|
|
|
-re "Remote debugging using.*$gdb_prompt" {
|
|
|
|
verbose "Set target to sid"
|
|
|
|
}
|
|
|
|
timeout {
|
|
|
|
perror "Couldn't set target for remote simulator."
|
|
|
|
cleanup
|
2001-05-04 21:07:01 +00:00
|
|
|
gdb_exit
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
set timeout $prev_timeout
|
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
2001-05-04 21:07:01 +00:00
|
|
|
global retval
|
2001-01-16 23:03:19 +00:00
|
|
|
|
2007-07-19 00:41:27 +00:00
|
|
|
if { $arg != "" } {
|
|
|
|
if [gdb_file_cmd $arg] then { return -1 }
|
|
|
|
}
|
|
|
|
|
2001-01-16 23:03:19 +00:00
|
|
|
gdb_target_sid
|
|
|
|
|
|
|
|
send_gdb "load\n"
|
|
|
|
global timeout
|
|
|
|
set prev_timeout $timeout
|
|
|
|
set timeout 2400
|
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
gdb_expect {
|
2001-05-04 21:07:01 +00:00
|
|
|
-re ".*\[Ee\]rror.*$gdb_prompt $" {
|
|
|
|
if $verbose>1 then {
|
|
|
|
perror "Error during download."
|
|
|
|
}
|
2013-06-07 17:31:09 +00:00
|
|
|
set retval -1
|
2001-05-04 21:07:01 +00:00
|
|
|
}
|
2001-01-16 23:03:19 +00:00
|
|
|
-re ".*$gdb_prompt $" {
|
|
|
|
if $verbose>1 then {
|
|
|
|
send_user "Loaded $arg into $GDB\n"
|
|
|
|
}
|
2013-06-07 17:31:09 +00:00
|
|
|
set retval 0
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
if $verbose>1 then {
|
|
|
|
perror "GDB couldn't load."
|
|
|
|
}
|
2013-06-07 17:31:09 +00:00
|
|
|
set retval -1
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
timeout {
|
|
|
|
if $verbose>1 then {
|
|
|
|
perror "Timed out trying to load $arg."
|
|
|
|
}
|
2013-06-07 17:31:09 +00:00
|
|
|
set retval -1
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
set timeout $prev_timeout
|
2001-05-04 21:07:01 +00:00
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 13:34:06 +00:00
|
|
|
return $retval
|
2001-01-16 23:03:19 +00:00
|
|
|
}
|