From patchwork Thu Jan 25 09:38:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 25538 Received: (qmail 111458 invoked by alias); 25 Jan 2018 09:38: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 111362 invoked by uid 89); 25 Jan 2018 09:38: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, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f194.google.com Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jan 2018 09:38:49 +0000 Received: by mail-wr0-f194.google.com with SMTP id v15so6930618wrb.8 for ; Thu, 25 Jan 2018 01:38: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=fxB69uppCZSZAB1lTI6CUBebe1QyoqasyFlfeLel25M=; b=F8IjTdTbqpFX6R7NOiISjiWU+pcVknoeZNIcDasYu2Rrk7RRI1wr/xpVrtVS8ePkp8 PR17dI2G8s86I7jqv+3DOFBaw3YgtZT0O0oYm3p1QQORh1qo/CzrJUDRfL10qk/8qkZl ErNVmiOCIYf6ZfGwmnTbvX2Gsu2oXzRC/RUdziJ/zO2fO1BgjmTk1WR8LVUV9qqPYSBK 3EAP0dzneq7W99BJd9EAmYFuq4jAshW7zzD67E0lLUsEE7HBt3UyIda3kx2HAklphcKV CUr9KY/8bFIKLPUTt7b6Whnrat+0z7/niXguy6ktUbAvr8sLNURJuEojxvogkMmrOPUm 6y9A== X-Gm-Message-State: AKwxytcqAfQY7ZJXVnrMx9Jo69DLgaQHA0P+RM0Q7+o60Uhr81ib8NXS fHnrr+vVcf+KrGdJ5Xd2K2ddOQ== X-Google-Smtp-Source: AH8x225PYPt7+RvPE7nB5PAzfhVfSF/J0DdjCqjwvOMSZZRKqf8c/d+7ZnFYye9PYHHHSoJ+eNSwJw== X-Received: by 10.223.176.253 with SMTP id j58mr7720312wra.252.1516873126731; Thu, 25 Jan 2018 01:38: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 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:46 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 7/7] Move read_partial_die to partial_die_info::read Date: Thu, 25 Jan 2018 09:38:34 +0000 Message-Id: <1516873114-7449-8-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 gdb: 2018-01-11 Yao Qi * dwarf2read.c (struct partial_die_info) : New method. (read_partial_die): Remove the declaration. (load_partial_dies): Update. (partial_die_info::partial_die_info): (read_partial_die): Change it to partial_die_info::read. --- gdb/dwarf2read.c | 108 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 51 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 9b6f2ec..02e4431 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1415,6 +1415,12 @@ struct partial_die_info name. */ void fixup (struct dwarf2_cu *cu); + /* Read a minimal amount of information into the minimal die + structure. */ + const gdb_byte *read (const struct die_reader_specs *reader, + struct abbrev_info *abbrev, + const gdb_byte *info_ptr); + /* Offset of this DIE. */ const sect_offset sect_off; @@ -1481,8 +1487,8 @@ struct partial_die_info /* Pointer into the info_buffer (or types_buffer) pointing at the target of DW_AT_sibling, if any. */ - /* NOTE: This member isn't strictly necessary, read_partial_die could - return DW_AT_sibling values to its caller load_partial_dies. */ + /* NOTE: This member isn't strictly necessary, partial_die_info::read + could return DW_AT_sibling values to its caller load_partial_dies. */ const gdb_byte *sibling = nullptr; /* If HAS_SPECIFICATION, the offset of the DIE referred to by @@ -1836,11 +1842,6 @@ static unsigned int peek_abbrev_code (bfd *, const gdb_byte *); static struct partial_die_info *load_partial_dies (const struct die_reader_specs *, const gdb_byte *, int); -static const gdb_byte *read_partial_die (const struct die_reader_specs *, - struct partial_die_info *, - struct abbrev_info *, - const gdb_byte *); - static struct partial_die_info *find_partial_die (sect_offset, int, struct dwarf2_cu *); @@ -14804,7 +14805,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, return PC_BOUNDS_NOT_PRESENT; } - /* read_partial_die has also the strict LOW < HIGH requirement. */ + /* partial_die_info::read has also the strict LOW < HIGH requirement. */ if (high <= low) return PC_BOUNDS_INVALID; @@ -18316,8 +18317,8 @@ load_partial_dies (const struct die_reader_specs *reader, struct partial_die_info pdi ((sect_offset) (info_ptr - reader->buffer), abbrev); - info_ptr = read_partial_die (reader, &pdi, abbrev, - (const gdb_byte *) info_ptr + bytes_read); + info_ptr = pdi.read (reader, abbrev, + (const gdb_byte *) info_ptr + bytes_read); /* This two-pass algorithm for processing partial symbols has a high cost in cache pressure. Thus, handle some simple cases @@ -18496,24 +18497,22 @@ partial_die_info::partial_die_info (sect_offset sect_off_, /* Read a minimal amount of information into the minimal die structure. */ -static const gdb_byte * -read_partial_die (const struct die_reader_specs *reader, - struct partial_die_info *part_die, - struct abbrev_info *abbrev, const gdb_byte *info_ptr) +const gdb_byte * +partial_die_info::read (const struct die_reader_specs *reader, + struct abbrev_info *abbrev, const gdb_byte *info_ptr) { struct dwarf2_cu *cu = reader->cu; struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_cu->dwarf2_per_objfile; - struct objfile *objfile = dwarf2_per_objfile->objfile; - const gdb_byte *buffer = reader->buffer; unsigned int i; - struct attribute attr; int has_low_pc_attr = 0; int has_high_pc_attr = 0; int high_pc_relative = 0; for (i = 0; i < abbrev->num_attrs; ++i) { + struct attribute attr; + info_ptr = read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr); /* Store the data if it is of an attribute we want to keep in a @@ -18521,7 +18520,7 @@ read_partial_die (const struct die_reader_specs *reader, switch (attr.name) { case DW_AT_name: - switch (part_die->tag) + switch (tag) { case DW_TAG_compile_unit: case DW_TAG_partial_unit: @@ -18532,12 +18531,16 @@ read_partial_die (const struct die_reader_specs *reader, case DW_TAG_enumerator: /* These tags always have simple identifiers already; no need to canonicalize them. */ - part_die->name = DW_STRING (&attr); + name = DW_STRING (&attr); break; default: - part_die->name - = dwarf2_canonicalize_name (DW_STRING (&attr), cu, - &objfile->per_bfd->storage_obstack); + { + struct objfile *objfile = dwarf2_per_objfile->objfile; + + name + = dwarf2_canonicalize_name (DW_STRING (&attr), cu, + &objfile->per_bfd->storage_obstack); + } break; } break; @@ -18547,16 +18550,16 @@ read_partial_die (const struct die_reader_specs *reader, assume they will be the same, and we only store the last one we see. */ if (cu->language == language_ada) - part_die->name = DW_STRING (&attr); - part_die->linkage_name = DW_STRING (&attr); + name = DW_STRING (&attr); + linkage_name = DW_STRING (&attr); break; case DW_AT_low_pc: has_low_pc_attr = 1; - part_die->lowpc = attr_value_as_address (&attr); + lowpc = attr_value_as_address (&attr); break; case DW_AT_high_pc: has_high_pc_attr = 1; - part_die->highpc = attr_value_as_address (&attr); + highpc = attr_value_as_address (&attr); if (cu->header.version >= 4 && attr_form_is_constant (&attr)) high_pc_relative = 1; break; @@ -18564,7 +18567,7 @@ read_partial_die (const struct die_reader_specs *reader, /* Support the .debug_loc offsets. */ if (attr_form_is_block (&attr)) { - part_die->d.locdesc = DW_BLOCK (&attr); + d.locdesc = DW_BLOCK (&attr); } else if (attr_form_is_section_offset (&attr)) { @@ -18577,20 +18580,20 @@ read_partial_die (const struct die_reader_specs *reader, } break; case DW_AT_external: - part_die->is_external = DW_UNSND (&attr); + is_external = DW_UNSND (&attr); break; case DW_AT_declaration: - part_die->is_declaration = DW_UNSND (&attr); + is_declaration = DW_UNSND (&attr); break; case DW_AT_type: - part_die->has_type = 1; + has_type = 1; break; case DW_AT_abstract_origin: case DW_AT_specification: case DW_AT_extension: - part_die->has_specification = 1; - part_die->spec_offset = dwarf2_get_ref_die_offset (&attr); - part_die->spec_is_dwz = (attr.form == DW_FORM_GNU_ref_alt + has_specification = 1; + spec_offset = dwarf2_get_ref_die_offset (&attr); + spec_is_dwz = (attr.form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz); break; case DW_AT_sibling: @@ -18601,6 +18604,7 @@ read_partial_die (const struct die_reader_specs *reader, _("ignoring absolute DW_AT_sibling")); else { + const gdb_byte *buffer = reader->buffer; sect_offset off = dwarf2_get_ref_die_offset (&attr); const gdb_byte *sibling_ptr = buffer + to_underlying (off); @@ -18610,14 +18614,14 @@ read_partial_die (const struct die_reader_specs *reader, else if (sibling_ptr > reader->buffer_end) dwarf2_section_buffer_overflow_complaint (reader->die_section); else - part_die->sibling = sibling_ptr; + sibling = sibling_ptr; } break; case DW_AT_byte_size: - part_die->has_byte_size = 1; + has_byte_size = 1; break; case DW_AT_const_value: - part_die->has_const_value = 1; + has_const_value = 1; break; case DW_AT_calling_convention: /* DWARF doesn't provide a way to identify a program's source-level @@ -18636,25 +18640,25 @@ read_partial_die (const struct die_reader_specs *reader, compatibility. */ if (DW_UNSND (&attr) == DW_CC_program && cu->language == language_fortran) - part_die->main_subprogram = 1; + main_subprogram = 1; break; case DW_AT_inline: if (DW_UNSND (&attr) == DW_INL_inlined || DW_UNSND (&attr) == DW_INL_declared_inlined) - part_die->may_be_inlined = 1; + may_be_inlined = 1; break; case DW_AT_import: - if (part_die->tag == DW_TAG_imported_unit) + if (tag == DW_TAG_imported_unit) { - part_die->d.sect_off = dwarf2_get_ref_die_offset (&attr); - part_die->is_dwz = (attr.form == DW_FORM_GNU_ref_alt + d.sect_off = dwarf2_get_ref_die_offset (&attr); + is_dwz = (attr.form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz); } break; case DW_AT_main_subprogram: - part_die->main_subprogram = DW_UNSND (&attr); + main_subprogram = DW_UNSND (&attr); break; default: @@ -18663,7 +18667,7 @@ read_partial_die (const struct die_reader_specs *reader, } if (high_pc_relative) - part_die->highpc += part_die->lowpc; + highpc += lowpc; if (has_low_pc_attr && has_high_pc_attr) { @@ -18675,31 +18679,33 @@ read_partial_die (const struct die_reader_specs *reader, labels are not in the output, so the relocs get a value of 0. If this is a discarded function, mark the pc bounds as invalid, so that GDB will ignore it. */ - if (part_die->lowpc == 0 && !dwarf2_per_objfile->has_section_at_zero) + if (lowpc == 0 && !dwarf2_per_objfile->has_section_at_zero) { + struct objfile *objfile = dwarf2_per_objfile->objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); complaint (&symfile_complaints, _("DW_AT_low_pc %s is zero " "for DIE at 0x%x [in module %s]"), - paddress (gdbarch, part_die->lowpc), - to_underlying (part_die->sect_off), objfile_name (objfile)); + paddress (gdbarch, lowpc), + to_underlying (sect_off), objfile_name (objfile)); } /* dwarf2_get_pc_bounds has also the strict low < high requirement. */ - else if (part_die->lowpc >= part_die->highpc) + else if (lowpc >= highpc) { + struct objfile *objfile = dwarf2_per_objfile->objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); complaint (&symfile_complaints, _("DW_AT_low_pc %s is not < DW_AT_high_pc %s " "for DIE at 0x%x [in module %s]"), - paddress (gdbarch, part_die->lowpc), - paddress (gdbarch, part_die->highpc), - to_underlying (part_die->sect_off), + paddress (gdbarch, lowpc), + paddress (gdbarch, highpc), + to_underlying (sect_off), objfile_name (objfile)); } else - part_die->has_pc_info = 1; + has_pc_info = 1; } return info_ptr;