From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1DQiOJVGaGEuMwAAWB0awg (envelope-from ) for ; Thu, 14 Oct 2021 11:02:45 -0400 Received: by simark.ca (Postfix, from userid 112) id D41CD1F0BB; Thu, 14 Oct 2021 11:02:45 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,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 228791E79C for ; Thu, 14 Oct 2021 11:02:45 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D6DA3858025 for ; Thu, 14 Oct 2021 15:02:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D6DA3858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1634223764; bh=0IgPAKp1sThYNVHzfMz7XhRpKfmQJYLtQqRt7kPFYZw=; 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=kPfOZVp7/8T71QddQRBMLd8tHquDLGtDd977Nvxi+yCagJuE1w092V1cf9DqPvJ7q Du1c1qBLbh4tNMAkOSbRlH5efPdmRCeRLVjO4eJHUjTTR+43dmSfWqaBgs0aKlK/z/ R6aTHmV0HuL9I1UCBll9VYkA3gZs5sPweP4zTx2E= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 32AF13858C2C for ; Thu, 14 Oct 2021 15:02:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 32AF13858C2C 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-out1.suse.de (Postfix) with ESMTPS id 417B121A88; Thu, 14 Oct 2021 15:02:24 +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 2503A13D9F; Thu, 14 Oct 2021 15:02:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hzsVB4BGaGGyDAAAMHmgww (envelope-from ); Thu, 14 Oct 2021 15:02:24 +0000 Subject: Re: [PATCH][gdb/testsuite] Add .debug_loc support in dwarf assembler To: Simon Marchi , gdb-patches@sourceware.org References: <20211014123315.GA22867@delia.home> <0316a868-cb5e-37e3-0040-d64d1acaf521@polymtl.ca> Message-ID: Date: Thu, 14 Oct 2021 17:02:23 +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: <0316a868-cb5e-37e3-0040-d64d1acaf521@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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" On 10/14/21 3:32 PM, Simon Marchi wrote: >> diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp >> index 66f9844fe2e..a15eacfb46c 100644 >> --- a/gdb/testsuite/lib/dwarf.exp >> +++ b/gdb/testsuite/lib/dwarf.exp >> @@ -2369,6 +2369,102 @@ namespace eval Dwarf { >> aranges_end: >> } >> >> + # Emit a .debug_loc entry. >> + >> + proc loc_entry { start end location_description } { >> + # Determine how to emit addresses. >> + variable _addr_size >> + if { $_addr_size == 8 } { >> + set addr_op .8byte >> + } elseif { $_addr_size == 4 } { >> + set addr_op .4byte >> + } >> + >> + # Emit start and end address. >> + _op $addr_op $start "Start address" >> + _op $addr_op $end "End address" >> + >> + declare_labels location_description_start >> + declare_labels location_description_end >> + >> + # Emit length of location description. >> + set len "$location_description_end - $location_description_start" >> + _op .2byte $len "Location description length" >> + >> + # Tag start of location description. >> + define_label $location_description_start >> + >> + # Emit location description. >> + variable _cu_version >> + variable _cu_offset_size >> + _location $location_description $_cu_version $_addr_size \ >> + $_cu_offset_size >> + >> + # Tag end of location description. >> + define_label $location_description_end >> + } >> + >> + # Emit a DWARF .debug_loc contribution. >> + # >> + # OPTIONS is a list with an even number of elements containing >> + # option-name and option-value pairs. >> + # Current options are: >> + # cu_is_64 0|1 - boolean indicating if references from location >> + # descriptions refer to a 64-bit DWARF CU. >> + # default = 0 (32-bit) >> + # cu_version n - section version of DWARF CU referenced from location >> + # descriptions. >> + # default = 4 >> + # >> + # BODY is Tcl code that emits the parts which make up the body of >> + # the debug_loc contribution. It is evaluated in the caller's context. >> + # The following command is available for the BODY section: >> + # >> + # loc_entry >> + # -- emit a .debug_loc entry >> + >> + proc loc { options body } { > > I would suggest using the same trick as used for rnglists: rename > loc_entry to _loc_entry (or something like that, to show it's > internal). And use: > > with_override Dwarf::entry Dwarf::_loc_entry { > uplevel $body > } > > Users would then look like: > > loc { ... } { > entry 0x123 0x456 { > ... > } > } > > I think that looks good: because you are in the "loc" context, it is > obvious enough that entry is a location list entry. I think that makes > it easy to write. > Ack, updated that way, thanks for the tip. > I would have suggested renaming "loc" to "loclist", because this is > actually generating a "location list", according to the standard. But > that might become confusing with the DWARF5 "loclists"... > Ack. FWIW, I chose the name based on the .debug_loc section, similar to how .debug_aranges are generated use a proc aranges. > But other than that, the patch LGTM. > Committed. Thanks, - Tom