public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 0/4] [gdb/testsuite] Fix one more remote host issue in gdb.arch tests
@ 2023-03-17 18:26 Tom de Vries
  2023-03-17 18:26 ` [pushed 1/4] [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host Tom de Vries
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tom de Vries @ 2023-03-17 18:26 UTC (permalink / raw)
  To: gdb-patches

I added REMOTE_HOST_USERNAME in local-remote-host, similar to
REMOTE_TARGET_USERNAME in remote-gdbserver-on-localhost, and when
testing found two failing test-cases in gdb.arch.

The new setup also made clear to me that testing target board
native-stdio-gdbserver in combination with remote host doesn't make sense, so
I've dropped that from my test matrix.  I considered erroring out in the
target board for remote host, but couldn't convince myself that it wouldn't be
overly restrictive.

Tested on x86_64-linux.

Tom de Vries (4):
  [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host
  [gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host
  [gdb/testsuite] Handle remote host in gdb_load_shlib
  [gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp

 gdb/testsuite/boards/local-remote-host.exp   | 27 +++++++++++++++++---
 gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp |  4 +--
 gdb/testsuite/gdb.arch/i386-biarch-core.exp  |  2 ++
 gdb/testsuite/lib/gdb.exp                    | 26 ++++++++++++++-----
 4 files changed, 48 insertions(+), 11 deletions(-)


base-commit: 3741934fdb04cde6661335e160249f9a83e498a7
-- 
2.35.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pushed 1/4] [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host
  2023-03-17 18:26 [pushed 0/4] [gdb/testsuite] Fix one more remote host issue in gdb.arch tests Tom de Vries
@ 2023-03-17 18:26 ` Tom de Vries
  2023-03-17 18:26 ` [pushed 2/4] [gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host Tom de Vries
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2023-03-17 18:26 UTC (permalink / raw)
  To: gdb-patches

Handle REMOTE_HOST_USERNAME in local-remote-host, similar to how that's done for
REMOTE_TARGET_USERNAME in remote-gdbserver-on-localhost.

This helps to keep the home dir clean.

Since the setup makes $build/gdb/testsuite on build unreadable for the remote
host, we run into permission problems for GDB and the data-directory, so fix
this (as was done for gdbserver in gdbserver-base.exp) using file normalize.

Tested on x86_64-linux.
---
 gdb/testsuite/boards/local-remote-host.exp | 27 +++++++++++++++++++---
 gdb/testsuite/lib/gdb.exp                  |  2 +-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/boards/local-remote-host.exp b/gdb/testsuite/boards/local-remote-host.exp
index e2085047882..f265208ddd9 100644
--- a/gdb/testsuite/boards/local-remote-host.exp
+++ b/gdb/testsuite/boards/local-remote-host.exp
@@ -22,12 +22,33 @@
 
 # Like local-remote-host-notty, but with readline/editing enabled.
 
-global GDB
-set GDB [file join [pwd] "../gdb"]
+set GDB [file normalize [file join [pwd] "../gdb"]]
 
 set_board_info hostname 127.0.0.1
 
-set_board_info username $env(USER)
+if { [info exists REMOTE_HOST_USERNAME] } {
+    set_board_info username $REMOTE_HOST_USERNAME
+} else {
+    set_board_info username $env(USER)
+}
+
+# Handle separate test account.
+if { [board_info $board username] != $env(USER) } {
+    # We're pretending that some local user account is remote host.
+    # Make things a bit more realistic by restricting file permissions.
+
+    # Make sure remote host can't see files on build.
+    remote_exec build "chmod go-rx $objdir"
+
+    # Make sure build can't see files on remote host.  We can't use
+    # remote_exec host, because we're in the middle of parsing the
+    # host board.
+    remote_exec build \
+	"[board_info $board rsh_prog] \
+		     -l [board_info $board username] \
+			[board_info $board hostname] \
+	chmod go-rx ."
+}
 
 # The ssh key should be correctly set up that you ssh to 127.0.0.1
 # without having to type password.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7ceb702b0bf..8f3bbd986f5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -176,7 +176,7 @@ verbose "using GDB = $GDB" 2
 # we're testing a non-installed GDB in the build directory.  Users may
 # also explictly override the -data-directory from the command line.
 if ![info exists GDB_DATA_DIRECTORY] {
-    set GDB_DATA_DIRECTORY "[pwd]/../data-directory"
+    set GDB_DATA_DIRECTORY [file normalize "[pwd]/../data-directory"]
 }
 verbose "using GDB_DATA_DIRECTORY = $GDB_DATA_DIRECTORY" 2
 
-- 
2.35.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pushed 2/4] [gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host
  2023-03-17 18:26 [pushed 0/4] [gdb/testsuite] Fix one more remote host issue in gdb.arch tests Tom de Vries
  2023-03-17 18:26 ` [pushed 1/4] [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host Tom de Vries
@ 2023-03-17 18:26 ` Tom de Vries
  2023-03-17 18:26 ` [pushed 3/4] [gdb/testsuite] Handle remote host in gdb_load_shlib Tom de Vries
  2023-03-17 18:26 ` [pushed 4/4] [gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp Tom de Vries
  3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2023-03-17 18:26 UTC (permalink / raw)
  To: gdb-patches

Fix test-case gdb.arch/i386-biarch-core.exp using gdb_download_remote host.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/i386-biarch-core.exp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
index f70b0922212..7babfacf921 100644
--- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp
+++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
@@ -49,6 +49,8 @@ if {$corestat(size) != 102400} {
     return -1
 }
 
+set corefile [gdb_remote_download host $corefile]
+
 # First check if this particular GDB supports i386, otherwise we should not
 # expect the i386 core file to be loaded successfully.
 set archs [get_set_option_choices "set architecture" "i386"]
-- 
2.35.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pushed 3/4] [gdb/testsuite] Handle remote host in gdb_load_shlib
  2023-03-17 18:26 [pushed 0/4] [gdb/testsuite] Fix one more remote host issue in gdb.arch tests Tom de Vries
  2023-03-17 18:26 ` [pushed 1/4] [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host Tom de Vries
  2023-03-17 18:26 ` [pushed 2/4] [gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host Tom de Vries
@ 2023-03-17 18:26 ` Tom de Vries
  2023-03-17 18:26 ` [pushed 4/4] [gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp Tom de Vries
  3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2023-03-17 18:26 UTC (permalink / raw)
  To: gdb-patches

With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver I run into:
...
(gdb) tstart^M
Target returns error code '.In-process agent library not loaded in process.  \
  Fast and static trace points unavailable.'.^M
(gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: start trace experiment
...

Fix this by:
- handling remote host in gdb_load_shlib, and
- moving the gdb_load_shlib to after the clean_restart, such that the
  set solib-search-path can take effect.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp |  2 +-
 gdb/testsuite/lib/gdb.exp                    | 24 ++++++++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
index a00c4dbe2ff..b13438fda0e 100644
--- a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
+++ b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
@@ -34,7 +34,6 @@ if ![gdb_target_supports_trace] {
 }
 
 set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
 
 # Can't use prepare_for_testing, because that splits compiling into
 # building objects and then linking, and we'd fail with "linker input
@@ -46,6 +45,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     return -1
 }
 clean_restart $testfile
+set remote_libipa [gdb_load_shlib $libipa]
 
 if ![runto_main] {
     return 0
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8f3bbd986f5..e48b94b4696 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5967,7 +5967,11 @@ proc gdb_remote_download {dest fromfile {tofile {}}} {
 # Copy shlib FILE to the target.
 
 proc gdb_download_shlib { file } {
-    return [gdb_remote_download target [shlib_target_file $file]]
+    set target_file [shlib_target_file $file]
+    if { [is_remote host] } {
+	remote_download host $target_file
+    }
+    return [gdb_remote_download target $target_file]
 }
 
 # Set solib-search-path to allow gdb to locate shlib FILE.
@@ -5979,16 +5983,26 @@ proc gdb_locate_shlib { file } {
 	perror "gdb_load_shlib: GDB is not running"
     }
 
-    # If the target is remote, we need to tell gdb where to find the
-    # libraries.
-    if { ![is_remote target] } {
+    if { [is_remote target] || [is_remote host] } {
+	# If the target or host is remote, we need to tell gdb where to find
+	# the libraries.
+    } else {
 	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]" "" \
+    if { [is_remote host] } {
+	set solib_search_path [board_info host remotedir]
+	if { $solib_search_path == "" } {
+	    set solib_search_path .
+	}
+    } else {
+	set solib_search_path [file dirname $file]
+    }
+
+    gdb_test_no_output "set solib-search-path $solib_search_path" \
 	"set solib-search-path for [file tail $file]"
 }
 
-- 
2.35.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pushed 4/4] [gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp
  2023-03-17 18:26 [pushed 0/4] [gdb/testsuite] Fix one more remote host issue in gdb.arch tests Tom de Vries
                   ` (2 preceding siblings ...)
  2023-03-17 18:26 ` [pushed 3/4] [gdb/testsuite] Handle remote host in gdb_load_shlib Tom de Vries
@ 2023-03-17 18:26 ` Tom de Vries
  3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2023-03-17 18:26 UTC (permalink / raw)
  To: gdb-patches

With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver I run into:
...
(gdb) info sharedlibrary^M
From To    Syms Read   Shared Object Library^M
$hex $hex  Yes         /lib64/ld-linux-x86-64.so.2^M
$hex $hex  Yes         /home/remote-host/libinproctrace.so^M
$hex $hex  Yes         /lib64/libm.so.6^M
$hex $hex  Yes         /lib64/libc.so.6^M
$hex $hex  Yes         /lib64/libdl.so.2^M
$hex $hex  Yes (*)     /usr/lib64/libstdc++.so.6^M
$hex $hex  Yes (*)     /lib64/libgcc_s.so.1^M
$hex $hex  Yes         /lib64/libpthread.so.0^M
(*): Shared library is missing debugging information.^M
(gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded
...
due to trying to match libinproctrace.so using the target path, while the
command lists it using the host path.

Fix this by making the regexp less strict.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
index b13438fda0e..7bc892263c7 100644
--- a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
+++ b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
@@ -53,7 +53,7 @@ if ![runto_main] {
 
 gdb_reinitialize_dir $srcdir/$subdir
 
-if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
+if { [gdb_test "info sharedlibrary" ".*[file tail $libipa].*" "IPA loaded"] != 0 } {
     untested "could not find IPA lib loaded"
     return 1
 }
-- 
2.35.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-17 18:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 18:26 [pushed 0/4] [gdb/testsuite] Fix one more remote host issue in gdb.arch tests Tom de Vries
2023-03-17 18:26 ` [pushed 1/4] [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host Tom de Vries
2023-03-17 18:26 ` [pushed 2/4] [gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host Tom de Vries
2023-03-17 18:26 ` [pushed 3/4] [gdb/testsuite] Handle remote host in gdb_load_shlib Tom de Vries
2023-03-17 18:26 ` [pushed 4/4] [gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp Tom de Vries

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).