binutils-gdb/gdb/testsuite/lib
Pedro Alves 5b80f00d51 gdb_load: Fix latent bugs
In a test I was writting, I needed a procedure that would connect to
the target, and do "load", or equivalent.

Years ago, boards would override gdb_load to implement that.  Then
gdb_reload was added, and gdb_load was relaxed to allow boards avoid
the spawing and connecting to the target.  This sped up gdbserver
testing.  See
https://www.sourceware.org/ml/gdb-patches/2007-02/msg00318.html.

To actually spawn the target and load the executable on the target
side, gdb_reload was born:

 # gdb_reload -- load a file into the target.  Called before "running",
 # either the first time or after already starting the program once,
 # for remote targets.  Most files that override gdb_load should now
 # override this instead.

 proc gdb_reload { } {
     # For the benefit of existing configurations, default to gdb_load.
     # Specifying no file defaults to the executable currently being
     # debugged.
     return [gdb_load ""]
 }

Note the comment about specifying no file.  Indeed looking at
config/sid.exp, or config/monitor.exp, we see examples of that.

However, the default gdb_load itself doesn't handle the case of no
file specified.  When passed no file, it just calls gdb_file_cmd with
no file either, which ends up invocing the "file" command with no
argument, which means unloading the file and its symbols...  That
means calling gdb_reload when testing against native targets is
broken.  We don't see that today because the only call to gdb_reload
that exists today is guarded by target_info exists
gdb,do_reload_on_run.

The native-extended-gdbserver.exp board is likewise broken here.  When
[gdb_load ""] is called, the board sets the remote exec-file to "" ...

Tested on x86_64 Fedora 17, native, remote gdbserver and
extended-remote gdbserver.

testsuite/
2014-05-01  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (gdb_load): Extend comment.  Skip calling
	gdb_file_cmd if no file is specified.
	* boards/native-extended-gdbserver.exp (gdb_load): Use the
	last_loaded_file to set the remote exec-file.
2014-05-02 00:59:31 +01:00
..
ada.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
append_gdb_boards_dir.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
cache.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
cell.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
cl_util.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
cl_util.h Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
compiler.c Add support to recognize clang. 2014-04-07 14:14:03 -07:00
compiler.cc Add support to recognize clang. 2014-04-07 14:14:03 -07:00
cp-support.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
d-support.exp Add gdb.dlang to the gdb testsuite for the purpose of creating D 2014-01-18 18:09:28 +00:00
dwarf.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fortran.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
future.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb-guile.exp Add Guile as an extension language. 2014-02-09 19:40:01 -08:00
gdb-python.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb.exp gdb_load: Fix latent bugs 2014-05-02 00:59:31 +01:00
gdbserver-support.exp Fix wrapper.exp testcase with stdio gdbserver. 2014-04-16 10:40:41 -07:00
go.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
java.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-support.exp Introduce some new MI test suite cleanups for breakpoint and 2014-04-23 12:17:31 -07:00
objc.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
opencl.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
opencl_hostapp.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
opencl_kernel.cl gdb: 2010-11-05 14:31:30 +00:00
pascal.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
perftest.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
prelink-support.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
prompt.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
range-stepping-support.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
selftest-support.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
set_unbuffered_mode.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-support.exp Check tracefile is generated by binary execution 2014-04-22 09:57:44 +08:00