Message ID | 20230424124846.29580-1-tdevries@suse.de |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 E6D9E385842A for <patchwork@sourceware.org>; Mon, 24 Apr 2023 12:50:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6D9E385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682340600; bh=w4qMIKvcQF4upimzKU8qCQrHjGaR9Hk/zweNY8wzMvk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MTMkc+XjkCXYJxKFVlt0rlhhdDzLO8z/sZGWLUXYiCcmu6/9hkDjh794af3chYB2o jSSdRucElj5gtdZBjO5gcPrAVE2+D+i1qdOG9cS628mgvmviajNe1cEoy+S+kFzIl4 0F2UtdLoyOof/nlKqAQ+SCYw6fSxX5XQdOp0bD0w= 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 3A7E03858C83 for <gdb-patches@sourceware.org>; Mon, 24 Apr 2023 12:48:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A7E03858C83 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 719401FD83 for <gdb-patches@sourceware.org>; Mon, 24 Apr 2023 12:48:45 +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 5C2DA1390E for <gdb-patches@sourceware.org>; Mon, 24 Apr 2023 12:48:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fPMjFa16RmRdBAAAMHmgww (envelope-from <tdevries@suse.de>) for <gdb-patches@sourceware.org>; Mon, 24 Apr 2023 12:48:45 +0000 To: gdb-patches@sourceware.org Subject: [pushed 1/4] [gdb/testsuite] Don't use string cat in gdb.dwarf2/dw2-abs-hi-pc.exp Date: Mon, 24 Apr 2023 14:48:43 +0200 Message-Id: <20230424124846.29580-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, T_SCC_BODY_TEXT_LINE 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tom de Vries <tdevries@suse.de> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
[pushed,1/4,gdb/testsuite] Don't use string cat in gdb.dwarf2/dw2-abs-hi-pc.exp
|
|
Commit Message
Tom de Vries
April 24, 2023, 12:48 p.m. UTC
Test-case gdb.dwarf2/dw2-abs-hi-pc.exp uses string cat: ... set sources [lmap i $sources { string cat "${srcdir}/${subdir}/" $i }] ... but that's only supported starting tcl 8.6. Fix this by using "expr" instead: ... set sources [lmap i $sources { expr { "$srcdir/$subdir/$i" } }] ... Tested on x86_64-linux. --- gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: ea5c591c023544e40bb4967314a47d8e6a1e806d
Comments
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Fix this by using "expr" instead:
Tom> ...
Tom> set sources [lmap i $sources { expr { "$srcdir/$subdir/$i" } }]
expr seems very weird here, since it's normally used for evaluating an
expression.
Maybe subst would be a more idiomatic choice, if it works.
Tom
On 4/24/23 18:48, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes: > > Tom> Fix this by using "expr" instead: > Tom> ... > Tom> set sources [lmap i $sources { expr { "$srcdir/$subdir/$i" } }] > > expr seems very weird here, since it's normally used for evaluating an > expression. I got the idea from here ( https://stackoverflow.com/questions/30489106/using-lmap-to-filter-list-of-strings ). > Maybe subst would be a more idiomatic choice, if it works. It does, indeed: ... -set sources [lmap i $sources { expr { "$srcdir/$subdir/$i" } }] +set sources [lmap i $sources { subst $srcdir/$subdir/$i }] ... My working set of tcl is a bit random, so I don't know what idiomatic is and what not. I agree that subst is neater since it needs less quoting. Thanks, - Tom
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> +set sources [lmap i $sources { subst $srcdir/$subdir/$i }]
Tom> My working set of tcl is a bit random, so I don't know what idiomatic
Tom> is and what not.
No worries, Tcl expertise isn't exactly a headline skill.
Tom> I agree that subst is neater since it needs less quoting.
It probably has to be { subst { $srcdir/$subdir/$i } }
since otherwise there will be a second substitution if, say, the srcdir
has a $ or [] in it.
Tom
On 4/25/23 20:38, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes: > > Tom> +set sources [lmap i $sources { subst $srcdir/$subdir/$i }] > > Tom> My working set of tcl is a bit random, so I don't know what idiomatic > Tom> is and what not. > > No worries, Tcl expertise isn't exactly a headline skill. > > Tom> I agree that subst is neater since it needs less quoting. > > It probably has to be { subst { $srcdir/$subdir/$i } } > since otherwise there will be a second substitution if, say, the srcdir > has a $ or [] in it. OK, let's try an example. We currently have this style: ... set b d set l { a $b } set res [lmap v $l { expr {"$v/c"} }] foreach v $res { puts "V: $v" } ... which does: ... V: a/c V: $b/c ... Then with subst we have the same: ... set res [lmap v $l { subst {$v/c} }] ... unless we forget the quoting: ... set res [lmap v $l { subst $v/c }] ... which gets us instead: ... V: a/c V: d/c ... Hmm, in that case I think subst is the worse choice. With expr, things either parse or not, and if it parses you get the right result. FWIW, reading a bit more about it I get the impression also set is idiomatic, so I came up with this: ... set res [lmap v $l { set v $v/c ; set v }] ... which works as well. Thanks, - Tom
On Apr 26 2023, Tom de Vries via Gdb-patches wrote: > FWIW, reading a bit more about it I get the impression also set is > idiomatic, so I came up with this: > ... > set res [lmap v $l { set v $v/c ; set v }] > ... > which works as well. You won't need the second set, though, since the first set already returns the assigned value.
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Then with subst we have the same:
Tom> ...
Tom> set res [lmap v $l { subst {$v/c} }]
Tom> ...
Tom> unless we forget the quoting:
This is true for everything in Tcl though.
The quoting matters a lot.
Tom> Hmm, in that case I think subst is the worse choice. With expr,
Tom> things either parse or not, and if it parses you get the right result.
expr has corner cases where weird things will happen as well.
It's really just intended for use with the expression sub-language.
Tom
On 4/26/23 09:08, Andreas Schwab wrote: > On Apr 26 2023, Tom de Vries via Gdb-patches wrote: > >> FWIW, reading a bit more about it I get the impression also set is >> idiomatic, so I came up with this: >> ... >> set res [lmap v $l { set v $v/c ; set v }] >> ... >> which works as well. > > You won't need the second set, though, since the first set already > returns the assigned value. > Andreas, thanks for the review. Committed as attached. Thanks, - Tom
On 4/27/23 15:39, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes: > > Tom> Then with subst we have the same: > Tom> ... > Tom> set res [lmap v $l { subst {$v/c} }] > Tom> ... > Tom> unless we forget the quoting: > > This is true for everything in Tcl though. > The quoting matters a lot. > True. > Tom> Hmm, in that case I think subst is the worse choice. With expr, > Tom> things either parse or not, and if it parses you get the right result. > > expr has corner cases where weird things will happen as well. > It's really just intended for use with the expression sub-language. Ack. I've just pushed a patch that uses set instead of expr, so this is no longer an issue. Thanks for reporting this. - Tom
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp b/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp index 0868b69f15e..2ea6a5cea00 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-abs-hi-pc.exp @@ -24,7 +24,8 @@ set sources \ ${testfile}.c \ ${testfile}-hello.c \ ${testfile}-world.c] -set sources [lmap i $sources { string cat "${srcdir}/${subdir}/" $i }] +set sources [lmap i $sources { expr { "$srcdir/$subdir/$i" } }] + lassign [function_range hello $sources] \ hello_start hello_len lassign [function_range world $sources] \