public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/3] [gdb/testsuite] Handle precise-aligned-alloc.c for remote host
@ 2023-03-17 15:07 Tom de Vries
  2023-03-17 15:07 ` [pushed 2/3] [gdb/testsuite] Fix have_avx for remote target Tom de Vries
  2023-03-17 15:07 ` [pushed 3/3] [gdb/testsuite] Set remotedir by default in some boards Tom de Vries
  0 siblings, 2 replies; 3+ messages in thread
From: Tom de Vries @ 2023-03-17 15:07 UTC (permalink / raw)
  To: gdb-patches

With test-case gdb.arch/i386-sse.exp (and likewise gdb.arch/i386-avx.exp) and
host board local-remote-host-notty and target board native-gdbserver I run
into:
...
gdb compile failed, i386-sse.c:68:10: fatal error: \
  ../lib/precise-aligned-alloc.c: No such file or directory
 #include "../lib/precise-aligned-alloc.c"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

Fix this using '#include "precise-aligned-alloc.c"' and making that work with
non-remote and remote host.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/i386-avx.c   |  2 +-
 gdb/testsuite/gdb.arch/i386-avx.exp |  2 ++
 gdb/testsuite/gdb.arch/i386-sse.c   |  2 +-
 gdb/testsuite/gdb.arch/i386-sse.exp |  2 ++
 gdb/testsuite/lib/gdb.exp           | 16 ++++++++++++++++
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/i386-avx.c b/gdb/testsuite/gdb.arch/i386-avx.c
index 28c407db397..b778b3f1666 100644
--- a/gdb/testsuite/gdb.arch/i386-avx.c
+++ b/gdb/testsuite/gdb.arch/i386-avx.c
@@ -50,7 +50,7 @@ v8sf_t data_orig[] =
 #endif
   };
 
-#include "../lib/precise-aligned-alloc.c"
+#include "precise-aligned-alloc.c"
 
 int
 main (int argc, char **argv)
diff --git a/gdb/testsuite/gdb.arch/i386-avx.exp b/gdb/testsuite/gdb.arch/i386-avx.exp
index ad2cb5852d1..55166849cde 100644
--- a/gdb/testsuite/gdb.arch/i386-avx.exp
+++ b/gdb/testsuite/gdb.arch/i386-avx.exp
@@ -30,6 +30,8 @@ set flags { debug }
 # C11 for _Alignas, gnu for asm.
 lappend flags additional_flags=-std=gnu11
 
+lappend_include_file flags $srcdir/lib/precise-aligned-alloc.c
+
 if { [test_compiler_info gcc*] || [test_compiler_info clang*] } {
     lappend flags "additional_flags=-mavx -I${srcdir}/.."
 }
diff --git a/gdb/testsuite/gdb.arch/i386-sse.c b/gdb/testsuite/gdb.arch/i386-sse.c
index a5424f5b52a..8b1b0ec144b 100644
--- a/gdb/testsuite/gdb.arch/i386-sse.c
+++ b/gdb/testsuite/gdb.arch/i386-sse.c
@@ -65,7 +65,7 @@ have_sse (void)
     return 0;
 }
 
-#include "../lib/precise-aligned-alloc.c"
+#include "precise-aligned-alloc.c"
 
 int
 main (int argc, char **argv)
diff --git a/gdb/testsuite/gdb.arch/i386-sse.exp b/gdb/testsuite/gdb.arch/i386-sse.exp
index 6df98ec1219..3c66589ce49 100644
--- a/gdb/testsuite/gdb.arch/i386-sse.exp
+++ b/gdb/testsuite/gdb.arch/i386-sse.exp
@@ -32,6 +32,8 @@ if { [test_compiler_info gcc*] || [test_compiler_info clang*] } {
     lappend flags "additional_flags=-msse -I${srcdir}/.."
 }
 
+lappend_include_file flags $srcdir/lib/precise-aligned-alloc.c
+
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
 	  $flags] != "" } {
     unsupported "compiler does not support SSE"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8b1127ce0bc..0e69bcab288 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9491,5 +9491,21 @@ gdb_caching_proc have_compile_flag { flag } {
 		additional_flags=$flag]
 }
 
+
+# Handle include file FILE, and if necessary update compiler flags variable
+# FLAGS.
+
+proc lappend_include_file { flags file } {
+    upvar $flags up_flags
+    if { [is_remote host] } {
+	gdb_remote_download host $file
+    } else {
+	set dir [file dirname $file]
+	if { $dir != [file join $::srcdir $::subdir] } {
+	    lappend up_flags "additional_flags=-I$dir"
+	}
+    }
+}
+
 # Always load compatibility stuff.
 load_lib future.exp

