From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uJUAEY3CB2CaTgAAWB0awg (envelope-from ) for ; Wed, 20 Jan 2021 00:41:33 -0500 Received: by simark.ca (Postfix, from userid 112) id 331111EF82; Wed, 20 Jan 2021 00:41:33 -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 567FC1E939 for ; Wed, 20 Jan 2021 00:41:32 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0861A3948491; Wed, 20 Jan 2021 05:41:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0861A3948491 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611121292; bh=dYlpd4gDaKdXFkU0SR5r683+Aeexp6/PI4ZtwU0V3JI=; 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=rro9aMcMa8BGA0EOof3SpOkZa+fTFXrwh0gBsrdo4U27PMfBgB4QpGm1sm7fAUd3E I1zOA9ExkF48wFlmaIJk07I/BL5X8Qbc244ZTuBTijrd6dOBs7GbtgmpZwjxF/EDy0 F+4t+UmSd8ehL+qSotTprQTnKPpn6s05snSIZKbc= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 2AF5D3947C02 for ; Wed, 20 Jan 2021 05:41:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2AF5D3947C02 X-ASG-Debug-ID: 1611121287-0c856e6cd571f230001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id fwluP2MpobPBfpjM (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Jan 2021 00:41:27 -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 E73A6441B21; Wed, 20 Jan 2021 00:41: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 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset Date: Wed, 20 Jan 2021 00:39:24 -0500 X-ASG-Orig-Subj: [PATCH 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset Message-Id: <20210120053925.142862-13-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: 1611121287 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: 3337 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 I think it's wrong that read_loclist_index and read_rnglist_index return a CORE_ADDR. A CORE_ADDR is an address in the program. These functions return offset in sections (.debug_loclists and .debug_rnglists). I think sect_offset is more appropriate. I'm wondering if struct attribute should have a "set_sect_offset" method, that takes a sect_offset parameter, or if it's better to be left as a simple "unsigned". gdb/ChangeLog: * dwarf2/read.c (read_loclist_index, read_rnglist_index): Return a sect_offset. (read_attribute_reprocess): Adjust. Change-Id: I0e22e0864130fb490072b41ae099762918b8ad4d --- gdb/dwarf2/read.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 86a69efe8ecc..b4ac290ca319 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20195,7 +20195,8 @@ lookup_loclist_base (struct dwarf2_cu *cu) /* Given a DW_FORM_loclistx value LOCLIST_INDEX, fetch the offset from the array of offsets in the .debug_loclists section. */ -static CORE_ADDR + +static sect_offset read_loclist_index (struct dwarf2_cu *cu, ULONGEST loclist_index) { dwarf2_per_objfile *per_objfile = cu->per_objfile; @@ -20245,14 +20246,15 @@ read_loclist_index (struct dwarf2_cu *cu, ULONGEST loclist_index) const gdb_byte *info_ptr = section->buffer + start_offset; if (cu->header.offset_size == 4) - return bfd_get_32 (abfd, info_ptr) + loclist_base; + return (sect_offset) (bfd_get_32 (abfd, info_ptr) + loclist_base); else - return bfd_get_64 (abfd, info_ptr) + loclist_base; + return (sect_offset) (bfd_get_64 (abfd, info_ptr) + loclist_base); } /* Given a DW_FORM_rnglistx value RNGLIST_INDEX, fetch the offset from the array of offsets in the .debug_rnglists section. */ -static CORE_ADDR + +static sect_offset read_rnglist_index (struct dwarf2_cu *cu, ULONGEST rnglist_index, dwarf_tag tag) { @@ -20309,9 +20311,9 @@ read_rnglist_index (struct dwarf2_cu *cu, ULONGEST rnglist_index, const gdb_byte *info_ptr = section->buffer + start_offset; if (cu->header.offset_size == 4) - return read_4_bytes (abfd, info_ptr) + rnglist_base; + return (sect_offset) (read_4_bytes (abfd, info_ptr) + rnglist_base); else - return read_8_bytes (abfd, info_ptr) + rnglist_base; + return (sect_offset) (read_8_bytes (abfd, info_ptr) + rnglist_base); } /* Process the attributes that had to be skipped in the first round. These @@ -20332,18 +20334,18 @@ read_attribute_reprocess (const struct die_reader_specs *reader, break; case DW_FORM_loclistx: { - CORE_ADDR loclists_sect_off + sect_offset loclists_sect_off = read_loclist_index (cu, attr->as_unsigned_reprocess ()); - attr->set_unsigned (loclists_sect_off); + attr->set_unsigned (to_underlying (loclists_sect_off)); } break; case DW_FORM_rnglistx: { - CORE_ADDR rnglists_sect_off + sect_offset rnglists_sect_off = read_rnglist_index (cu, attr->as_unsigned_reprocess (), tag); - attr->set_unsigned (rnglists_sect_off); + attr->set_unsigned (to_underlying (rnglists_sect_off)); } break; case DW_FORM_strx: -- 2.30.0