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 03/10] [gdb/testsuite] Fix quoting issues in gdb.dwarf2 for remote host
Date: Mon, 27 Mar 2023 13:58:51 +0200	[thread overview]
Message-ID: <20230327115858.5950-4-tdevries@suse.de> (raw)
In-Reply-To: <20230327115858.5950-1-tdevries@suse.de>

A few test-cases in gdb.dwarf2 use something like:
...
  additional_flags=\"-DFOO=BAR + 10\"
...
which doesn't work on remote host.

Fix this by introducing a new proc quote_for_host that also works for remote
host, such that we have:
...
  additional_flags=[quote_for_host -DFOO=BAR + 10]
...

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp     | 17 ++++++++++-------
 .../gdb.dwarf2/dw2-ref-missing-frame.exp       | 18 ++++++++++++------
 gdb/testsuite/lib/gdb.exp                      | 13 +++++++++++++
 3 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp b/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp
index 2ec3d11d8ac..0868b69f15e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp
@@ -37,13 +37,16 @@ set sources \
 	 ${testfile}-hello.c \
 	 ${testfile}-world-dbg.S \
 	 ${testfile}-world.c]
-set flags \
-    [list \
-	 "nodebug" \
-	 "additional_flags=\"-DHELLO_START=$hello_start\"" \
-	 "additional_flags=\"-DHELLO_END=$hello_start + $hello_len\"" \
-	 "additional_flags=\"-DWORLD_START=$world_start\"" \
-	 "additional_flags=\"-DWORLD_END=$world_start + $world_len\""]
+
+set flags {}
+lappend flags nodebug
+lappend flags additional_flags=[quote_for_host -DHELLO_START=$hello_start]
+lappend flags additional_flags=[quote_for_host -DHELLO_END=$hello_start \
+				    + $hello_len]
+lappend flags additional_flags=[quote_for_host -DWORLD_START=$world_start]
+lappend flags additional_flags=[quote_for_host -DWORLD_END=$world_start \
+				    + $world_len]
+
 set executable ${testfile}
 if {[build_executable ${testfile}.exp ${executable} $sources $flags] == -1} {
     return -1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ref-missing-frame.exp b/gdb/testsuite/gdb.dwarf2/dw2-ref-missing-frame.exp
index d9a552a8c9d..09c484a8ebb 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ref-missing-frame.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ref-missing-frame.exp
@@ -25,12 +25,18 @@ lassign [function_range func_loopfb \
              "${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3}"] \
     func_loopfb_start func_loopfb_len
 
-set flags \
-    [list \
-         "additional_flags=\"-DFUNC_NOFB_START=$func_nofb_start\"" \
-         "additional_flags=\"-DFUNC_NOFB_END=$func_nofb_start + $func_nofb_len\"" \
-         "additional_flags=\"-DFUNC_LOOPFB_START=$func_loopfb_start\"" \
-         "additional_flags=\"-DFUNC_LOOPFB_END=$func_loopfb_start + $func_loopfb_len\""]
+set flags {}
+lappend flags \
+    additional_flags=[quote_for_host -DFUNC_NOFB_START=$func_nofb_start]
+lappend flags \
+    additional_flags=[quote_for_host -DFUNC_NOFB_END=$func_nofb_start \
+			  + $func_nofb_len]
+lappend flags \
+    additional_flags=[quote_for_host -DFUNC_LOOPFB_START=$func_loopfb_start]
+lappend flags \
+    additional_flags=[quote_for_host -DFUNC_LOOPFB_END=$func_loopfb_start \
+			  + $func_loopfb_len]
+
 set executable ${testfile}
 
 if { [prepare_for_testing_full "failed to prepare" \
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c0762cbb3a8..2cf128fdd68 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4700,6 +4700,19 @@ proc escape_for_host { str } {
     return [string map $map $str]
 }
 
+# Add double quotes around ARGS, sufficiently escaped for use on host
+# commandline.
+
+proc quote_for_host { args } {
+    set str [join $args]
+    if { [is_remote host] } {
+	set str [join [list {\"} $str {\"}] ""]
+    } else {
+	set str [join [list {"} $str {"}] ""]
+    }
+    return $str
+}
+
 # Compile source files specified by SOURCE into a binary of type TYPE at path
 # DEST.  gdb_compile is implemented using DejaGnu's target_compile, so the type
 # parameter and most options are passed directly to it.
-- 
2.35.3


  parent reply	other threads:[~2023-03-27 11:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27 11:58 [pushed 00/10] [gdb/testsuite] Fix " Tom de Vries
2023-03-27 11:58 ` [pushed 01/10] [gdb/testsuite] Add missing include_file in gdb.dwarf/*.exp Tom de Vries
2023-03-27 11:58 ` [pushed 02/10] [gdb/testsuite] Fix have_index for remote host Tom de Vries
2023-03-27 11:58 ` Tom de Vries [this message]
2023-03-27 11:58 ` [pushed 04/10] [gdb/testsuite] Fix quoting issue in gdb.base/index-cache.exp Tom de Vries
2023-03-27 11:58 ` [pushed 05/10] [gdb/testsuite] Fix gdb.dwarf2/per-bfd-sharing.exp for remote host Tom de Vries
2023-03-27 11:58 ` [pushed 06/10] [gdb/testsuite] Fix gdb.dwarf2/gdb-index.exp on " Tom de Vries
2023-03-27 11:58 ` [pushed 07/10] [gdb/testsuite] Fix gdb.dwarf2/enqueued-cu-base-addr.exp for " Tom de Vries
2023-03-27 11:58 ` [pushed 08/10] [gdb/testsuite] Fix gdb.dwarf2/gdb-index-cxx.exp " Tom de Vries
2023-03-27 11:58 ` [pushed 09/10] [gdb/testsuite] Unsupport gdb.dwarf2/gdb-add-index-symlink.exp " Tom de Vries
2023-03-27 11:58 ` [pushed 10/10] [gdb/testsuite] Fix gdb.dwarf2/imported-unit-bp-c.exp " 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=20230327115858.5950-4-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).