* [pushed 1/2] [gdb/testsuite] Add escape_for_host
@ 2023-03-17 12:30 Tom de Vries
2023-03-17 12:30 ` [pushed 2/2] [gdb/testsuite] Handle remote host in escape_for_host Tom de Vries
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-03-17 12:30 UTC (permalink / raw)
To: gdb-patches
In gdb_compile we have:
...
lappend new_options "ldflags=-Wl,-rpath,\\\$ORIGIN"
...
and we could improve readability by using {} rather than "":
...
lappend new_options {ldflags=-Wl,-rpath,\$ORIGIN}
...
But rather than manually adding escapes in a string, add a new proc
escape_for_host that care of this for us, allowing us to write:
...
lappend new_options [escape_for_host {ldflags=-Wl,-rpath,$ORIGIN}]
...
Tested on x86_64-linux.
---
gdb/testsuite/lib/gdb.exp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 5f32181f60e..b45c73fcc1a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4653,6 +4653,16 @@ proc gdb_can_simple_compile {name code {type object} {compile_flags ""}} {
global gdb_saved_set_unbuffered_mode_obj
set gdb_saved_set_unbuffered_mode_obj ""
+# Escape STR sufficiently for use on host commandline.
+
+proc escape_for_host { str } {
+ set map {
+ {$} {\$}
+ }
+
+ return [string map $map $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.
@@ -4926,7 +4936,7 @@ proc gdb_compile {source dest type options} {
if { $shlib_load } {
lappend new_options "libs=-ldl"
}
- lappend new_options "ldflags=-Wl,-rpath,\\\$ORIGIN"
+ lappend new_options [escape_for_host {ldflags=-Wl,-rpath,$ORIGIN}]
}
}
set options $new_options
base-commit: 92376883a9a18e478228ae14ac8f3b03398fdefa
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pushed 2/2] [gdb/testsuite] Handle remote host in escape_for_host
2023-03-17 12:30 [pushed 1/2] [gdb/testsuite] Add escape_for_host Tom de Vries
@ 2023-03-17 12:30 ` Tom de Vries
0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2023-03-17 12:30 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:
...
FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded
...
due to having:
...
$ readelf -d ftrace-insn-reloc | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: []
...
instead of:
...
$ readelf -d ftrace-insn-reloc | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN]
...
Handle this in escape_for_host.
Tested on x86_64-linux.
---
gdb/testsuite/lib/gdb.exp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b45c73fcc1a..8b1127ce0bc 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4656,8 +4656,14 @@ set gdb_saved_set_unbuffered_mode_obj ""
# Escape STR sufficiently for use on host commandline.
proc escape_for_host { str } {
- set map {
- {$} {\$}
+ if { [is_remote host] } {
+ set map {
+ {$} {\\$}
+ }
+ } else {
+ set map {
+ {$} {\$}
+ }
}
return [string map $map $str]
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-17 12:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 12:30 [pushed 1/2] [gdb/testsuite] Add escape_for_host Tom de Vries
2023-03-17 12:30 ` [pushed 2/2] [gdb/testsuite] Handle remote host in escape_for_host 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).