From patchwork Thu Jan 25 09:38:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 25539 Received: (qmail 111812 invoked by alias); 25 Jan 2018 09:38:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 111747 invoked by uid 89); 25 Jan 2018 09:38:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Anonymous X-HELO: mail-wr0-f196.google.com Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jan 2018 09:38:48 +0000 Received: by mail-wr0-f196.google.com with SMTP id a1so2228965wri.5 for ; Thu, 25 Jan 2018 01:38:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=d3CoykP9mb2BJE2L1HBvBA+hfqkiWorzOxahunVYFW8=; b=qWUITCV+VTcPUYlg3gTVHBF+UF+ZpsbQpyPWkRMJapO7jzcQJikLtmGY3Abs2JSUG5 MQ5eRC50WUDOhyYqqCTXmxxe+x7vTrP6mmGwkMnWzPp/L8bPdC5QMEQ6OOY96+HqxSx2 SH5SgaWJ94TGWPBaoShPtw8g/RUHPCAcR7A6/rIsgvLj+5UHhFwHdfS+MfoW42FWqou0 /VhTavWaLPtvWu9w9a70yjWISGt4wLZSMzfIPKawSiBeWznC+9j7swGOJgCExgnStJtW HbAsYD+cpysVLeg9TIz2L9gDw43XSv5FJ4rO0MxP7GozTVj4GlUSeYyJwk87E8EcEBFV qT4w== X-Gm-Message-State: AKwxytczoL9bzFaAYdlNnfcbAfCDtVJTSzf1nmVgk99G+mqj+l0dcXjQ 3gHwklfCl+FrNZbi44hmwijbww== X-Google-Smtp-Source: AH8x225MMEDR1iMMExWSgohXd8BYOIpbQ1O2/JVmnWjtbG8nwJghVmyIpgXztKJbl1uollIPXzwb9A== X-Received: by 10.223.150.213 with SMTP id u79mr8743831wrb.137.1516873125901; Thu, 25 Jan 2018 01:38:45 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id p15sm3767493wre.47.2018.01.25.01.38.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Jan 2018 01:38:45 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 6/7] Move fixup_partial_die to partial_die_info::fixup Date: Thu, 25 Jan 2018 09:38:33 +0000 Message-Id: <1516873114-7449-7-git-send-email-yao.qi@linaro.org> In-Reply-To: <1516873114-7449-1-git-send-email-yao.qi@linaro.org> References: <1516873114-7449-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes fixup_partial_die can be a partial_die_info method fixup, and field fixup_called can be private. gdb: 2018-01-11 Yao Qi * dwarf2read.c (struct partial_die_info) : New method. (struct partial_die_info) : Change it to m_fixup_called. (fixup_partial_die): Remove declaration. (scan_partial_symbols): Update. (partial_die_parent_scope): Likewise. (partial_die_full_name): Likewise. (fixup_partial_die): Change it to partial_die_info::fixup. --- gdb/dwarf2read.c | 79 +++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0ee102a..9b6f2ec 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1410,6 +1410,11 @@ struct partial_die_info load_partial_dies. */ partial_die_info& operator=(const partial_die_info& rhs) = delete; + /* Adjust the partial die before generating a symbol for it. This + function may set the is_external flag or change the DIE's + name. */ + void fixup (struct dwarf2_cu *cu); + /* Offset of this DIE. */ const sect_offset sect_off; @@ -1442,9 +1447,6 @@ struct partial_die_info /* Flag set if any of the DIE's children are template arguments. */ unsigned int has_template_arguments : 1; - /* Flag set if fixup_partial_die has been called on this die. */ - unsigned int fixup_called : 1; - /* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt. */ unsigned int is_dwz : 1; @@ -1519,10 +1521,13 @@ struct partial_die_info has_byte_size = 0; has_const_value = 0; has_template_arguments = 0; - fixup_called = 0; + m_fixup_called = false; is_dwz = 0; spec_is_dwz = 0; } + + /* Flag set if fixup has been called on this die. */ + bool m_fixup_called : 1; }; /* This data structure holds the information of an abbrev. */ @@ -1839,9 +1844,6 @@ static const gdb_byte *read_partial_die (const struct die_reader_specs *, static struct partial_die_info *find_partial_die (sect_offset, int, struct dwarf2_cu *); -static void fixup_partial_die (struct partial_die_info *, - struct dwarf2_cu *); - static const gdb_byte *read_attribute (const struct die_reader_specs *, struct attribute *, struct attr_abbrev *, const gdb_byte *); @@ -9025,7 +9027,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc, while (pdi != NULL) { - fixup_partial_die (pdi, cu); + pdi->fixup (cu); /* Anonymous namespaces or modules have no name but have interesting children, so we need to look at them. Ditto for anonymous @@ -9161,7 +9163,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, if (parent->scope_set) return parent->scope; - fixup_partial_die (parent, cu); + parent->fixup (cu); grandparent_scope = partial_die_parent_scope (parent, cu); @@ -9226,7 +9228,7 @@ partial_die_full_name (struct partial_die_info *pdi, types here will be reused if full symbols are loaded later. */ if (pdi->has_template_arguments) { - fixup_partial_die (pdi, cu); + pdi->fixup (cu); if (pdi->name != NULL && strchr (pdi->name, '<') == NULL) { @@ -9535,7 +9537,7 @@ add_partial_subprogram (struct partial_die_info *pdi, pdi = pdi->die_child; while (pdi != NULL) { - fixup_partial_die (pdi, cu); + pdi->fixup (cu); if (pdi->tag == DW_TAG_subprogram || pdi->tag == DW_TAG_inlined_subroutine || pdi->tag == DW_TAG_lexical_block) @@ -18842,45 +18844,40 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi, } } -/* Adjust PART_DIE before generating a symbol for it. This function - may set the is_external flag or change the DIE's name. */ - -static void -fixup_partial_die (struct partial_die_info *part_die, - struct dwarf2_cu *cu) +void +partial_die_info::fixup (struct dwarf2_cu *cu) { /* Once we've fixed up a die, there's no point in doing so again. This also avoids a memory leak if we were to call guess_partial_die_structure_name multiple times. */ - if (part_die->fixup_called) + if (m_fixup_called) return; /* If we found a reference attribute and the DIE has no name, try to find a name in the referred to DIE. */ - if (part_die->name == NULL && part_die->has_specification) + if (name == NULL && has_specification) { struct partial_die_info *spec_die; - spec_die = find_partial_die (part_die->spec_offset, - part_die->spec_is_dwz, cu); + spec_die = find_partial_die (spec_offset, spec_is_dwz, cu); - fixup_partial_die (spec_die, cu); + spec_die->fixup (cu); if (spec_die->name) { - part_die->name = spec_die->name; + name = spec_die->name; /* Copy DW_AT_external attribute if it is set. */ if (spec_die->is_external) - part_die->is_external = spec_die->is_external; + is_external = spec_die->is_external; } } /* Set default names for some unnamed DIEs. */ - if (part_die->name == NULL && part_die->tag == DW_TAG_namespace) - part_die->name = CP_ANONYMOUS_NAMESPACE_STR; + if (name == NULL && tag == DW_TAG_namespace) + name = CP_ANONYMOUS_NAMESPACE_STR; /* If there is no parent die to provide a namespace, and there are children, see if we can determine the namespace from their linkage @@ -18888,25 +18885,25 @@ fixup_partial_die (struct partial_die_info *part_die, if (cu->language == language_cplus && !VEC_empty (dwarf2_section_info_def, cu->per_cu->dwarf2_per_objfile->types) - && part_die->die_parent == NULL - && part_die->has_children - && (part_die->tag == DW_TAG_class_type - || part_die->tag == DW_TAG_structure_type - || part_die->tag == DW_TAG_union_type)) - guess_partial_die_structure_name (part_die, cu); + && die_parent == NULL + && has_children + && (tag == DW_TAG_class_type + || tag == DW_TAG_structure_type + || tag == DW_TAG_union_type)) + guess_partial_die_structure_name (this, cu); /* GCC might emit a nameless struct or union that has a linkage name. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47510. */ - if (part_die->name == NULL - && (part_die->tag == DW_TAG_class_type - || part_die->tag == DW_TAG_interface_type - || part_die->tag == DW_TAG_structure_type - || part_die->tag == DW_TAG_union_type) - && part_die->linkage_name != NULL) + if (name == NULL + && (tag == DW_TAG_class_type + || tag == DW_TAG_interface_type + || tag == DW_TAG_structure_type + || tag == DW_TAG_union_type) + && linkage_name != NULL) { char *demangled; - demangled = gdb_demangle (part_die->linkage_name, DMGL_TYPES); + demangled = gdb_demangle (linkage_name, DMGL_TYPES); if (demangled) { const char *base; @@ -18920,7 +18917,7 @@ fixup_partial_die (struct partial_die_info *part_die, base = demangled; struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; - part_die->name + name = ((const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack, base, strlen (base))); @@ -18928,7 +18925,7 @@ fixup_partial_die (struct partial_die_info *part_die, } } - part_die->fixup_called = 1; + m_fixup_called = true; } /* Read an attribute value described by an attribute form. */