From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A8B623858410 for ; Fri, 17 Mar 2023 12:30:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8B623858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C952A1FDDE for ; Fri, 17 Mar 2023 12:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679056208; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PKQpuX2lJkaAUEEpAkPNa6LCsezJDCE+YCuRT50nf0A=; b=F5bCVVFitewhwG84R6wxX0SiL0BgP5HcV1ziGf6DMl8lgDEEDA4fjZpXi7lsmcF9LWowFt 8VNC5APKlZRq/5D+Y0yS/kghJsIRB+rk7RABioZBSK9IoHCqkhPfqHWWDC5hXHliWaiTKy T/T/K1tZ1TMIp0Q0f2eV4PUpu0lQAy0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679056208; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PKQpuX2lJkaAUEEpAkPNa6LCsezJDCE+YCuRT50nf0A=; b=nxHN3srIVI86UrXDTJWgNNIGPPYk99aSQO0Gy2ckA9f6C1P8l+W86k1sjToHlRuVSOcrVT 8KO30a6f65onYcAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B58381346F for ; Fri, 17 Mar 2023 12:30:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9uUZK1BdFGSHNgAAMHmgww (envelope-from ) for ; Fri, 17 Mar 2023 12:30:08 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [pushed 1/2] [gdb/testsuite] Add escape_for_host Date: Fri, 17 Mar 2023 13:30:06 +0100 Message-Id: <20230317123007.3889-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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