public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/9] [gdb/testsuite] Fix gdb.base/print-file-var.exp for remote target
Date: Mon,  7 Nov 2022 17:13:28 +0100	[thread overview]
Message-ID: <20221107161333.16999-5-tdevries@suse.de> (raw)
In-Reply-To: <20221107161333.16999-1-tdevries@suse.de>

When running test-case gdb.base/print-file-var.exp with target board
remote-gdbserver-on-localhost (using REMOTE_TARGET_USERNAME) we run into some
failures.

Fix these by using the name of a shared lib as returned by gdb_load_shlib.

This required splitting up the gdb_load_shlib functionality, which is now
defined as:
...
proc gdb_load_shlib { file } {
    set dest [gdb_download_shlib $file]
    gdb_locate_shlib $file
    return $dest
}
...
such that we can do gdb_download_shlib before gdb is started.

Tested on x86_64-linux.

Co-Authored-by: Ivan Tetyushkin <ivan.tetyushkin@syntacore.com>
---
 gdb/testsuite/gdb.base/print-file-var.exp |  6 ++--
 gdb/testsuite/lib/gdb.exp                 | 40 ++++++++++++++---------
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp
index 9abe87d7758..841eb22d957 100644
--- a/gdb/testsuite/gdb.base/print-file-var.exp
+++ b/gdb/testsuite/gdb.base/print-file-var.exp
@@ -59,8 +59,10 @@ proc test {hidden dlopen version_id_main lang} {
     set main_opts [list debug $lang]
     set link_opts [list debug shlib=${libobj1}]
 
+    set target_libobj2 [gdb_download_shlib $libobj2]
+
     if {$dlopen} {
-	lappend main_opts "additional_flags=-DSHLIB_NAME=\"$libobj2\""
+	lappend main_opts "additional_flags=-DSHLIB_NAME=\"$target_libobj2\""
 	lappend link_opts "shlib_load"
     } else {
 	lappend link_opts "shlib=${libobj2}"
@@ -79,7 +81,7 @@ proc test {hidden dlopen version_id_main lang} {
 
     clean_restart $executable
     gdb_load_shlib $libobj1
-    gdb_load_shlib $libobj2
+    gdb_locate_shlib $libobj2
 
     if ![runto_main] {
 	return -1
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e2cda30b95a..ef609e6e37e 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5869,30 +5869,40 @@ proc gdb_remote_download {dest fromfile {tofile {}}} {
     }
 }
 
-# gdb_load_shlib LIB...
-#
-# Copy the listed library to the target.
+# Copy shlib FILE to the target.
 
-proc gdb_load_shlib { file } {
+proc gdb_download_shlib { file } {
+    return [gdb_remote_download target [shlib_target_file $file]]
+}
+
+# Set solib-search-path to allow gdb to locate shlib FILE.
+
+proc gdb_locate_shlib { file } {
     global gdb_spawn_id
 
     if ![info exists gdb_spawn_id] {
 	perror "gdb_load_shlib: GDB is not running"
     }
 
-    set dest [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.
-	gdb_test "set solib-search-path [file dirname $file]" "" \
-	    "set solib-search-path for [file tail $file]"
+    # 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.
+    gdb_test "set solib-search-path [file dirname $file]" "" \
+	"set solib-search-path for [file tail $file]"
+}
+
+# Copy shlib FILE to the target and set solib-search-path to allow gdb to
+# locate it.
+
+proc gdb_load_shlib { file } {
+    set dest [gdb_download_shlib $file]
+    gdb_locate_shlib $file
     return $dest
 }
 
-- 
2.35.3


  parent reply	other threads:[~2022-11-07 16:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 16:13 [PATCH 0/9] [gdb/testsuite] Fix remote target test fails Tom de Vries
2022-11-07 16:13 ` [PATCH 1/9] [gdb/testsuite] Fix gdb.base/foll-exec.exp for remote target Tom de Vries
2022-11-07 16:13 ` [PATCH 2/9] [gdb/testsuite] Fix gdb.base/info_sources_2.exp " Tom de Vries
2022-11-07 16:13 ` [PATCH 3/9] [gdb/testsuite] Add REMOTE_TARGET_USERNAME in remote-gdbserver-on-localhost.exp Tom de Vries
2022-11-08  9:18   ` Tom de Vries
2022-11-09 20:49     ` Tom de Vries
2022-11-15 14:31       ` Tom de Vries
2022-11-07 16:13 ` Tom de Vries [this message]
2022-11-07 16:13 ` [PATCH 5/9] [gdb/testsuite] Fix gdb.base/infcall-exec.exp for remote target Tom de Vries
2022-11-07 16:13 ` [PATCH 6/9] [gdb/testsuite] Fix gdb.base/solib-vanish.exp " Tom de Vries
2022-11-07 16:13 ` [PATCH 7/9] [gdb/testsuite] Fix gdb.base/info-shared.exp " Tom de Vries
2022-11-07 16:13 ` [PATCH 8/9] [gdb/testsuite] Fix gdb.base/jit-reader-exec.exp " Tom de Vries
2022-11-07 16:13 ` [PATCH 9/9] [gdb/testsuite] Fix gdb.base/jit-elf-so.exp " Tom de Vries
2022-11-15 14:30 ` [PATCH 0/9] [gdb/testsuite] Fix remote target test fails Tom de Vries

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=20221107161333.16999-5-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).