From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 84E8C395C029 for ; Wed, 20 May 2020 17:40:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 84E8C395C029 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B9BB556024; Wed, 20 May 2020 13:40:34 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id agfuEqEbpcgQ; Wed, 20 May 2020 13:40:34 -0400 (EDT) Received: from murgatroyd.Home (174-16-104-48.hlrn.qwest.net [174.16.104.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 7BF66117429; Wed, 20 May 2020 13:40:34 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/4] Attribute method inlining Date: Wed, 20 May 2020 11:40:29 -0600 Message-Id: <20200520174032.9525-2-tromey@adacore.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200520174032.9525-1-tromey@adacore.com> References: <20200520174032.9525-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 20 May 2020 17:40:36 -0000 This inlines a couple of methods on struct attribute, improving the performance of DWARF partial symbol reading. These methods were discovered as hot spots using callgrind. For this patch, and for all the patches in this series, I tested gdb's performance on three programs: 1. gdb itself -- I built gdb and copied it to /tmp, ensuring that the same version was used in all tests. 2. The system libxul.so, the main library of Firefox. I installed the separate debuginfo and ensured that gdb read it. 3. A large-ish Ada program that I happen to have. I ran gdb 10 times like: /bin/time -f %e \ ./gdb/gdb --data-directory ./gdb/data-directory -nx \ -iex 'set debug-file-directory /usr/lib/debug' \ -batch $X ... where $X was the test executable. Then I computed the mean time. This was all done with a standard (-g -O2) build of gdb. The baseline times were gdb 1.90 libxul 2.12 Ada 2.61 This patch brings the numbers down to gdb 1.88 libxul 2.11 Ada 2.60 Not a huge change, but still visible in the results. gdb/ChangeLog 2020-05-20 Tom Tromey * dwarf2/attribute.h (struct attribute) : Inline. : Inline. : New method. * dwarf2/attribute.c (attribute::form_is_ref): Move to header. (attribute::get_ref_die_offset_complaint): Rename from get_ref_die_offset. Just issue complaint. --- gdb/ChangeLog | 9 +++++++++ gdb/dwarf2/attribute.c | 29 ++--------------------------- gdb/dwarf2/attribute.h | 25 +++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 9f808aa7904..b39cfe2c00d 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -120,38 +120,13 @@ attribute::form_is_constant () const } } -/* DW_ADDR is always stored already as sect_offset; despite for the forms - besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */ - -bool -attribute::form_is_ref () const -{ - switch (form) - { - case DW_FORM_ref_addr: - case DW_FORM_ref1: - case DW_FORM_ref2: - case DW_FORM_ref4: - case DW_FORM_ref8: - case DW_FORM_ref_udata: - case DW_FORM_GNU_ref_alt: - return true; - default: - return false; - } -} - /* See attribute.h. */ -sect_offset -attribute::get_ref_die_offset () const +void +attribute::get_ref_die_offset_complaint () const { - if (form_is_ref ()) - return (sect_offset) DW_UNSND (this); - complaint (_("unsupported die ref attribute form: '%s'"), dwarf_form_name (form)); - return {}; } /* See attribute.h. */ diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index a9cabd69f9f..ffb91e878f1 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -82,7 +82,16 @@ struct attribute /* DW_ADDR is always stored already as sect_offset; despite for the forms besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */ - bool form_is_ref () const; + bool form_is_ref () const + { + return (form == DW_FORM_ref_addr + || form == DW_FORM_ref1 + || form == DW_FORM_ref2 + || form == DW_FORM_ref4 + || form == DW_FORM_ref8 + || form == DW_FORM_ref_udata + || form == DW_FORM_GNU_ref_alt); + } /* Check if the attribute's form is a DW_FORM_block* if so return true else false. */ @@ -92,7 +101,13 @@ struct attribute /* Return DIE offset of this attribute. Return 0 with complaint if the attribute is not of the required kind. */ - sect_offset get_ref_die_offset () const; + sect_offset get_ref_die_offset () const + { + if (form_is_ref ()) + return (sect_offset) u.unsnd; + get_ref_die_offset_complaint (); + return {}; + } /* Return the constant value held by this attribute. Return DEFAULT_VALUE if the value held by the attribute is not @@ -119,6 +134,12 @@ struct attribute ULONGEST signature; } u; + +private: + + /* Used by get_ref_die_offset to issue a complaint. */ + + void get_ref_die_offset_complaint () const; }; /* Get at parts of an attribute structure. */ -- 2.21.3