From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id DKuCO4SwJ2EmMAAAWB0awg (envelope-from ) for ; Thu, 26 Aug 2021 11:17:24 -0400 Received: by simark.ca (Postfix, from userid 112) id DD2AC1EE1B; Thu, 26 Aug 2021 11:17:24 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E12441EDEE for ; Thu, 26 Aug 2021 11:17:23 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 716603858415 for ; Thu, 26 Aug 2021 15:17:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 716603858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629991043; bh=38PKcpmFdm6OLacFwBTc4d3Ix+ASZtbod8kq9Thaj8A=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=CRX3X10Wtd2OFhsX8zyvd5LzhGjjzuEoWYaE8d5dVhYVsw0mYP+HqIx06ehVw3nhn w6hulrwko0k7NEe1RhmwuGkFzt25e9EvY353Afz6QRv1onuWTeQ03yrTv8ZtkEy49T v0BiEAyxwiBjVkZkkLFvbL6AhjcCMlkm3uOFcxFQ= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 8505F3858D3C for ; Thu, 26 Aug 2021 15:16:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8505F3858D3C Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 B7108201B4; Thu, 26 Aug 2021 15:16:54 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id A086213689; Thu, 26 Aug 2021 15:16:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id hdf+JWawJ2EIawAAGKfGzw (envelope-from ); Thu, 26 Aug 2021 15:16:54 +0000 Subject: Re: [PATCH][gdb/testsuite] Add label option to proc cu To: Simon Marchi , gdb-patches@sourceware.org References: <20210826115605.GA22680@delia> <62258296-6132-ff23-cd4c-2f2820249a60@polymtl.ca> Message-ID: <4b72733b-4725-9d44-a5e5-0325d51064b6@suse.de> Date: Thu, 26 Aug 2021 17:16:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <62258296-6132-ff23-cd4c-2f2820249a60@polymtl.ca> Content-Type: multipart/mixed; boundary="------------1442DA4D016148ACF7782798" Content-Language: en-US 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This is a multi-part message in MIME format. --------------1442DA4D016148ACF7782798 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 8/26/21 3:38 PM, Simon Marchi wrote: > On 2021-08-26 7:56 a.m., Tom de Vries via Gdb-patches wrote: >> Hi, >> >> We can use current dwarf assembly infrastructure to declare a label that marks >> the start of the CU header: >> ... >> declare_labels header_start_cu_a >> _section ".debug_info" >> header_start_cu_a : cu {} { >> } >> _section ".debug_info" >> header_start_cu_b : cu {} { >> } >> ... >> on the condition that we switch to the .debug_info section before, which makes >> this style of use fragile. >> >> Another way to achieve the same is to use the label as generated by the cu >> proc itself: >> ... >> variable _cu_label >> cu {} { >> } >> set header_start_cu_a $_cu_label >> cu {} { >> } >> set header_start_cu_b $_cu_label >> ... >> but again that seems fragile given that adding a new CU inbetween will >> silently result in the wrong value for the label. > > And this is done by poking in the internals of the framework, not good. > >> Add a label option to proc cu such that we can simply do: >> ... >> declare_labels header_start_cu_a >> cu { label header_start_cu_a } { >> } >> cu { label header_start_cu_b } { >> } > > That looks like the right way to do it. But can we make it so the > caller doesn't need to use declare_labels? For example, with rnglists' > -post-header-label switch, it's not needed, so I presume it would be > possible here. Done. I looked at -post-header-label, but that puts the burden on the caller to come up with a unique name. That doesn't work well with proc dummy_cu being defined like this: ... proc dummy_cu {} { # Generate a CU with default options and empty body. cu {label dummy_cu} { } # Generate an .debug_aranges entry for the dummy CU. aranges {} dummy_cu { } } ... and then being called twice. Instead, I opted to reuse _cu_label, but rather than poking it's now exported by the proc. WDYT? Thanks, - Tom --------------1442DA4D016148ACF7782798 Content-Type: text/x-patch; charset=UTF-8; name="0006-gdb-testsuite-Add-label-option-to-proc-cu.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0006-gdb-testsuite-Add-label-option-to-proc-cu.patch" [gdb/testsuite] Add label option to proc cu We can use current dwarf assembly infrastructure to declare a label that marks the start of the CU header: ... declare_labels header_start_cu_a _section ".debug_info" header_start_cu_a : cu {} { } _section ".debug_info" header_start_cu_b : cu {} { } ... on the condition that we switch to the .debug_info section before, which makes this style of use fragile. Another way to achieve the same is to use the label as generated by the cu proc itself: ... variable _cu_label cu {} { } set header_start_cu_a $_cu_label cu {} { } set header_start_cu_b $_cu_label ... but again that seems fragile given that adding a new CU inbetween will silently result in the wrong value for the label. Add a label option to proc cu such that we can simply do: ... cu { label header_start_cu_a } { } cu { label header_start_cu_b } { } ... Tested on x86_64-linux. --- gdb/testsuite/lib/dwarf.exp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index ce7b5983ab9..4f66b91ccbe 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -1258,6 +1258,10 @@ namespace eval Dwarf { # default = default # fission 0|1 - boolean indicating if generating Fission debug info # default = 0 + # label