From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.104]) by sourceware.org (Postfix) with ESMTPS id 463AA3899074 for ; Sat, 28 Mar 2020 19:22:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 463AA3899074 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 cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id EE5BC26FF for ; Sat, 28 Mar 2020 14:22:12 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH24jhU8rVQh0IH24juv36; Sat, 28 Mar 2020 14:22:12 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PYBfJSCUT7+CZi6QpCeuPpiPKJGLlt3RfuoAQhRf5t8=; b=aB10xTvseOODQlesyhZLfuHT4f ws98aGHG7kQFxx3xXvAEDEjfJpOio0OafeY5mkeJC+HlEGL0jnhfURI4UE9T6myJJ0SPBP5aEvAkt +nQ57W4fq4+QxHoKGRKiBSgkA; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:55190 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jIH24-003oZR-Og; Sat, 28 Mar 2020 13:22:12 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 13/20] Change how reprocessing is done Date: Sat, 28 Mar 2020 13:22:01 -0600 Message-Id: <20200328192208.11324-14-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200328192208.11324-1-tom@tromey.com> References: <20200328192208.11324-1-tom@tromey.com> 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.118.117.21 X-Source-L: No X-Exim-ID: 1jIH24-003oZR-Og X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:55190 X-Source-Auth: tom+tromey.com X-Email-Count: 16 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-21.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A 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: Sat, 28 Mar 2020 19:22:16 -0000 Currently gdb keeps a vector of attributes that require reprocessing. However, now that there is a reprocessing flag in the attribute, we can remove the vector and instead simply loop over attributes a second time. Normally there are not many attributes, so this should be reasonably cheap. gdb/ChangeLog 2020-03-28 Tom Tromey * dwarf2/read.c (skip_one_die): Update. (read_full_die_1): Change how reprocessing is done. (partial_die_info::read): Update. (read_attribute_value): Remove need_reprocess parameter. (read_attribute): Likewise. * dwarf2/attribute.h (struct attribute) : New method. --- gdb/ChangeLog | 10 +++++++++ gdb/dwarf2/attribute.h | 6 ++++++ gdb/dwarf2/read.c | 48 +++++++++++++++++++----------------------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 972beef9825..9b387e5df05 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -214,6 +214,12 @@ struct attribute requires_reprocessing = 0; } + /* True if this attribute requires reprocessing. */ + bool reprocessing_p () const + { + return requires_reprocessing; + } + ENUM_BITFIELD(dwarf_attribute) name : 15; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index b010c9c3b01..d3897ac2198 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1192,7 +1192,7 @@ static const struct cu_partial_die_info find_partial_die (sect_offset, int, static const gdb_byte *read_attribute (const struct die_reader_specs *, struct attribute *, struct attr_abbrev *, - const gdb_byte *, bool *need_reprocess); + const gdb_byte *); static void read_attribute_reprocess (const struct die_reader_specs *reader, struct attribute *attr); @@ -8464,9 +8464,7 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, /* The only abbrev we care about is DW_AT_sibling. */ if (abbrev->attrs[i].name == DW_AT_sibling) { - bool ignored; - read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr, - &ignored); + read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr); if (attr.form == DW_FORM_ref_addr) complaint (_("ignoring absolute DW_AT_sibling")); else @@ -17484,15 +17482,13 @@ read_full_die_1 (const struct die_reader_specs *reader, attributes. */ die->num_attrs = abbrev->num_attrs; - std::vector indexes_that_need_reprocess; + bool any_need_reprocess = false; for (i = 0; i < abbrev->num_attrs; ++i) { - bool need_reprocess; - info_ptr = - read_attribute (reader, &die->attrs[i], &abbrev->attrs[i], - info_ptr, &need_reprocess); - if (need_reprocess) - indexes_that_need_reprocess.push_back (i); + info_ptr = read_attribute (reader, &die->attrs[i], &abbrev->attrs[i], + info_ptr); + if (die->attrs[i].reprocessing_p ()) + any_need_reprocess = true; } struct attribute *attr = die->attr (DW_AT_str_offsets_base); @@ -17502,8 +17498,14 @@ read_full_die_1 (const struct die_reader_specs *reader, auto maybe_addr_base = die->addr_base (); if (maybe_addr_base.has_value ()) cu->addr_base = *maybe_addr_base; - for (int index : indexes_that_need_reprocess) - read_attribute_reprocess (reader, &die->attrs[index]); + if (any_need_reprocess) + { + for (i = 0; i < abbrev->num_attrs; ++i) + { + if (die->attrs[i].reprocessing_p ()) + read_attribute_reprocess (reader, &die->attrs[i]); + } + } *diep = die; return info_ptr; } @@ -17857,13 +17859,12 @@ partial_die_info::read (const struct die_reader_specs *reader, std::vector attr_vec (abbrev.num_attrs); for (i = 0; i < abbrev.num_attrs; ++i) { - bool need_reprocess; info_ptr = read_attribute (reader, &attr_vec[i], &abbrev.attrs[i], - info_ptr, &need_reprocess); + info_ptr); /* String and address offsets that need to do the reprocessing have already been read at this point, so there is no need to wait until the loop terminates to do the reprocessing. */ - if (need_reprocess) + if (attr_vec[i].reprocessing_p ()) read_attribute_reprocess (reader, &attr_vec[i]); attribute &attr = attr_vec[i]; /* Store the data if it is of an attribute we want to keep in a @@ -18342,8 +18343,7 @@ read_attribute_reprocess (const struct die_reader_specs *reader, static const gdb_byte * read_attribute_value (const struct die_reader_specs *reader, struct attribute *attr, unsigned form, - LONGEST implicit_const, const gdb_byte *info_ptr, - bool *need_reprocess) + LONGEST implicit_const, const gdb_byte *info_ptr) { struct dwarf2_cu *cu = reader->cu; struct dwarf2_per_objfile *dwarf2_per_objfile @@ -18354,7 +18354,6 @@ read_attribute_value (const struct die_reader_specs *reader, struct comp_unit_head *cu_header = &cu->header; unsigned int bytes_read; struct dwarf_block *blk; - *need_reprocess = false; attr->form = (enum dwarf_form) form; switch (form) @@ -18528,14 +18527,13 @@ read_attribute_value (const struct die_reader_specs *reader, info_ptr += bytes_read; } info_ptr = read_attribute_value (reader, attr, form, implicit_const, - info_ptr, need_reprocess); + info_ptr); break; case DW_FORM_implicit_const: attr->set_signed (implicit_const); break; case DW_FORM_addrx: case DW_FORM_GNU_addr_index: - *need_reprocess = true; attr->set_unsigned_reprocess (read_unsigned_leb128 (abfd, info_ptr, &bytes_read)); info_ptr += bytes_read; @@ -18573,9 +18571,8 @@ read_attribute_value (const struct die_reader_specs *reader, str_index = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); info_ptr += bytes_read; } - *need_reprocess = true; attr->set_unsigned_reprocess (str_index); - } + } break; default: error (_("Dwarf Error: Cannot handle %s in DWARF reader [in module %s]"), @@ -18611,14 +18608,13 @@ read_attribute_value (const struct die_reader_specs *reader, static const gdb_byte * read_attribute (const struct die_reader_specs *reader, struct attribute *attr, struct attr_abbrev *abbrev, - const gdb_byte *info_ptr, bool *need_reprocess) + const gdb_byte *info_ptr) { attr->name = abbrev->name; attr->string_is_canonical = 0; attr->requires_reprocessing = 0; return read_attribute_value (reader, attr, abbrev->form, - abbrev->implicit_const, info_ptr, - need_reprocess); + abbrev->implicit_const, info_ptr); } /* Return pointer to string at .debug_str offset STR_OFFSET. */ -- 2.17.2