diff options
author | Tom de Vries <tdevries@suse.de> | 2023-03-17 13:29:13 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-03-17 13:29:13 +0100 |
commit | ff000c4dbb2b99531c8cda1e0e67e787ce8aef20 (patch) | |
tree | bd353f92dd1c39361763cbdd3d0a24cc803bb2af | |
parent | 92376883a9a18e478228ae14ac8f3b03398fdefa (diff) | |
download | binutils-ff000c4dbb2b99531c8cda1e0e67e787ce8aef20.zip binutils-ff000c4dbb2b99531c8cda1e0e67e787ce8aef20.tar.gz binutils-ff000c4dbb2b99531c8cda1e0e67e787ce8aef20.tar.bz2 |
[gdb/testsuite] Add escape_for_host
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.
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 5f32181..b45c73f 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 |