From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway32.websitewelcome.com (gateway32.websitewelcome.com [192.185.145.115]) by sourceware.org (Postfix) with ESMTPS id 4A5C8385E000 for ; Sat, 4 Apr 2020 14:43:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4A5C8385E000 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 gateway32.websitewelcome.com (Postfix) with ESMTP id E491115A676 for ; Sat, 4 Apr 2020 09:43:26 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Kk18jwthaSl8qKk18jRzde; Sat, 04 Apr 2020 09:43:26 -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=OK8ViExGcNEm486SUqs//TQSCgIqHT6+gpkFjqabWIo=; b=N8jv0EQJfbK33CHZqEnL4Ft4Ay gdvHSQK1445TGgPPTRBoxwCa/nzEqK5ETnJypmc9SSC+sIwC3lx5cDbeePq+8qPgmb5TJjZVkBtF1 B30CEt77GUFSRVV1Cho4jFC1c; Received: from 174-16-110-145.hlrn.qwest.net ([174.16.110.145]:58434 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jKk18-003j51-NF; Sat, 04 Apr 2020 08:43:26 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 11/20] Add reprocessing flag to struct attribute Date: Sat, 4 Apr 2020 08:43:11 -0600 Message-Id: <20200404144320.18851-12-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200404144320.18851-1-tom@tromey.com> References: <20200404144320.18851-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: 174.16.110.145 X-Source-L: No X-Exim-ID: 1jKk18-003j51-NF X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-110-145.hlrn.qwest.net (bapiya.Home) [174.16.110.145]:58434 X-Source-Auth: tom+tromey.com X-Email-Count: 22 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-18.0 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, SPF_HELO_PASS, SPF_NEUTRAL, 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: Sat, 04 Apr 2020 14:43:29 -0000 Some forms require "reprocessing" -- a second pass to update their value appropriately. In this case, we'll set the unsigned value on the attribute, and then later set it to the correct value. To handle this, we introduce a reprocessing flag to attribute. Then, we manage this flag to ensure that setting and unsetting is done properly. gdb/ChangeLog 2020-04-04 Tom Tromey * dwarf2/read.c (read_cutu_die_from_dwo): Use OBSTACK_ZALLOC. (read_attribute_reprocess, read_attribute_value): Update. (read_attribute): Clear requires_reprocessing. * dwarf2/attribute.h (struct attribute) : New methods. : Clear requires_reprocessing. : New method. : Shrink by one bit. : New member. * dwarf2/attribute.c (attribute::form_requires_reprocessing): New method. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/dwarf2/attribute.c | 14 ++++++++++++++ gdb/dwarf2/attribute.h | 37 ++++++++++++++++++++++++++++++++++++- gdb/dwarf2/read.c | 12 +++++++----- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 092a09295ba..1b72f2b53d6 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -206,3 +206,17 @@ attribute::form_is_unsigned () const || form == DW_FORM_ref8 || form == DW_FORM_ref_udata); } + +/* See attribute.h. */ + +bool +attribute::form_requires_reprocessing () const +{ + return (form == DW_FORM_strx1 + || form == DW_FORM_strx2 + || form == DW_FORM_strx3 + || form == DW_FORM_strx4 + || form == DW_FORM_GNU_str_index + || form == DW_FORM_addrx + || form == DW_FORM_GNU_addr_index); +} diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 2617cab7188..3218b8be711 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -73,6 +73,15 @@ struct attribute return u.snd; } + /* Return the unsigned value, but only for attributes requiring + reprocessing. */ + ULONGEST as_unsigned_reprocess () const + { + gdb_assert (form_requires_reprocessing ()); + gdb_assert (requires_reprocessing); + return u.unsnd; + } + /* Return non-zero if ATTR's value is a section offset --- classes lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise. You may use DW_UNSND (attr) to retrieve such offsets. @@ -118,6 +127,10 @@ struct attribute /* Check if the attribute's form is an unsigned integer form. */ bool form_is_unsigned () const; + /* Check if the attribute's form is a form that requires + "reprocessing". */ + bool form_requires_reprocessing () const; + /* Return DIE offset of this attribute. Return 0 with complaint if the attribute is not of the required kind. */ @@ -147,6 +160,7 @@ struct attribute gdb_assert (form_is_string ()); u.str = str; string_is_canonical = 0; + requires_reprocessing = 0; } /* Set the canonical string value for this attribute. */ @@ -185,8 +199,29 @@ struct attribute u.unsnd = unsnd; } + /* Temporarily set this attribute to an unsigned integer. This is + used only for those forms that require reprocessing. */ + void set_unsigned_reprocess (ULONGEST unsnd) + { + gdb_assert (form_requires_reprocessing ()); + u.unsnd = unsnd; + requires_reprocessing = 1; + } + + + ENUM_BITFIELD(dwarf_attribute) name : 15; + + /* A boolean that is used for forms that require reprocessing. A + form may require data not directly available in the attribute. + E.g., DW_FORM_strx requires the corresponding + DW_AT_str_offsets_base. In this case, the processing for the + attribute must be done in two passes. In the first past, this + flag is set and the value is an unsigned. In the second pass, + the unsigned value is turned into the correct value for the form, + and this flag is cleared. This flag is unused for other + forms. */ + unsigned int requires_reprocessing : 1; - ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_form) form : 15; /* Has u.str already been updated by dwarf2_canonicalize_name? This diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 3539fb0136e..92f018ad5d2 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6499,7 +6499,7 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu, else if (stub_comp_dir != NULL) { /* Reconstruct the comp_dir attribute to simplify the code below. */ - comp_dir = XOBNEW (&cu->comp_unit_obstack, struct attribute); + comp_dir = OBSTACK_ZALLOC (&cu->comp_unit_obstack, struct attribute); comp_dir->name = DW_AT_comp_dir; comp_dir->form = DW_FORM_string; comp_dir->set_string_noncanonical (stub_comp_dir); @@ -18355,7 +18355,7 @@ read_attribute_reprocess (const struct die_reader_specs *reader, { case DW_FORM_addrx: case DW_FORM_GNU_addr_index: - DW_ADDR (attr) = read_addr_index (cu, DW_UNSND (attr)); + DW_ADDR (attr) = read_addr_index (cu, attr->as_unsigned_reprocess ()); break; case DW_FORM_strx: case DW_FORM_strx1: @@ -18364,7 +18364,7 @@ read_attribute_reprocess (const struct die_reader_specs *reader, case DW_FORM_strx4: case DW_FORM_GNU_str_index: { - unsigned int str_index = DW_UNSND (attr); + unsigned int str_index = attr->as_unsigned_reprocess (); gdb_assert (!attr->canonical_string_p ()); if (reader->dwo_file != NULL) attr->set_string_noncanonical (read_dwo_str_index (reader, @@ -18578,7 +18578,8 @@ read_attribute_value (const struct die_reader_specs *reader, case DW_FORM_addrx: case DW_FORM_GNU_addr_index: *need_reprocess = true; - DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); + attr->set_unsigned_reprocess (read_unsigned_leb128 (abfd, info_ptr, + &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_strx: @@ -18615,7 +18616,7 @@ read_attribute_value (const struct die_reader_specs *reader, info_ptr += bytes_read; } *need_reprocess = true; - DW_UNSND (attr) = str_index; + attr->set_unsigned_reprocess (str_index); } break; default: @@ -18656,6 +18657,7 @@ read_attribute (const struct die_reader_specs *reader, { 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); -- 2.17.2