From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 962423858D1E for ; Sat, 24 Dec 2022 22:44:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 962423858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 4FC4D10047D63 for ; Sat, 24 Dec 2022 22:44:44 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 9DG0p362AxJBC9DG0pcgza; Sat, 24 Dec 2022 22:44:44 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=V9y4bcri c=1 sm=1 tr=0 ts=63a780dc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=sHyYjHe8cH0A:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=iOJcF2zuWQU72QzT7yEA: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=JcRuYxtp4O8iY42FEh6SmtyHZPoYlSGvYvC3B4l9w2Y=; b=sIK0B28FOE4OxR0S9BsUgNtgZs jxlhgPGhKhFBFA7xeKhX3l94SfTaOzDnMkv94ZxyJr+3pM5D1n6lSJHekiEM8Cv8SffY/Hgi940JR WAWwINd8RoPXTJOGkK6lbmln/; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:34046 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p9DFz-000U8G-SC; Sat, 24 Dec 2022 15:44:43 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add initializers to comp_unit_head Date: Sat, 24 Dec 2022 15:44:35 -0700 Message-Id: <20221224224435.760523-1-tom@tromey.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 97.122.76.186 X-Source-L: No X-Exim-ID: 1p9DFz-000U8G-SC X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:34046 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: PR symtab/29343 points out that it would be beneficial if comp_unit_head had a constructor and used initializers. This patch implements this. I'm unsure if this is sufficient to close the bug, but at least it's a step. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29343 --- gdb/dwarf2/comp-unit-head.h | 24 ++++++++++++------------ gdb/dwarf2/cu.h | 2 +- gdb/dwarf2/read.c | 2 -- gdb/dwarf2/read.h | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h index a7ee3e64546..7579fe7fa29 100644 --- a/gdb/dwarf2/comp-unit-head.h +++ b/gdb/dwarf2/comp-unit-head.h @@ -34,36 +34,36 @@ translation, looks like this. */ struct comp_unit_head { - unsigned int length; - unsigned char version; - unsigned char addr_size; - unsigned char signed_addr_p; - sect_offset abbrev_sect_off; + unsigned int length = 0; + unsigned char version = 0; + unsigned char addr_size = 0; + unsigned char signed_addr_p = 0; + sect_offset abbrev_sect_off {}; /* Size of file offsets; either 4 or 8. */ - unsigned int offset_size; + unsigned int offset_size = 0; /* Size of the length field; either 4 or 12. */ - unsigned int initial_length_size; + unsigned int initial_length_size = 0; - enum dwarf_unit_type unit_type; + enum dwarf_unit_type unit_type {}; /* Offset to first die in this cu from the start of the cu. This will be the first byte following the compilation unit header. */ - cu_offset first_die_cu_offset; + cu_offset first_die_cu_offset {}; /* Offset to the first byte of this compilation unit header in the .debug_info section, for resolving relative reference dies. */ - sect_offset sect_off; + sect_offset sect_off {}; /* For types, offset in the type's DIE of the type defined by this TU. */ - cu_offset type_cu_offset_in_tu; + cu_offset type_cu_offset_in_tu {}; /* 64-bit signature of this unit. For type units, it denotes the signature of the type (DW_UT_type in DWARF 4, additionally DW_UT_split_type in DWARF 5). Also used in DWARF 5, to denote the dwo id when the unit type is DW_UT_skeleton or DW_UT_split_compile. */ - ULONGEST signature; + ULONGEST signature = 0; /* Return the total length of the CU described by this header. */ unsigned int get_length () const diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index 52975095871..b126acab7b2 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -98,7 +98,7 @@ struct dwarf2_cu void add_dependence (struct dwarf2_per_cu_data *ref_per_cu); /* The header of the compilation unit. */ - struct comp_unit_head header {}; + struct comp_unit_head header; /* Base address of this compilation unit. */ gdb::optional base_address; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7bd12c107e2..28fadb886aa 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -23580,8 +23580,6 @@ dwarf2_per_cu_data::get_header () const const gdb_byte *info_ptr = this->section->buffer + to_underlying (this->sect_off); - memset (&m_header, 0, sizeof (m_header)); - read_comp_unit_head (&m_header, info_ptr, this->section, rcuh_kind::COMPILE); diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index dd718266883..0dc4e2e885c 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -206,7 +206,7 @@ struct dwarf2_per_cu_data Don't access this field directly, use the get_header method instead. It should be private, but we can't make it private at the moment. */ - mutable comp_unit_head m_header {}; + mutable comp_unit_head m_header; /* The file and directory for this CU. This is cached so that we don't need to re-examine the DWO in some situations. This may be -- 2.38.1