From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qEuSCxnCB2CaTgAAWB0awg (envelope-from ) for ; Wed, 20 Jan 2021 00:39:37 -0500 Received: by simark.ca (Postfix, from userid 112) id 1D1CF1EF7C; Wed, 20 Jan 2021 00:39:37 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 338691EF82 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 85937394800C; Wed, 20 Jan 2021 05:39:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85937394800C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611121173; bh=mQNPQ0y76gS05PY39VbVz21Ge2bpT/xpfDQYMokFNlU=; 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=m8GjYFrw/VgHSDWNffhJwf1WzOcFWUXB5mynM/5fpgzQe38rEWRGhP5iYRz3KBdou RgLHppl4lolb/lA9DrF2+AkpS+Qwuagsn9a+9tuyyDhNDMAembUt/fgNluhUqPmuJF Rkz5tcuF+lcnXo3IoHS9e+BBgwq0ugCV121dhLac= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 27BB8386F419 for ; Wed, 20 Jan 2021 05:39:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 27BB8386F419 X-ASG-Debug-ID: 1611121166-0c856e6cd571f1f0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id pgHK3JvsIz1LYyBG (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 5156C441B21; 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 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng, loc}listx Date: Wed, 20 Jan 2021 00:39:17 -0500 X-ASG-Orig-Subj: [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng, loc}listx Message-Id: <20210120053925.142862-6-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: 4648 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 We hit an assertion when loading the binary from PR 26813. When fixing it, execution goes a up bit further but then hits another assert, and another, and another. With these fours fixes, I am able to load the binary and get to the prompt. An error is shown (index pointing outside of the section), because the DW_FORM_rnglistx attribute is not read correctly, but that one is taken care of by the next patch. The four fixes are: - attribute::form_requires_reprocessing needs to handle forms DW_FORM_rnglistx and DW_FORM_loclistx, because set_unsigned_reprocess is called for them in read_attribute_value. - read_attribute_reprocess must call set_unsigned for them, not set_address. The parameter of set_address is a CORE_ADDR, meaning it's for program addresses. Post-reprocess, DW_FORM_rnglistx and DW_FORM_loclistx are offsets into their respective sections (.debug_rnglists and .debug_loclists). set_unsigned is the current attribute value setter that fits the best. But perhaps we should have a setter that takes a sect_offset? - read_attribute_process must call as_unsigned_reprocess instead of as_unsigned to get the pre-reprocess value, otherwise we hit the assert inside as_unsigned that makes sure the attribute doesn't need reprocessing. - attribute::set_unsigned needs to clear the requires_reprocessing flag, otherwise it stays set when reprocessing DW_FORM_rnglistx and DW_FORM_loclistx attributes. There's another assert that we hit once the next patch is applied, but since it's in the same vein as the changes in this patch, I included it in this patch: - attribute::form_is_unsigned must handle form DW_FORM_loclistx, otherwise we hit the assert when trying to call set_unsigned for an attribute of this form. DW_FORM_rnglistx is already handled. gdb/ChangeLog: PR gdb/26813 * dwarf2/attribute.h (struct attribute) : Clear requires_reprocessing flag. * dwarf2/attribute.c (attribute::form_is_unsigned): Handle DW_FORM_loclistx. (attribute::form_requires_reprocessing): Handle DW_FORM_rnglistx and DW_FORM_loclistx. * dwarf2/read.c (read_attribute_reprocess): Use set_unsigned instead of set_address for DW_FORM_loclistx and DW_FORM_rnglistx. Change-Id: I06c156fa3913ca98e4e39085f4ef171645b4bc1e --- gdb/dwarf2/attribute.c | 5 ++++- gdb/dwarf2/attribute.h | 1 + gdb/dwarf2/read.c | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 479261030c5d..b4f188a096e1 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -179,6 +179,7 @@ attribute::form_is_unsigned () const || form == DW_FORM_flag_present || form == DW_FORM_udata || form == DW_FORM_rnglistx + || form == DW_FORM_loclistx || form == DW_FORM_ref1 || form == DW_FORM_ref2 || form == DW_FORM_ref4 @@ -197,7 +198,9 @@ attribute::form_requires_reprocessing () const || form == DW_FORM_strx4 || form == DW_FORM_GNU_str_index || form == DW_FORM_addrx - || form == DW_FORM_GNU_addr_index); + || form == DW_FORM_GNU_addr_index + || form == DW_FORM_rnglistx + || form == DW_FORM_loclistx); } /* See attribute.h. */ diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index a3ff9b0eb9c6..56776d64ed34 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -223,6 +223,7 @@ struct attribute { gdb_assert (form_is_unsigned ()); u.unsnd = unsnd; + requires_reprocessing = 0; } /* Temporarily set this attribute to an unsigned integer. This is diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 76044187bf76..4146694247ea 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20287,10 +20287,20 @@ read_attribute_reprocess (const struct die_reader_specs *reader, attr->as_unsigned_reprocess ())); break; case DW_FORM_loclistx: - attr->set_address (read_loclist_index (cu, attr->as_unsigned ())); - break; + { + CORE_ADDR loclists_sect_off + = read_loclist_index (cu, attr->as_unsigned_reprocess ()); + + attr->set_unsigned (loclists_sect_off); + } + break; case DW_FORM_rnglistx: - attr->set_address (read_rnglist_index (cu, attr->as_unsigned (), tag)); + { + CORE_ADDR rnglists_sect_off + = read_rnglist_index (cu, attr->as_unsigned_reprocess (), tag); + + attr->set_unsigned (rnglists_sect_off); + } break; case DW_FORM_strx: case DW_FORM_strx1: -- 2.30.0