From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PUSHED] gdb_load: Fix latent bugs
Date: Fri, 02 May 2014 00:33:00 -0000 [thread overview]
Message-ID: <1398988835-5392-1-git-send-email-palves@redhat.com> (raw)
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.
---
gdb/testsuite/ChangeLog | 7 +++++++
gdb/testsuite/boards/native-extended-gdbserver.exp | 3 ++-
gdb/testsuite/lib/gdb.exp | 7 +++++--
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index e03d39a..3dac79f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
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-01 Pedro Alves <palves@redhat.com>
+
* boards/local-remote-host.exp: New file.
2014-05-01 Pedro Alves <palves@redhat.com>
diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp
index 8bb95db..2c405a8 100644
--- a/gdb/testsuite/boards/native-extended-gdbserver.exp
+++ b/gdb/testsuite/boards/native-extended-gdbserver.exp
@@ -78,12 +78,13 @@ proc mi_gdb_start { args } {
#
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 $arg\n"
+ send_gdb "set remote exec-file $last_loaded_file\n"
gdb_expect {
-re "$gdb_prompt $" {}
timeout {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 07249c6..3125e7a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3491,11 +3491,14 @@ proc gdb_load_shlibs { args } {
}
#
-# gdb_load -- load a file into the debugger.
+# gdb_load -- load a file into the debugger. Specifying no file
+# defaults to the executable currently being debugged.
# Many files in config/*.exp override this procedure.
#
proc gdb_load { arg } {
- return [gdb_file_cmd $arg]
+ if { $arg != "" } {
+ return [gdb_file_cmd $arg]
+ }
}
# gdb_reload -- load a file into the target. Called before "running",
--
1.7.11.7
reply other threads:[~2014-05-02 0:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1398988835-5392-1-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).