From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost
Date: Tue, 7 Mar 2023 10:00:15 +0100 [thread overview]
Message-ID: <20230307090015.1250-1-tdevries@suse.de> (raw)
When running test-cases gdb.mi/*.exp with target board
remote-gdbserver-on-localhost, we run into a few fails.
Fix these (and make things more similar to the gdb.exp procs) by:
- factoring out mi_load_shlib out of mi_load_shlibs
- making mi_load_shlib use gdb_download_shlib, like
gdb_load_shlib
- factoring out mi_locate_shlib out of mi_load_shlib
- making mi_locate_shlib check for mi_spawn_id, like
gdb_locate_shlib
- using gdb_download_shlib and mi_locate_shlib in the test-cases.
Tested on x86_64-linux, with and without target board
remote-gdbserver-on-localhost.
---
gdb/testsuite/gdb.mi/mi-catch-load.exp | 4 ++
.../gdb.mi/mi-var-invalidate-shlib.exp | 5 ++-
gdb/testsuite/lib/mi-support.exp | 40 ++++++++++++++-----
3 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/mi-catch-load.exp b/gdb/testsuite/gdb.mi/mi-catch-load.exp
index 842f4b47f1d..9d15e84d5dc 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-load.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-load.exp
@@ -32,9 +32,12 @@ if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] !
return -1
}
+gdb_download_shlib $binfile2
+
# test -catch-load
with_test_prefix "catch-load" {
mi_clean_restart $binfile
+ mi_locate_shlib $binfile2
mi_runto_main
mi_gdb_test "111-gdb-set auto-solib-add on" "111\\^done" \
@@ -61,6 +64,7 @@ with_test_prefix "catch-load" {
# test -catch-unload
with_test_prefix "catch-unload" {
mi_clean_restart $binfile
+ mi_locate_shlib $binfile2
mi_runto_main
mi_gdb_test "111-gdb-set auto-solib-add on" "111\\^done" "auto-solib-add on"
diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp
index 94eccdf63a0..47ac54f7088 100644
--- a/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp
@@ -30,8 +30,9 @@ if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $shlib_path {debug}] != "" } {
return -1
}
+set shlib_path_target [gdb_download_shlib $shlib_path]
-set opts [list shlib_load debug additional_flags=-DSHLIB_PATH="${shlib_path}"]
+set opts [list shlib_load debug additional_flags=-DSHLIB_PATH="${shlib_path_target}"]
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
untested "failed to compile"
return -1
@@ -45,7 +46,7 @@ proc do_test { separate_debuginfo } {
# Start the process once and create varobjs referencing the loaded objfiles.
with_test_prefix "setup" {
- mi_load_shlibs $::shlib_path
+ mi_locate_shlib $::shlib_path
if { $separate_debuginfo } {
mi_load_shlibs ${::shlib_path}.debug
}
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index ab251da339c..3c2dd2fab2b 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2069,20 +2069,38 @@ proc check_mi_and_console_threads {name} {
}
}
+# Set solib-search-path to allow gdb to locate shlib FILE.
+proc mi_locate_shlib { file } {
+ global mi_spawn_id
+
+ if ![info exists mi_spawn_id] {
+ perror "mi_locate_shlib: GDB is not running"
+ }
+
+ # If the target is remote, we need to tell gdb where to find the
+ # libraries.
+ if { ![is_remote target] } {
+ return
+ }
+
+ # We could set this even when not testing remotely, but a user
+ # generally won't set it unless necessary. In order to make the tests
+ # more like the real-life scenarios, we don't set it for local testing.
+ mi_gdb_test "set solib-search-path [file dirname $file]" "\^done" ""
+}
+
+# Copy shlib FILE to the target and set solib-search-path to allow gdb to
+# locate it.
+proc mi_load_shlib { file } {
+ set dest [gdb_download_shlib $file]
+ mi_locate_shlib $file
+ return $dest
+}
+
# Download shared libraries to the target.
proc mi_load_shlibs { args } {
foreach file $args {
- gdb_remote_download target [shlib_target_file $file]
- }
-
- if {[is_remote target]} {
- # If the target is remote, we need to tell gdb where to find the
- # libraries.
- #
- # We could set this even when not testing remotely, but a user
- # generally won't set it unless necessary. In order to make the tests
- # more like the real-life scenarios, we don't set it for local testing.
- mi_gdb_test "set solib-search-path [file dirname [lindex $args 0]]" "\^done" ""
+ mi_load_shlib $file
}
}
base-commit: 07f285934886016ddd82cac99a3873e68b499d5c
--
2.35.3
reply other threads:[~2023-03-07 9:00 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=20230307090015.1250-1-tdevries@suse.de \
--to=tdevries@suse.de \
--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).