From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UL2OJxjCB2C4TgAAWB0awg (envelope-from ) for ; Wed, 20 Jan 2021 00:39:36 -0500 Received: by simark.ca (Postfix, from userid 112) id 8E9641EF8C; Wed, 20 Jan 2021 00:39:35 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 BD8641EF86 for ; Wed, 20 Jan 2021 00:39:34 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 073043948446; Wed, 20 Jan 2021 05:39:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 073043948446 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611121174; bh=AOjuRwtkPXVJ6QYAeIT3LKcGQhYGkGBFP55I+bHcm3I=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FBauEDPdgn4N3Is9azDXr/XRJQB5x+LTMS91ebmm1Wm/D5eYkMzVOkF9OVtThSNgG sVLik54lXfiQ36/6CbWcnsj2JRib9GPVycrmiH6n9GLcjbMgbyhAISdhE15MrPqTFI AgOA3g0hZwdorq3ntBRt/6zMOXTDg3M7ncxDgXG8= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 2DD023947429 for ; Wed, 20 Jan 2021 05:39:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DD023947429 X-ASG-Debug-ID: 1611121166-0c856e6cd571f200001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 5WCMdKo8xRUsMtxs (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Jan 2021 00:39:26 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 75EDA441D65; Wed, 20 Jan 2021 00:39:26 -0500 (EST) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read Date: Wed, 20 Jan 2021 00:39:19 -0500 X-ASG-Orig-Subj: [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read Message-Id: <20210120053925.142862-8-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210120053925.142862-1-simon.marchi@polymtl.ca> References: <20210120053925.142862-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1611121166 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2773 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.87375 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Simon Marchi While writing a test for this series, I made a function (DW_AT_subprogram) with a DW_AT_ranges attribute using the DW_FORM_rnglistx form: 0x00000012: DW_TAG_subprogram DW_AT_name [DW_FORM_string] ("foo") DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000036 [0x0000000000004000, 0x0000000000005000)) And strangely I couldn't print it: (gdb) p foo No symbol "foo" in current context. This is because of the `attr.constant_value (0)` in the DW_AT_ranges handling of partial_die_info::read. Since DW_FORM_rnglistx is not recognized as a constant value by attribute::constant_value, the default value (0) is returned. Down the line, this causes dwarf2_rnglists_process to try read a range list at offset 0 in the .debug_rnglists section, which is obviously wrong. In the end, no symbol is created for foo because we didn't find an address range. Use attr->as_unsigned instead. This is what is done for the equivalent code in dwarf2_get_pc_bounds. With this, GDB processes the subprogram DIE and we are able to print the function symbol: (gdb) p foo $1 = {void (void)} 0x4000 Note that I didn't see an actual compiler use DW_FORM_rnglistx for a subprogram's range. However, in the binary attached to PR 26813, there are some lexical blocks with it: 0x0000d34a: DW_TAG_lexical_block DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x2) rangelist = 0x000000d4 [0x0000000000005db1, 0x0000000000005e36) [0x0000000000005e48, 0x0000000000005f3c) [0x0000000000006045, 0x0000000000006053)) Their ranges are read incorrectly just like the ranges of the subprograms. With this patch applied, they are read correctly. gdb/ChangeLog: * dwarf2/read.c (partial_die_info::read): Use attribute::as_unsigned instead of attribute::constant_value for DW_AT_ranges. Change-Id: I285381a15588574058d934bbc88f06029e8a3bd1 --- gdb/dwarf2/read.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9701d422a338..5277e2a09e3f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19805,7 +19805,7 @@ partial_die_info::read (const struct die_reader_specs *reader, /* It would be nice to reuse dwarf2_get_pc_bounds here, but that requires a full DIE, so instead we just reimplement it. */ - unsigned int ranges_offset = (attr.constant_value (0) + unsigned int ranges_offset = (attr.as_unsigned () + (need_ranges_base ? cu->ranges_base : 0)); -- 2.30.0