base-commit: a14e3d11b2656355ca2c3d5b5a9f05e46f71e897
-- 
2.35.3


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

* [pushed 2/3] [gdb/testsuite] Fix have_avx for remote target
  2023-03-17 15:07 [pushed 1/3] [gdb/testsuite] Handle precise-aligned-alloc.c for remote host Tom de Vries
@ 2023-03-17 15:07 ` Tom de Vries
  2023-03-17 15:07 ` [pushed 3/3] [gdb/testsuite] Set remotedir by default in some boards Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-03-17 15:07 UTC (permalink / raw)
  To: gdb-patches

In proc have_avx we compile some source into an exec, resulting in a file $obj
on build, and then attempt to execute it on target:
...
    set result [remote_exec target $obj]
...

Fix this by using gdb_remote_download target.

Likewise in a few other procs that use "remote_exec target".

Tested on x86_64-linux.
---
 gdb/testsuite/lib/gdb.exp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0e69bcab288..7ceb702b0bf 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8987,7 +8987,8 @@ gdb_caching_proc supports_scalar_storage_order_attribute {} {
 	return 0
     }
 
-    set result [remote_exec target $obj]
+    set target_obj [gdb_remote_download target $obj]
+    set result [remote_exec target $target_obj]
     set status [lindex $result 0]
     set output [lindex $result 1]
     if { $output != "" } {
@@ -9047,7 +9048,8 @@ gdb_caching_proc have_mpx {} {
         return 0
     }
 
-    set result [remote_exec target $obj]
+    set target_obj [gdb_remote_download target $obj]
+    set result [remote_exec target $target_obj]
     set status [lindex $result 0]
     set output [lindex $result 1]
     if { $output != "" } {
@@ -9071,7 +9073,8 @@ gdb_caching_proc have_mpx {} {
         return 0
     }
 
-    set result [remote_exec target $obj]
+    set target_obj [gdb_remote_download target $obj]
+    set result [remote_exec target $target_obj]
     set status [lindex $result 0]
     set output [lindex $result 1]
     set status [expr ($status == 0) \
@@ -9114,7 +9117,8 @@ gdb_caching_proc have_avx {} {
         return 0
     }
 
-    set result [remote_exec target $obj]
+    set target_obj [gdb_remote_download target $obj]
+    set result [remote_exec target $target_obj]
     set status [lindex $result 0]
     set output [lindex $result 1]
     if { $output != "" } {
@@ -9311,7 +9315,8 @@ gdb_caching_proc arm_cc_for_target {} {
 		 $src \
 		 executable [list compiler=$compiler]]} {
 
-	    set result [remote_exec target $obj]
+	    set target_obj [gdb_remote_download target $obj]
+	    set result [remote_exec target $target_obj]
 	    set status [lindex $result 0]
 	    set output [lindex $result 1]
 
-- 
2.35.3


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

* [pushed 3/3] [gdb/testsuite] Set remotedir by default in some boards
  2023-03-17 15:07 [pushed 1/3] [gdb/testsuite] Handle precise-aligned-alloc.c for remote host Tom de Vries
  2023-03-17 15:07 ` [pushed 2/3] [gdb/testsuite] Fix have_avx for remote target Tom de Vries
@ 2023-03-17 15:07 ` Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-03-17 15:07 UTC (permalink / raw)
  To: gdb-patches

When doing a gdb_simple_compile, and downloading the resulting exec $obj
to target the result $target_obj may be a relative file path, which may give
problems when trying to do:
...
remote_exec target $target_obj
...

Fix/workaround this on some target boards by setting remotedir by default, and
add a corresponding test in gdb.testsuite/board-sanity.exp.

This doesn't work for host/target board local-remote-host-native, so xfail this.

Tested on x86_64-linux.
---
 .../boards/remote-gdbserver-on-localhost.exp  | 45 ++++++++++++-------
 .../boards/remote-stdio-gdbserver.exp         | 16 +++++++
 gdb/testsuite/gdb.testsuite/board-sanity.exp  | 32 +++++++++++++
 3 files changed, 77 insertions(+), 16 deletions(-)

diff --git a/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp b/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
index a08d2d19801..530e744c9b4 100644
--- a/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
+++ b/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
@@ -37,22 +37,35 @@ if { [info exists REMOTE_TARGET_USERNAME] } {
 }
 set_board_info hostname localhost
 
-# Handle separate test account.
-if { [board_info $board username] != $env(USER) } {
-    # We're pretending that some local user account is remote target.
-    # Make things a bit more realistic by restricting file permissions.
-
-    # Make sure remote target can't see files on build.
-    remote_exec build "chmod go-rx $objdir"
-
-    # Make sure build can't see files on remote target.  We can't use
-    # remote_exec target, because we're in the middle of parsing the
-    # target board.
-    remote_exec build \
-	"[board_info $board rsh_prog] \
-		     -l [board_info $board username] \
-			[board_info $board hostname] \
-	chmod go-rx ."
+save_vars {rsh_cmd res} {
+    set rsh_cmd \
+	[join \
+	     [list \
+		  [board_info $board rsh_prog] \
+		  -l [board_info $board username] \
+		  [board_info $board hostname]]]
+
+    # Handle separate test account.
+    if { [board_info $board username] != $env(USER) } {
+	# We're pretending that some local user account is remote target.
+	# Make things a bit more realistic by restricting file permissions.
+
+	# Make sure remote target can't see files on build.
+	remote_exec build "chmod go-rx $objdir"
+
+	# Make sure build can't see files on remote target.  We can't use
+	# remote_exec target, because we're in the middle of parsing the
+	# target board.
+	remote_exec build $rsh_cmd chmod go-rx ."
+    }
+
+    # Set remotedir by default, to force remote_download target to give an
+    # absolute file name.
+    set res [remote_exec build $rsh_cmd pwd]
+    if { [lindex $res 0] != 0 } {
+	error "Couldn't set remotedir using pwd"
+    }
+    set_board_info remotedir [string trim [lindex $res 1]]
 }
 
 proc ${board}_file { dest op args } {
diff --git a/gdb/testsuite/boards/remote-stdio-gdbserver.exp b/gdb/testsuite/boards/remote-stdio-gdbserver.exp
index 53e40d86477..c4e29e402fe 100644
--- a/gdb/testsuite/boards/remote-stdio-gdbserver.exp
+++ b/gdb/testsuite/boards/remote-stdio-gdbserver.exp
@@ -45,6 +45,22 @@ set_board_info rcp_prog /usr/bin/scp
 # Some remote machines don't have writable home directories.
 if [info exists REMOTE_TMPDIR] {
     set_board_info remotedir $REMOTE_TMPDIR
+} else {
+    # Set remotedir by default, to force remote_download target to give an
+    # absolute file name.
+    save_vars {rsh_cmd res} {
+	set rsh_cmd \
+	    [join \
+		 [list \
+		      [board_info $board rsh_prog] \
+		      -l [board_info $board username] \
+		      [board_info $board hostname]]]
+	set res [remote_exec build $rsh_cmd pwd]
+	if { [lindex $res 0] != 0 } {
+	    error "Couldn't set remotedir using pwd"
+	}
+	set_board_info remotedir [string trim [lindex $res 1]]
+    }
 }
 
 if [info exists GDBSERVER] {
diff --git a/gdb/testsuite/gdb.testsuite/board-sanity.exp b/gdb/testsuite/gdb.testsuite/board-sanity.exp
index b2b3690d1b5..d6402262f60 100644
--- a/gdb/testsuite/gdb.testsuite/board-sanity.exp
+++ b/gdb/testsuite/gdb.testsuite/board-sanity.exp
@@ -120,3 +120,35 @@ foreach_with_prefix remote {host target} {
 	test_remote $remote $host_is_target
     }
 }
+
+proc_with_prefix gdb_simple_compile_and_run {} {
+    set src {
+	int main() {
+	    return 0;
+	}
+    }
+
+    set test "compile"
+    if {![gdb_simple_compile board-sanity $src executable]} {
+	fail $test
+	return
+    }
+    pass $test
+
+    set target_obj [gdb_remote_download target $obj]
+    set result [remote_exec target $target_obj]
+    set status [lindex $result 0]
+    set output [lindex $result 1]
+
+    if { [host_info name] == "local-remote-host-native"
+	 && [target_info name] == "local-remote-host-native" } {
+	# Setting remotedir on this board has effect on both host and
+	# target, and it seems to broken for host.  Xfail this for now.
+	setup_xfail *-*-*
+    }
+    gdb_assert { $status == 0 && $output == "" }
+
+    remote_file build delete $obj
+}
+
+gdb_simple_compile_and_run
-- 
2.35.3


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 15:07 [pushed 1/3] [gdb/testsuite] Handle precise-aligned-alloc.c for remote host Tom de Vries
2023-03-17 15:07 ` [pushed 2/3] [gdb/testsuite] Fix have_avx for remote target Tom de Vries
2023-03-17 15:07 ` [pushed 3/3] [gdb/testsuite] Set remotedir by default in some boards 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).