From patchwork Thu Feb 22 15:36:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 26004 Received: (qmail 31479 invoked by alias); 22 Feb 2018 15:36:51 -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 31397 invoked by uid 89); 22 Feb 2018 15:36:50 -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= X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Feb 2018 15:36:48 +0000 Received: by mail-wm0-f66.google.com with SMTP id z81so4690399wmb.4 for ; Thu, 22 Feb 2018 07:36:48 -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=O4q5qyCMhnd6S8kTIDJLvkO6DdfeqTQQv7j7lJb3Ais=; b=ZmzVQFRoIvs7qEplA8bEASyEyiqGdeW0bcGqjC0rboIxNkDE3r5Zlhar0JHas5yomm sjaJ29ZLARNswDjYadCZBik6ptEWqM4DpCu2n/ny+x9NVS54TQ6jI+fZc+VVSZrnUChg 7wg0/M/UPoYF32Je76YcSkurEbiaIVCVcNawnDqxL8lzWPukJYwLzTckxd6uT5BPNa9A fQ8D7HJMWPteGiMNRoydUro2G62eS96Cn1dn1y7d1HOOZ29Z2ByfPUbGqyrACelCmC3l NC990myWhIqHiMrAfPwp/x4kXygHFm+TfId0a1124dUS0Zk/Y+uELRWsI47AoLF3pdyZ qFAg== X-Gm-Message-State: APf1xPB8hbyDPYNGFbwtJB00aKDkbSE+QgAmTDF7CHXQ1QQzws3qBR/N +e10CYIgE1hckPl+pc4hTPzs7jd0 X-Google-Smtp-Source: AH8x226sCJrECvdBZ73iP8vXM0dC+s6WA/4fQZTWPh79MqWiKX+l1TWBE46hCccH9HxeG+MCLf09Ww== X-Received: by 10.28.39.67 with SMTP id n64mr5271323wmn.71.1519313806023; Thu, 22 Feb 2018 07:36:46 -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 a67sm538325wrc.13.2018.02.22.07.36.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Feb 2018 07:36: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, 22 Feb 2018 15:36:35 +0000 Message-Id: <1519313796-2397-7-git-send-email-yao.qi@linaro.org> In-Reply-To: <1519313796-2397-1-git-send-email-yao.qi@linaro.org> References: <1519313796-2397-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes fixup_partial_die can be a partial_die_info method fixup. gdb: 2018-01-11 Yao Qi * dwarf2read.c (struct partial_die_info) : New method. (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 | 73 +++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 333a890..7823c3b 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1410,6 +1410,11 @@ struct partial_die_info : public allocate_on_obstack 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,7 +1447,7 @@ struct partial_die_info : public allocate_on_obstack /* 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. */ + /* Flag set if fixup has been called on this die. */ unsigned int fixup_called : 1; /* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt. */ @@ -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 *); @@ -9082,7 +9084,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 @@ -9218,7 +9220,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); @@ -9283,7 +9285,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) { @@ -9592,7 +9594,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) @@ -18874,45 +18876,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 (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 @@ -18920,25 +18917,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; @@ -18952,7 +18949,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))); @@ -18960,7 +18957,7 @@ fixup_partial_die (struct partial_die_info *part_die, } } - part_die->fixup_called = 1; + fixup_called = 1; } /* Read an attribute value described by an attribute form. */