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: [pushed 1/3] [gdb/testsuite] Handle precise-aligned-alloc.c for remote host
Date: Fri, 17 Mar 2023 16:07:34 +0100	[thread overview]
Message-ID: <20230317150736.11883-1-tdevries@suse.de> (raw)

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


             reply	other threads:[~2023-03-17 15:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 15:07 Tom de Vries [this message]
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

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