X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fdwarf2read.c;h=b7933de49cfbccb00155d77a1800fdae9b29593a;hb=edb0470b99a9f399ccb5d666173c4315f6cb02c0;hp=14cae6ef82685d29c5d997ebe876a2726baf97e2;hpb=c1ec8cea7ff53eb76cb7c354b813c67fde755409;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 14cae6ef82..b7933de49c 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -3415,15 +3415,15 @@ find_slot_in_mapped_hash (struct mapped_index *index, const char *name, Returns 1 if all went well, 0 otherwise. */ static bool -read_index_from_section (struct objfile *objfile, - const char *filename, - bool deprecated_ok, - struct dwarf2_section_info *section, - struct mapped_index *map, - const gdb_byte **cu_list, - offset_type *cu_list_elements, - const gdb_byte **types_list, - offset_type *types_list_elements) +read_gdb_index_from_section (struct objfile *objfile, + const char *filename, + bool deprecated_ok, + struct dwarf2_section_info *section, + struct mapped_index *map, + const gdb_byte **cu_list, + offset_type *cu_list_elements, + const gdb_byte **types_list, + offset_type *types_list_elements) { const gdb_byte *addr; offset_type version; @@ -3532,7 +3532,7 @@ to use the section anyway."), elements of all the CUs and return 1. Otherwise, return 0. */ static int -dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile) +dwarf2_read_gdb_index (struct dwarf2_per_objfile *dwarf2_per_objfile) { const gdb_byte *cu_list, *types_list, *dwz_list = NULL; offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; @@ -3540,11 +3540,11 @@ dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile) struct objfile *objfile = dwarf2_per_objfile->objfile; std::unique_ptr map (new struct mapped_index); - if (!read_index_from_section (objfile, objfile_name (objfile), - use_deprecated_index_sections, - &dwarf2_per_objfile->gdb_index, map.get (), - &cu_list, &cu_list_elements, - &types_list, &types_list_elements)) + if (!read_gdb_index_from_section (objfile, objfile_name (objfile), + use_deprecated_index_sections, + &dwarf2_per_objfile->gdb_index, map.get (), + &cu_list, &cu_list_elements, + &types_list, &types_list_elements)) return 0; /* Don't use the index if it's empty. */ @@ -3560,12 +3560,12 @@ dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile) const gdb_byte *dwz_types_ignore; offset_type dwz_types_elements_ignore; - if (!read_index_from_section (objfile, bfd_get_filename (dwz->dwz_bfd), - 1, - &dwz->gdb_index, &dwz_map, - &dwz_list, &dwz_list_elements, - &dwz_types_ignore, - &dwz_types_elements_ignore)) + if (!read_gdb_index_from_section (objfile, + bfd_get_filename (dwz->dwz_bfd), 1, + &dwz->gdb_index, &dwz_map, + &dwz_list, &dwz_list_elements, + &dwz_types_ignore, + &dwz_types_elements_ignore)) { warning (_("could not read '.gdb_index' section from %s; skipping"), bfd_get_filename (dwz->dwz_bfd)); @@ -6198,7 +6198,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) return true; } - if (dwarf2_read_index (dwarf2_per_objfile)) + if (dwarf2_read_gdb_index (dwarf2_per_objfile)) { *index_kind = dw_index_kind::GDB_INDEX; return true; @@ -6308,6 +6308,10 @@ read_comp_unit_head (struct comp_unit_head *cu_header, cu_header->offset_size = (bytes_read == 4) ? 4 : 8; info_ptr += bytes_read; cu_header->version = read_2_bytes (abfd, info_ptr); + if (cu_header->version < 2 || cu_header->version > 5) + error (_("Dwarf Error: wrong version in compilation unit header " + "(is %d, should be 2, 3, 4 or 5) [in module %s]"), + cu_header->version, filename); info_ptr += 2; if (cu_header->version < 5) switch (section_kind) @@ -6410,11 +6414,6 @@ error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile, { const char *filename = get_section_file_name (section); - if (header->version < 2 || header->version > 5) - error (_("Dwarf Error: wrong version in compilation unit header " - "(is %d, should be 2, 3, 4 or 5) [in module %s]"), header->version, - filename); - if (to_underlying (header->abbrev_sect_off) >= dwarf2_section_size (dwarf2_per_objfile->objfile, abbrev_section)) error (_("Dwarf Error: bad offset (%s) in compilation unit header " @@ -9762,8 +9761,6 @@ fixup_go_packaging (struct dwarf2_cu *cu) saved_package_name); struct symbol *sym; - TYPE_TAG_NAME (type) = TYPE_NAME (type); - sym = allocate_symbol (objfile); SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack); SYMBOL_SET_NAMES (sym, saved_package_name, @@ -10219,19 +10216,13 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu) static void process_cu_includes (struct dwarf2_per_objfile *dwarf2_per_objfile) { - int ix; - struct dwarf2_per_cu_data *iter; - - for (ix = 0; - VEC_iterate (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, - ix, iter); - ++ix) + for (dwarf2_per_cu_data *iter : dwarf2_per_objfile->just_read_cus) { if (! iter->is_debug_types) compute_compunit_symtab_includes (iter); } - VEC_free (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus); + dwarf2_per_objfile->just_read_cus.clear (); } /* Generate full symbol information for PER_CU, whose DIEs have @@ -10339,7 +10330,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu, } /* Push it for inclusion processing later. */ - VEC_safe_push (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, per_cu); + dwarf2_per_objfile->just_read_cus.push_back (per_cu); } /* Generate full symbol information for type unit PER_CU, whose DIEs have @@ -11112,10 +11103,10 @@ read_namespace_alias (struct die_info *die, struct dwarf2_cu *cu) static struct using_direct ** using_directives (enum language language) { - if (language == language_ada && context_stack_depth == 0) - return &global_using_directives; + if (language == language_ada && outermost_context_p ()) + return get_global_using_directives (); else - return &local_using_directives; + return get_local_using_directives (); } /* Read the import statement specified by the given die and record it. */ @@ -13730,7 +13721,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) when we finish processing a function scope, we may need to go back to building a containing block's symbol lists. */ local_symbols = newobj->locals; - local_using_directives = newobj->local_using_directives; + set_local_using_directives (newobj->local_using_directives); /* If we've finished processing a top-level function, subsequent symbols go in the file symbol list. */ @@ -13788,7 +13779,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) inherit_abstract_dies (die, cu); newobj = pop_context (); - if (local_symbols != NULL || local_using_directives != NULL) + if (local_symbols != NULL || (*get_local_using_directives ()) != NULL) { struct block *block = finish_block (0, &local_symbols, newobj->old_blocks, NULL, @@ -13807,7 +13798,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) dwarf2_record_block_ranges (die, block, baseaddr, cu); } local_symbols = newobj->locals; - local_using_directives = newobj->local_using_directives; + set_local_using_directives (newobj->local_using_directives); } /* Read in DW_TAG_call_site and insert it to CU->call_site_htab. */ @@ -15036,7 +15027,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, SET_FIELD_BITPOS (*fp, offset * bits_per_byte); FIELD_BITSIZE (*fp) = 0; FIELD_TYPE (*fp) = die_type (die, cu); - FIELD_NAME (*fp) = type_name_no_tag (fp->type); + FIELD_NAME (*fp) = TYPE_NAME (fp->type); } else if (die->tag == DW_TAG_variant_part) { @@ -15653,18 +15644,13 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (get_die_type (die, cu) != NULL) return get_die_type (die, cu); - TYPE_TAG_NAME (type) = full_name; - if (die->tag == DW_TAG_structure_type - || die->tag == DW_TAG_class_type) - TYPE_NAME (type) = TYPE_TAG_NAME (type); + TYPE_NAME (type) = full_name; } else { /* The name is already allocated along with this objfile, so we don't need to duplicate it for the type. */ - TYPE_TAG_NAME (type) = name; - if (die->tag == DW_TAG_class_type) - TYPE_NAME (type) = TYPE_TAG_NAME (type); + TYPE_NAME (type) = name; } } @@ -15944,8 +15930,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) if (i < TYPE_N_BASECLASSES (t)) complaint (_("virtual function table pointer " "not found when defining class '%s'"), - TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : - ""); + TYPE_NAME (type) ? TYPE_NAME (type) : ""); } else { @@ -16135,7 +16120,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) TYPE_CODE (type) = TYPE_CODE_ENUM; name = dwarf2_full_name (NULL, die, cu); if (name != NULL) - TYPE_TAG_NAME (type) = name; + TYPE_NAME (type) = name; attr = dwarf2_attr (die, DW_AT_type, cu); if (attr != NULL) @@ -16686,7 +16671,6 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu) /* Create the type. */ type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name); - TYPE_TAG_NAME (type) = TYPE_NAME (type); return set_die_type (die, type, cu); } @@ -16751,9 +16735,6 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu) sect_offset_str (die->sect_off)); type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name); - /* determine_prefix uses TYPE_TAG_NAME. */ - TYPE_TAG_NAME (type) = TYPE_NAME (type); - return set_die_type (die, type, cu); } @@ -18236,7 +18217,7 @@ load_partial_dies (const struct die_reader_specs *reader, /* The exception for DW_TAG_typedef with has_children above is a workaround of GCC PR debug/47510. In the case of this complaint - type_name_no_tag_or_error will error on such types later. + type_name_or_error will error on such types later. GDB skipped children of DW_TAG_typedef by the shortcut above and then it could not find the child DIEs referenced later, this is checked @@ -20323,11 +20304,11 @@ public: we're processing the end of a sequence. */ void record_line (bool end_sequence); - /* Check address and if invalid nop-out the rest of the lines in this - sequence. */ + /* Check ADDRESS is zero and less than UNRELOCATED_LOWPC and if true + nop-out rest of the lines in this sequence. */ void check_line_address (struct dwarf2_cu *cu, const gdb_byte *line_ptr, - CORE_ADDR lowpc, CORE_ADDR address); + CORE_ADDR unrelocated_lowpc, CORE_ADDR address); void handle_set_discriminator (unsigned int discriminator) { @@ -20671,14 +20652,14 @@ lnp_state_machine::lnp_state_machine (gdbarch *arch, line_header *lh, void lnp_state_machine::check_line_address (struct dwarf2_cu *cu, const gdb_byte *line_ptr, - CORE_ADDR lowpc, CORE_ADDR address) + CORE_ADDR unrelocated_lowpc, CORE_ADDR address) { - /* If address < lowpc then it's not a usable value, it's outside the - pc range of the CU. However, we restrict the test to only address - values of zero to preserve GDB's previous behaviour which is to - handle the specific case of a function being GC'd by the linker. */ + /* If ADDRESS < UNRELOCATED_LOWPC then it's not a usable value, it's outside + the pc range of the CU. However, we restrict the test to only ADDRESS + values of zero to preserve GDB's previous behaviour which is to handle + the specific case of a function being GC'd by the linker. */ - if (address == 0 && address < lowpc) + if (address == 0 && address < unrelocated_lowpc) { /* This line table is for a function which has been GCd by the linker. Ignore it. PR gdb/12528 */ @@ -20772,7 +20753,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu, line_ptr += bytes_read; state_machine.check_line_address (cu, line_ptr, - lowpc, address); + lowpc - baseaddr, address); state_machine.handle_set_address (baseaddr, address); } break; @@ -21045,9 +21026,6 @@ dwarf2_start_symtab (struct dwarf2_cu *cu, record_debugformat ("DWARF 2"); record_producer (cu->producer); - /* We assume that we're processing GCC output. */ - processing_gcc_compilation = 2; - cu->processing_has_namespace_info = 0; return cust; @@ -21375,7 +21353,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, when we do not have enough information to show inlined frames; pretend it's a local variable in that case so that the user can still see it. */ - if (context_stack_depth > 0 + if (!outermost_context_p () && context_stack[context_stack_depth - 1].name != NULL) SYMBOL_IS_ARGUMENT (sym) = 1; attr = dwarf2_attr (die, DW_AT_location, cu); @@ -22183,18 +22161,18 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) DW_TAG_namespace DIEs with a name of "::" for the global namespace. Work around this problem here. */ if (cu->language == language_cplus - && strcmp (TYPE_TAG_NAME (parent_type), "::") == 0) + && strcmp (TYPE_NAME (parent_type), "::") == 0) return ""; /* We give a name to even anonymous namespaces. */ - return TYPE_TAG_NAME (parent_type); + return TYPE_NAME (parent_type); case DW_TAG_class_type: case DW_TAG_interface_type: case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_module: parent_type = read_type_die (parent, cu); - if (TYPE_TAG_NAME (parent_type) != NULL) - return TYPE_TAG_NAME (parent_type); + if (TYPE_NAME (parent_type) != NULL) + return TYPE_NAME (parent_type); else /* An anonymous structure is only allowed non-static data members; no typedefs, no member functions, et cetera. @@ -22219,8 +22197,8 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) parent_type = read_type_die (parent, cu); if (TYPE_DECLARED_CLASS (parent_type)) { - if (TYPE_TAG_NAME (parent_type) != NULL) - return TYPE_TAG_NAME (parent_type); + if (TYPE_NAME (parent_type) != NULL) + return TYPE_NAME (parent_type); return ""; } /* Fall through. */ @@ -25015,13 +24993,13 @@ free_one_cached_comp_unit (struct dwarf2_per_cu_data *target_per_cu) } } -/* Release all extra memory associated with OBJFILE. */ +/* Cleanup function for the dwarf2_per_objfile data. */ -void -dwarf2_free_objfile (struct objfile *objfile) +static void +dwarf2_free_objfile (struct objfile *objfile, void *datum) { struct dwarf2_per_objfile *dwarf2_per_objfile - = get_dwarf2_per_objfile (objfile); + = static_cast (datum); delete dwarf2_per_objfile; } @@ -25343,8 +25321,8 @@ show_check_physname (struct ui_file *file, int from_tty, void _initialize_dwarf2_read (void) { - - dwarf2_objfile_data_key = register_objfile_data (); + dwarf2_objfile_data_key + = register_objfile_data_with_cleanup (nullptr, dwarf2_free_objfile); add_prefix_cmd ("dwarf", class_maintenance, set_dwarf_cmd, _("\ Set DWARF specific variables.\n\