if (reader.comp_unit_die == nullptr)
return;
- switch (reader.comp_unit_die->tag)
- {
- case DW_TAG_compile_unit:
- this_cu->set_unit_type (DW_UT_compile);
- break;
- case DW_TAG_partial_unit:
- this_cu->set_unit_type (DW_UT_partial);
- break;
- case DW_TAG_type_unit:
- this_cu->set_unit_type (DW_UT_type);
- break;
- default:
- error (_("Dwarf Error: unexpected tag '%s' at offset %s [in module %s]"),
- dwarf_tag_name (reader.comp_unit_die->tag),
- sect_offset_str (reader.cu->per_cu->sect_off),
- objfile_name (per_objfile->objfile));
- }
-
if (reader.dummy_p)
{
/* Nothing. */
else
lang = pretend_language;
- cu->per_cu->set_lang (lang);
cu->language_defn = language_def (lang);
+
+ switch (comp_unit_die->tag)
+ {
+ case DW_TAG_compile_unit:
+ cu->per_cu->set_unit_type (DW_UT_compile);
+ break;
+ case DW_TAG_partial_unit:
+ cu->per_cu->set_unit_type (DW_UT_partial);
+ break;
+ case DW_TAG_type_unit:
+ cu->per_cu->set_unit_type (DW_UT_type);
+ break;
+ default:
+ error (_("Dwarf Error: unexpected tag '%s' at offset %s"),
+ dwarf_tag_name (comp_unit_die->tag),
+ sect_offset_str (cu->per_cu->sect_off));
+ }
+
+ cu->per_cu->set_lang (lang);
}
/* See read.h. */
void set_lang (enum language lang)
{
- /* We'd like to be more strict here, similar to what is done in
- set_unit_type, but currently a partial unit can go from unknown to
- minimal to ada to c. */
- if (m_lang != lang)
+ if (unit_type () == DW_UT_partial)
+ return;
+ if (m_lang == language_unknown)
+ /* Set if not set already. */
m_lang = lang;
+ else
+ /* If already set, verify that it's the same value. */
+ gdb_assert (m_lang == lang);
}
/* Free any cached file names. */
set pattern1 \
[multi_line \
"Reading symbols from \[^\r\n\]+" \
- "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex \\\[\[^\r\n\]+\\\]"]
+ "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"]
# This pattern is hit when GDB does use -readnow (e.g. running with
# --target_board=readnow).
[multi_line \
"Reading symbols from \[^\r\n\]+" \
"Expanding full symbols from \[^\r\n\]+" \
- "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex \\\[\[^\r\n\]+\\\]"]
+ "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"]
# Load the executable, we expect an error from the DWARF parser.
gdb_test_multiple "file $binfile" "file $testfile" {