From patchwork Thu Jan 25 14:45: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: 25543 Received: (qmail 48012 invoked by alias); 25 Jan 2018 14:45:52 -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 47978 invoked by uid 89); 25 Jan 2018 14:45:51 -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-f68.google.com Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jan 2018 14:45:49 +0000 Received: by mail-wm0-f68.google.com with SMTP id r78so15422744wme.0 for ; Thu, 25 Jan 2018 06:45:41 -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:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=A9dGkGWz/96X+Mm7fNRPpPhgzFZWCd+sn5ryZMO1vUo=; b=tZzMgGNDngaVvOm7Wib2VTYNNyqnwUD3dRvzcaKm/E8T/vhnf1PRZKNb1P6U5O4nF6 0uj5ZbDXbCO9b4zz8chYsiL54QerbDriW3t4VCvruafKqIOwDY98DOVc2vt3O127LEFl Ra8RkLpjeBMfhXSkOvhPon0i91rFUyS8lHQIvFhyY/TzWDgv7ua1EyvJa3JaF5Ay8P0O BADwAoFZB16NY18WOZ/pJViy75b75uvVIDYG4Qm/KB14H6Z9ji4RPGmfw42siHc/GHpi yYItQGsaAeTzKoxbVSKyIfwa97VasaytTGuNX4RgIMw3jBJ4X8eAlgGXJk+aigfzGOU9 5cNA== X-Gm-Message-State: AKwxytcLaqcHPhutfRYmn+51YdTOWJlpdnYHuYgDXCGvy3C7Wa9lzIkU dWxAgufvSdMcM48rVys1MnVnlw== X-Google-Smtp-Source: AH8x227MbUj0VxUxnUNCrXnHAgUVG63HwKI7Cp4LQuyuoH2eh5+QF2DEnMeOlyR/aSj3ratud7JhXA== X-Received: by 10.28.247.11 with SMTP id v11mr8549136wmh.27.1516891539253; Thu, 25 Jan 2018 06:45:39 -0800 (PST) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id y23sm6812789wrc.24.2018.01.25.06.45.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Jan 2018 06:45:38 -0800 (PST) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 6/7] Move fixup_partial_die to partial_die_info::fixup References: <1516873114-7449-1-git-send-email-yao.qi@linaro.org> <1516873114-7449-7-git-send-email-yao.qi@linaro.org> <7ec76915-7c39-04dc-4903-918531056500@redhat.com> Date: Thu, 25 Jan 2018 14:45:33 +0000 In-Reply-To: <7ec76915-7c39-04dc-4903-918531056500@redhat.com> (Pedro Alves's message of "Thu, 25 Jan 2018 12:59:10 +0000") Message-ID: <86zi52c7zm.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: > Currently, the boolean bits were all together for packing. > This moves the bit away from the others, after some pointer > fields, I think. This is probably growing the size of > the structure with some padding holes. OK, I discard the chunk of changing fixup_called to private field. Still keep it public. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0ee102a..087588a 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,7 +1447,7 @@ 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. */ + /* 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 *); @@ -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 (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; + fixup_called = 1; } /* Read an attribute value described by an attribute form. */