[PATCH/RFC] gdb: tests: add support for testing FLAT toolchains

Mike Frysinger
2011-07-01T00:24:58Z

From: Jie Zhang <jie@codesourcery.com>

FLAT toolchains output a FLAT binary for the named output and create
another file with a .gdb suffix that is used for debugging. So when
testing a FLAT toolchain and we need to load up a file, use the .gdb.

This restarts an old thread and implements things as suggested by
Daniel Jacobowitz:
http://sourceware.org/ml/gdb-patches/2010-03/msg00648.html

Pretty sure this works (I'll double check), but I want to make sure
this is going in the direction people are OK with.

Signed-off-by: Jie Zhang <jie@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
gdb/testsuite/lib/gdb.exp | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index dc16cfa..091b271 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2091,6 +2091,16 @@ proc current_target_name { } {
return $answer
}

+proc gdb_get_exec_name { binfile } {
+ # FLAT toolchains have to load the .flt file to the board
+ if { [target_info exists use_binfmt_flat]
+ && [file exists "${binfile}.flt"] } {
+ return "${binfile}.flt"
+ } else {
+ return ${binfile}
+ }
+}
+
set gdb_wrapper_initialized 0
set gdb_wrapper_target ""

@@ -2286,6 +2296,16 @@ proc gdb_compile {source dest type options} {
clone_output "gdb compile failed, $result"
}
}
+
+ # FLAT toolchains output a bFLT file with the default name and create
+ # a secondary ELF file with a .gdb suffix. GDB needs the ELF file in
+ # order to do debugging, so flip-flop things.
+ if { [target_info exists use_binfmt_flat]
+ && [file exists "${dest}.gdb"] } {
+ file rename -force "${dest}" "${dest}.flt"
+ file rename -force "${dest}.gdb" "${dest}"
+ }
+
return $result;
}

@@ -2762,7 +2782,7 @@ proc gdb_touch_execfile { binfile } {
proc gdb_download { filename } {
global cleanfiles

- set destname [remote_download target $filename]
+ set destname [remote_download target [gdb_get_exec_name $filename]]
lappend cleanfiles $destname
return $destname
}
--
1.7.6