From patchwork Sat Feb 10 00:42:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85553 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CFB363858C66 for ; Sat, 10 Feb 2024 00:43:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 9D4B43858D32 for ; Sat, 10 Feb 2024 00:42:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D4B43858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9D4B43858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707525778; cv=none; b=UV4LkUjnqtjQkrdTMoe97ZXKhz5sFnXMzKTsyIlaLts0fReXfwEJx5DolENoNYO7jjNs3nanwyEWGN6JYxn6pZK3ls17jyTCLSoe2Bnel0FLWZJ0EIBs/9mkdkox+Mdek+JGWFGtjATKARnQ3d1R9WuU+3Nq3sUB4pwsdNmI62o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707525778; c=relaxed/simple; bh=gOggJEycyi+lUPDmNWj31VZ8XHVBg0XEY3sSw1HzY+Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YetyUn6BIwYECZCaM4EG5J8jGF0YQhfvADSyEywEeVmust7hsHLs1iRWkHcBFfKz6OcW316cW1unqc2dXTYaPfvsFALT/4LC2n9qUb9TIYNDaB2wvIYH0u8tlOlo0RA3UTuJNqO2uDez6LHFCIL7qYHnc2eOoyhVjdeEC8YcUhU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5005a.ext.cloudfilter.net ([10.0.29.234]) by cmsmtp with ESMTPS id YaovrzHIvpUFLYbSJrgfaB; Sat, 10 Feb 2024 00:42:55 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id YbSIr1l2eOQsyYbSJrr2Me; Sat, 10 Feb 2024 00:42:55 +0000 X-Authority-Analysis: v=2.4 cv=auMRCjZV c=1 sm=1 tr=0 ts=65c6c68f a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=k1lJg1FmEPc47z8vjooA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pwUU1kKbtUkAoeM9KF5ahM6xX0hULa/Tc4WNmX26Wfs=; b=iAXiwq5gmwLcqyuN0V+6UcHY+i r3hI493qifyMgNa7I/q9HxMmLAG+zsF6Iu3LXcp4QrpnG1GXUwjseXCIKqppVK2bnwmK77gw4Zc4m MrhYZChciQF2PYIBD3LIXRYFM; Received: from [161.98.8.3] (port=53790 helo=prentzel.ci.boulder.co.us) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rYbSI-000pMg-1j; Fri, 09 Feb 2024 17:42:54 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use DW_FORM_ref_addr for DIE offset in .debug_names Date: Fri, 9 Feb 2024 17:42:53 -0700 Message-ID: <20240210004253.2352981-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 161.98.8.3 X-Source-L: No X-Exim-ID: 1rYbSI-000pMg-1j X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (prentzel.ci.boulder.co.us) [161.98.8.3]:53790 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDzdSGnTI9375N8W4qx9nptx5Tupe3Lm+xwr5EPvn7Qj1nJtdABw2RgNtKVzDZT/KLYbjvxC7jsV5HZCLdUpiecNeRXdKZGBi1RTmTccgxpvcXT2KOtZ 7iPd5fwHwPXd7NnHMaximgCaYzpQys9fFfmCfsPAo3/fNw4V9Lz1cSqS4lQ+NA1fnFxyvtAvPOHRi+ROphb0Vvp8kC/fszcphQs= X-Spam-Status: No, score=-3022.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Today I realized that while the .debug_names writer uses DW_FORM_udata for the DIE offset, DW_FORM_ref_addr would be more appropriate here. This patch makes this change. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31361 --- gdb/dwarf2/index-write.c | 7 +++++-- gdb/dwarf2/read-debug-names.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 0123e7f2435..a114001f4ee 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -761,7 +761,7 @@ class debug_names : DW_IDX_type_unit); m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata); m_abbrev_table.append_unsigned_leb128 (DW_IDX_die_offset); - m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata); + m_abbrev_table.append_unsigned_leb128 (DW_FORM_ref_addr); m_abbrev_table.append_unsigned_leb128 (DW_IDX_GNU_language); m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata); if ((entry->flags & IS_STATIC) != 0) @@ -796,7 +796,10 @@ class debug_names gdb_assert (it != m_cu_index_htab.cend ()); m_entry_pool.append_unsigned_leb128 (it->second); - m_entry_pool.append_unsigned_leb128 (to_underlying (entry->die_offset)); + m_entry_pool.append_uint (dwarf5_offset_size (), + m_dwarf5_byte_order, + to_underlying (entry->die_offset)); + m_entry_pool.append_unsigned_leb128 (entry->per_cu->dw_lang ()); if (parent != nullptr) diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index e2563e84fcf..0add8040894 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -155,6 +155,10 @@ mapped_debug_names_reader::scan_one_entry (const char *name, ull = read_unsigned_leb128 (abfd, entry, &bytes_read); entry += bytes_read; break; + case DW_FORM_ref_addr: + ull = read_offset (abfd, entry, offset_size); + entry += offset_size; + break; case DW_FORM_ref4: ull = read_4_bytes (abfd, entry); entry += 4;