diff options
Diffstat (limited to 'gdb/dwarf2/read.c')
-rw-r--r-- | gdb/dwarf2/read.c | 218 |
1 files changed, 27 insertions, 191 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f31ddb5..821f761 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -153,9 +153,6 @@ static int dwarf2_locexpr_block_index; static int dwarf2_loclist_block_index; static int ada_block_index; -static bool producer_is_gas_lt_2_38 (struct dwarf2_cu *cu); -static bool producer_is_gas_ge_2_39 (struct dwarf2_cu *cu); - /* Size of .debug_loclists section header for 32-bit DWARF format. */ #define LOCLIST_HEADER_SIZE32 12 @@ -1175,7 +1172,6 @@ static void queue_and_load_all_dwo_tus (dwarf2_cu *cu); static void process_cu_includes (dwarf2_per_objfile *per_objfile); -static void check_producer (struct dwarf2_cu *cu); /* Various complaints about symbol reading that don't abort the process. */ @@ -5558,8 +5554,6 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) if (cust != NULL) { - int gcc_4_minor = producer_is_gcc_ge_4 (cu->producer); - /* Set symtab language to language from DW_AT_language. If the compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ @@ -5579,13 +5573,13 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) Still one can confuse GDB by using non-standard GCC compilation options - this waits on GCC PR other/32998 (-frecord-gcc-switches). */ - if (cu->has_loclist && gcc_4_minor >= 5) + /* Note that this code traditionally did not accept non-GCC + compilers; that is preserved but seems potentially wrong. */ + if (cu->has_loclist && cu->producer_is_gcc () + && !cu->producer_is_gcc_lt_4_5 ()) cust->set_locations_valid (true); - int major, minor; - if (cu->producer != nullptr - && producer_is_gcc (cu->producer, &major, &minor) - && (major < 4 || (major == 4 && minor < 5))) + if (cu->producer_is_gcc_lt_4_5 ()) /* Don't trust gcc < 4.5.x. */ cust->set_epilogue_unwind_valid (false); else @@ -6574,55 +6568,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) &objfile->objfile_obstack); } -/* ICC<14 does not output the required DW_AT_declaration on incomplete - types, but gives them a size of zero. Starting with version 14, - ICC is compatible with GCC. */ - -static bool -producer_is_icc_lt_14 (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_icc_lt_14; -} - -/* ICC generates a DW_AT_type for C void functions. This was observed on - ICC 14.0.5.212, and appears to be against the DWARF spec (V5 3.3.2) - which says that void functions should not have a DW_AT_type. */ - -static bool -producer_is_icc (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_icc; -} - -/* Check for possibly missing DW_AT_comp_dir with relative .debug_line - directory paths. GCC SVN r127613 (new option -fdebug-prefix-map) fixed - this, it was first present in GCC release 4.3.0. */ - -static bool -producer_is_gcc_lt_4_3 (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_gcc_lt_4_3; -} - -/* See dwarf2/read.h. */ -bool -producer_is_clang (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_clang; -} - static file_and_directory & find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu) { @@ -6635,7 +6580,7 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu) dwarf2_string_attr (die, DW_AT_comp_dir, cu)); if (res.get_comp_dir () == nullptr - && producer_is_gcc_lt_4_3 (cu) + && cu->producer_is_gcc_lt_4_3 () && res.get_name () != nullptr && IS_ABSOLUTE_PATH (res.get_name ())) { @@ -6776,7 +6721,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) implicitly prefixing it with the compilation dir. Work around this by prefixing it with the source dir instead. */ if (cu->header.version == 5 && !IS_ABSOLUTE_PATH (fnd.get_name ()) - && producer_is_gas_lt_2_38 (cu)) + && cu->producer_is_gas_lt_2_38 ()) { attr = dwarf2_attr (die, DW_AT_stmt_list, cu); if (attr != nullptr && attr->form_is_unsigned ()) @@ -9252,7 +9197,7 @@ fixup_low_high_pc (struct dwarf2_cu *cu, struct die_info *die, CORE_ADDR *low_pc struct gdbarch *gdbarch = objfile->arch (); if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm - && producer_is_gas_ge_2_39 (cu)) + && cu->producer_is_gas_ge_2_39 ()) { /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low_pc attribute with the thumb bit set (PR gas/31115). Work around this. */ @@ -10792,110 +10737,6 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, dwarf2_record_block_entry_pc (die, block, cu); } -/* Check whether the producer field indicates either of GCC < 4.6, or the - Intel C/C++ compiler, and cache the result in CU. */ - -static void -check_producer (struct dwarf2_cu *cu) -{ - int major, minor; - - if (cu->producer == NULL) - { - /* For unknown compilers expect their behavior is DWARF version - compliant. - - GCC started to support .debug_types sections by -gdwarf-4 since - gcc-4.5.x. As the .debug_types sections are missing DW_AT_producer - for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4 - combination. gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility - interpreted incorrectly by GDB now - GCC PR debug/48229. */ - } - else if (producer_is_gcc (cu->producer, &major, &minor)) - { - cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6); - cu->producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3); - cu->producer_is_gcc_11 = major == 11; - } - else if (producer_is_icc (cu->producer, &major, &minor)) - { - cu->producer_is_icc = true; - cu->producer_is_icc_lt_14 = major < 14; - } - else if (startswith (cu->producer, "CodeWarrior S12/L-ISA")) - cu->producer_is_codewarrior = true; - else if (producer_is_clang (cu->producer, &major, &minor)) - cu->producer_is_clang = true; - else if (producer_is_gas (cu->producer, &major, &minor)) - { - cu->producer_is_gas_lt_2_38 = major < 2 || (major == 2 && minor < 38); - cu->producer_is_gas_2_39 = major == 2 && minor == 39; - cu->producer_is_gas_ge_2_40 = major > 2 || (major == 2 && minor >= 40); - } - else - { - /* For other non-GCC compilers, expect their behavior is DWARF version - compliant. */ - } - - cu->checked_producer = true; -} - -/* Check for GCC PR debug/45124 fix which is not present in any G++ version up - to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed - during 4.6.0 experimental. */ - -static bool -producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_gxx_lt_4_6; -} - - -/* Codewarrior (at least as of version 5.0.40) generates dwarf line information - with incorrect is_stmt attributes. */ - -static bool -producer_is_codewarrior (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_codewarrior; -} - -static bool -producer_is_gas_lt_2_38 (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_gas_lt_2_38; -} - -static bool -producer_is_gas_2_39 (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_gas_2_39; -} - -/* Return true if CU is produced by GAS 2.39 or later. */ - -static bool -producer_is_gas_ge_2_39 (struct dwarf2_cu *cu) -{ - if (!cu->checked_producer) - check_producer (cu); - - return cu->producer_is_gas_2_39 || cu->producer_is_gas_ge_2_40; -} - /* Return the accessibility of DIE, as given by DW_AT_accessibility. If that attribute is not available, return the appropriate default. */ @@ -10915,7 +10756,7 @@ dwarf2_access_attribute (struct die_info *die, struct dwarf2_cu *cu) plongest (value)); } - if (cu->header.version < 3 || producer_is_gxx_lt_4_6 (cu)) + if (cu->header.version < 3 || cu->producer_is_gxx_lt_4_6 ()) { /* The default DWARF 2 accessibility for members is public, the default accessibility for inheritance is private. */ @@ -11008,7 +10849,7 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu, Negative DW_AT_data_member_location https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378 */ - if (offset == -1 && cu->producer_is_gcc_11) + if (offset == -1 && cu->producer_is_gcc_11 ()) { complaint (_("DW_AT_data_member_location value of -1, assuming 0")); offset = 0; @@ -12141,7 +11982,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) maybe_set_alignment (cu, die, type); - if (producer_is_icc_lt_14 (cu) && (type->length () == 0)) + if (cu->producer_is_icc_lt_14 () && type->length () == 0) { /* ICC<14 does not output the required DW_AT_declaration on incomplete types, but gives them a size of zero. */ @@ -12153,7 +11994,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (die_is_declaration (die, cu)) type->set_is_stub (true); else if (attr == NULL && die->child == NULL - && producer_is_realview (cu->producer)) + && cu->producer_is_realview ()) /* RealView does not output the required DW_AT_declaration on incomplete types. */ type->set_is_stub (true); @@ -12434,8 +12275,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) set_type_vptr_fieldno (type, TYPE_VPTR_FIELDNO (t)); } } - else if (cu->producer - && startswith (cu->producer, "IBM(R) XL C/C++ Advanced Edition")) + else if (cu->producer_is_xlc ()) { /* The IBM XLC compiler does not provide direct indication of the containing type, but the vtable pointer is @@ -13264,8 +13104,7 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu) FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need version checking. */ - if (cu->lang () == language_fortran - && cu->producer && strstr (cu->producer, "GNU F77")) + if (cu->lang () == language_fortran && cu->producer_is_gf77 ()) { return DW_ORD_row_major; } @@ -14018,7 +13857,7 @@ prototyped_function_p (struct die_info *die, struct dwarf2_cu *cu) prototyped and unprototyped functions; default to prototyped, since that is more common in modern code (and RealView warns about unprototyped functions). */ - if (producer_is_realview (cu->producer)) + if (cu->producer_is_realview ()) return 1; return 0; @@ -14050,7 +13889,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) && !type->is_stub () && die->child == nullptr && (cu->per_cu->version () == 2 - || producer_is_gas_2_39 (cu))) + || cu->producer_is_gas_2_39 ())) { /* Work around PR gas/29517, pretend we have an DW_TAG_unspecified_type return type. */ @@ -14077,7 +13916,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) && is_valid_DW_AT_calling_convention_for_subroutine (attr->constant_value (0))) TYPE_CALLING_CONVENTION (ftype) = (enum dwarf_calling_convention) attr->constant_value (0); - else if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL")) + else if (cu->producer_is_xlc_opencl ()) TYPE_CALLING_CONVENTION (ftype) = DW_CC_GDB_IBM_OpenCL; else TYPE_CALLING_CONVENTION (ftype) = DW_CC_normal; @@ -14197,7 +14036,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = objfile->arch (); struct type *target_type = die_type (die, cu); - if (gdbarch_dwarf2_omit_typedef_p (gdbarch, target_type, cu->producer, name)) + if (gdbarch_dwarf2_omit_typedef_p (gdbarch, target_type, + cu->get_producer (), name)) { /* The long double is defined as a base type in C. GCC creates a long double typedef with target-type _Float128 for the long double to @@ -14546,7 +14386,7 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, int bits, int unsigned_p, /* Versions of Intel's C Compiler generate an integer type called "void" instead of using DW_TAG_unspecified_type. This has been seen on at least versions 14, 17, and 18. */ - if (bits == 0 && producer_is_icc (cu) && name != nullptr + if (bits == 0 && cu->producer_is_icc () && name != nullptr && strcmp (name, "void") == 0) type = builtin_type (objfile)->builtin_void; else @@ -17902,7 +17742,7 @@ lnp_state_machine::record_line (bool end_sequence) if (!end_sequence && !ignore_this_line) { linetable_entry_flags lte_flags = m_flags; - if (producer_is_codewarrior (m_cu)) + if (m_cu->producer_is_codewarrior ()) lte_flags |= LEF_IS_STMT; if (dwarf_record_line_p (m_cu, m_line, m_last_line, @@ -21231,22 +21071,20 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, if (comp_unit_die == nullptr) { + cu->set_producer (nullptr); cu->language_defn = language_def (pretend_language); cu->per_cu->set_unit_type (DW_UT_compile); cu->per_cu->set_lang (pretend_language, (dwarf_source_language) 0); return; } - cu->producer = dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu); - /* Re-check if needed. */ - cu->checked_producer = false; + cu->set_producer (dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu)); /* Set the language we're debugging. */ attr = dwarf2_attr (comp_unit_die, DW_AT_language, cu); enum language lang; dwarf_source_language dw_lang = (dwarf_source_language) 0; - if (cu->producer != nullptr - && strstr (cu->producer, "IBM XL C for OpenCL") != NULL) + if (cu->producer_is_xlc_opencl ()) { /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not standardised yet. As a workaround for the @@ -21255,8 +21093,7 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, lang = language_opencl; dw_lang = DW_LANG_OpenCL; } - else if (cu->producer != nullptr - && strstr (cu->producer, "GNU Go ") != NULL) + else if (cu->producer_is_ggo ()) { /* Similar hack for Go. */ lang = language_go; @@ -21275,10 +21112,9 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, /* Initialize the lto_artificial field. */ attr = dwarf2_attr (comp_unit_die, DW_AT_name, cu); if (attr != nullptr - && cu->producer != nullptr + && cu->producer_is_gcc () && attr->as_string () != nullptr - && strcmp (attr->as_string (), "<artificial>") == 0 - && producer_is_gcc (cu->producer, nullptr, nullptr)) + && strcmp (attr->as_string (), "<artificial>") == 0) cu->per_cu->lto_artificial = true; switch (comp_unit_die->tag) |