From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id zukwKPzVoV++PwAAWB0awg (envelope-from ) for ; Tue, 03 Nov 2020 17:13:16 -0500 Received: by simark.ca (Postfix, from userid 112) id 97EB11F08B; Tue, 3 Nov 2020 17:13:16 -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.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,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 6F8C51E58D for ; Tue, 3 Nov 2020 17:13:15 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBD773986839; Tue, 3 Nov 2020 22:13:14 +0000 (GMT) Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.54.2]) by sourceware.org (Postfix) with ESMTPS id 5E423384A87E for ; Tue, 3 Nov 2020 22:13:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5E423384A87E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 21B4D400D708B for ; Tue, 3 Nov 2020 16:10:44 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id a4YAkW7yBnPrxa4YAk9Y0Q; Tue, 03 Nov 2020 16:13:10 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding: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=iO+YJeDrsN3qw6hZ6H+e2orSp1ey7c/SraSsGZTD+vQ=; b=U7KLOsjRdVaIYsWCeBQSHizq4a EQAcc4DmxMSHsC6v5/PNIQSz3McEpLnnCfD1f6WrRwBdR+HQLsACZvs4RKXLy4eDIjpgkcdcGlG0O vvx71EQN0TMf8oQGvvK1ekEPo; Received: from 97-122-89-243.hlrn.qwest.net ([97.122.89.243]:42982 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ka4YA-003Kpv-Dy; Tue, 03 Nov 2020 15:13:10 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH] Shrink size of dwarf2_per_cu_data Date: Tue, 3 Nov 2020 15:13:06 -0700 Message-Id: <20201103221306.6688-1-tom@tromey.com> X-Mailer: git-send-email 2.17.2 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.89.243 X-Source-L: No X-Exim-ID: 1ka4YA-003Kpv-Dy X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-89-243.hlrn.qwest.net (bapiya.Home) [97.122.89.243]:42982 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" I noticed some holes in struct dwarf2_per_cu_data. This patch rearranges the type slightly, and shrinks the size of some fields. This reduces it from 136 bytes to 112 bytes (on x86-64). I also reduced the size of the DWARF "version" fields in a couple of spots. It seemed needless to use a short to hold a value that ranges from 2 to 5, and this also helped the goal of shrinking dwarf2_per_cu_data. gdb/ChangeLog 2020-11-03 Tom Tromey * dwarf2/read.h (struct dwarf2_per_cu_data) : Now unsigned char. (struct dwarf2_per_cu_data): Rearrange. * dwarf2/comp-unit.h (struct comp_unit_head) : Now unsigned char. (struct comp_unit_head): Rearrange. * dwarf2/comp-unit.c (read_comp_unit_head): Update. --- gdb/ChangeLog | 10 ++++++++++ gdb/dwarf2/comp-unit.c | 7 ++++--- gdb/dwarf2/comp-unit.h | 15 +++++++-------- gdb/dwarf2/read.h | 26 +++++++++++++------------- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/gdb/dwarf2/comp-unit.c b/gdb/dwarf2/comp-unit.c index 7ddc893aac6..05cf3f1c6a8 100644 --- a/gdb/dwarf2/comp-unit.c +++ b/gdb/dwarf2/comp-unit.c @@ -75,11 +75,12 @@ read_comp_unit_head (struct comp_unit_head *cu_header, cu_header->initial_length_size = bytes_read; cu_header->offset_size = (bytes_read == 4) ? 4 : 8; info_ptr += bytes_read; - cu_header->version = read_2_bytes (abfd, info_ptr); - if (cu_header->version < 2 || cu_header->version > 5) + unsigned version = read_2_bytes (abfd, info_ptr); + if (version < 2 || version > 5) error (_("Dwarf Error: wrong version in compilation unit header " "(is %d, should be 2, 3, 4 or 5) [in module %s]"), - cu_header->version, filename); + version, filename); + cu_header->version = version; info_ptr += 2; if (cu_header->version < 5) switch (section_kind) diff --git a/gdb/dwarf2/comp-unit.h b/gdb/dwarf2/comp-unit.h index 35bca8f8e9d..09ffac8d2da 100644 --- a/gdb/dwarf2/comp-unit.h +++ b/gdb/dwarf2/comp-unit.h @@ -35,7 +35,7 @@ struct comp_unit_head { unsigned int length; - short version; + unsigned char version; unsigned char addr_size; unsigned char signed_addr_p; sect_offset abbrev_sect_off; @@ -48,14 +48,16 @@ struct comp_unit_head enum dwarf_unit_type unit_type; - /* Offset to the first byte of this compilation unit header in the - .debug_info section, for resolving relative reference dies. */ - sect_offset sect_off; - /* 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; + /* Offset to the first byte of this compilation unit header in the + .debug_info section, for resolving relative reference dies. */ + 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; /* 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). @@ -63,9 +65,6 @@ struct comp_unit_head DW_UT_skeleton or DW_UT_split_compile. */ ULONGEST signature; - /* For types, offset in the type's DIE of the type defined by this TU. */ - cu_offset type_cu_offset_in_tu; - /* Return the total length of the CU described by this header. */ unsigned int get_length () const { diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index a0d76f349e8..f358c562fdf 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -433,7 +433,7 @@ struct dwarf2_per_cu_data unsigned int length; /* DWARF standard version this data has been read from (such as 4 or 5). */ - short dwarf_version; + unsigned char dwarf_version; /* Flag indicating this compilation unit will be read in before any of the current compilation units are processed. */ @@ -469,6 +469,18 @@ struct dwarf2_per_cu_data This flag is only valid if is_debug_types is true. */ unsigned int tu_read : 1; + /* True if HEADER has been read in. + + Don't access this field directly. It should be private, but we can't make + it private at the moment. */ + mutable bool m_header_read_in : 1; + + /* The unit type of this CU. */ + ENUM_BITFIELD (dwarf_unit_type) unit_type : 8; + + /* The language of this CU. */ + ENUM_BITFIELD (language) lang : LANGUAGE_BITS; + /* Our index in the unshared "symtabs" vector. */ unsigned index; @@ -477,12 +489,6 @@ struct dwarf2_per_cu_data not the DWO file. */ struct dwarf2_section_info *section; - /* The unit type of this CU. */ - enum dwarf_unit_type unit_type; - - /* The language of this CU. */ - enum language lang; - /* Backlink to the owner of this. */ dwarf2_per_bfd *per_bfd; @@ -495,12 +501,6 @@ struct dwarf2_per_cu_data should be private, but we can't make it private at the moment. */ mutable comp_unit_head m_header; - /* True if HEADER has been read in. - - Don't access this field directly. It should be private, but we can't make - it private at the moment. */ - mutable bool m_header_read_in; - /* When dwarf2_per_bfd::using_index is true, the 'quick' field is active. Otherwise, the 'psymtab' field is active. */ union -- 2.17.2