From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id coMQEKTdEmC1dQAAWB0awg (envelope-from ) for ; Thu, 28 Jan 2021 10:52:04 -0500 Received: by simark.ca (Postfix, from userid 112) id 37C311EF80; Thu, 28 Jan 2021 10:52:04 -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 D90CF1E945 for ; Thu, 28 Jan 2021 10:52:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95B6339AC859; Thu, 28 Jan 2021 15:52:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95B6339AC859 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611849123; bh=YVE2749tbikFXEjc9UU+cOd2vxE1s9mJEFah3lqzOCA=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=wifJNPhb0bTEIM42Zmdvul3LDJ1uIiRP2GACm9Bm3tpqcU/66MdUvRsxwtjivC2O5 T1XjXWW8NsvNq0abpXGJeLJIpztJSmKG0HZwoULvAdVi/Q4Hs9R1wOQZ4kOkCrIQ8u 0PsP5J9+aiskfbJrVmA8YQLoH3GhsOmyMxifrtqs= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id C1B4239960E6 for ; Thu, 28 Jan 2021 15:52:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C1B4239960E6 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10SFpram021509 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jan 2021 10:51:58 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10SFpram021509 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A56E81E945; Thu, 28 Jan 2021 10:51:53 -0500 (EST) Subject: Re: [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read To: Zoran Zaric , gdb-patches@sourceware.org References: <20210120053925.142862-1-simon.marchi@polymtl.ca> <20210120053925.142862-8-simon.marchi@polymtl.ca> <2d20d449-857b-0b1d-aebc-96ff07828342@amd.com> Message-ID: Date: Thu, 28 Jan 2021 10:51:53 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2d20d449-857b-0b1d-aebc-96ff07828342@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 28 Jan 2021 15:51:53 +0000 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" On 2021-01-28 10:41 a.m., Zoran Zaric wrote: >> 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. >> > > Good find. > > Zoran Note that an identical change was already merged: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9f6c202e573b796a9e7328cc5fdab7c0c63776bf So this patch will probably disappear when I rebase. Simon