From patchwork Mon Mar 27 11:58:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 66947 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89C9538708BD for ; Mon, 27 Mar 2023 12:00:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89C9538708BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679918402; bh=Uuk4M1fT0gjikWg+ktDj+99B5WklFrY0EUKABGLO20I=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rT1BfkhuiGyGAQtHY8Cdn2bAmN1hO5ph4oIV0ceX+Ln2GrpIplRuoZDtAWz0nuBBF a9v5iMGwRwy9qSOUxRzPjS7LO8z0UFcnuBA4uVPIp8pRPla6ShtIy2qC9WA7p5qMMG 42cailHN/7BbZxQWmC/zJFvmlUYy/xXh0Fl5FZ5Y= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 814EE3858C3A for ; Mon, 27 Mar 2023 11:59:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 814EE3858C3A 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 B971B1FDC0 for ; Mon, 27 Mar 2023 11:58:59 +0000 (UTC) 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 A62C013482 for ; Mon, 27 Mar 2023 11:58:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4ADuJgOFIWTCOgAAMHmgww (envelope-from ) for ; Mon, 27 Mar 2023 11:58:59 +0000 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 Message-Id: <20230327115858.5950-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230327115858.5950-1-tdevries@suse.de> References: <20230327115858.5950-1-tdevries@suse.de> MIME-Version: 1.0 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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.