#include "dwarf2/read.h"
#include "dwarf2/section.h"
#include "dwarf2/stringify.h"
+#include "dwarf2/error.h"
/* See comp-unit-head.h. */
info_ptr += bytes_read;
unsigned version = read_2_bytes (abfd, info_ptr);
if (version < 2 || version > 5)
- error (_("Dwarf Error: wrong version in compilation unit header "
- "(is %d, should be 2, 3, 4 or 5) [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "wrong version in compilation unit header "
+ "(is %d, should be 2, 3, 4 or 5) [in module %s]"),
version, filename);
cu_header->version = version;
info_ptr += 2;
case DW_UT_skeleton:
case DW_UT_split_compile:
if (section_kind != rcuh_kind::COMPILE)
- error (_("Dwarf Error: wrong unit_type in compilation unit header "
- "(is %s, should be %s) [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "wrong unit_type in compilation unit header "
+ "(is %s, should be %s) [in module %s]"),
dwarf_unit_type_name (cu_header->unit_type),
dwarf_unit_type_name (DW_UT_type), filename);
break;
section_kind = rcuh_kind::TYPE;
break;
default:
- error (_("Dwarf Error: wrong unit_type in compilation unit header "
- "(is %#04x, should be one of: %s, %s, %s, %s or %s) "
- "[in module %s]"), cu_header->unit_type,
- dwarf_unit_type_name (DW_UT_compile),
+ error (_(DWARF_ERROR_PREFIX
+ "wrong unit_type in compilation unit header "
+ "(is %#04x, should be one of: %s, %s, %s, %s or %s) "
+ "[in module %s]"),
+ cu_header->unit_type, dwarf_unit_type_name (DW_UT_compile),
dwarf_unit_type_name (DW_UT_skeleton),
dwarf_unit_type_name (DW_UT_split_compile),
dwarf_unit_type_name (DW_UT_type),
info_ptr += bytes_read;
cu_header->type_cu_offset_in_tu = (cu_offset) type_offset;
if (to_underlying (cu_header->type_cu_offset_in_tu) != type_offset)
- error (_("Dwarf Error: Too big type_offset in compilation unit "
- "header (is %s) [in module %s]"), plongest (type_offset),
- filename);
+ error (_(DWARF_ERROR_PREFIX
+ "Too big type_offset in compilation unit "
+ "header (is %s) [in module %s]"),
+ plongest (type_offset), filename);
}
return info_ptr;
if (to_underlying (header->abbrev_sect_off)
>= abbrev_section->get_size (per_objfile->objfile))
- error (_("Dwarf Error: bad offset (%s) in compilation unit header "
- "(offset %s + 6) [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad offset (%s) in compilation unit header "
+ "(offset %s + 6) [in module %s]"),
sect_offset_str (header->abbrev_sect_off),
sect_offset_str (header->sect_off),
filename);
avoid potential 32-bit overflow. */
if (((ULONGEST) header->sect_off + header->get_length_with_initial ())
> section->size)
- error (_("Dwarf Error: bad length (0x%x) in compilation unit header "
- "(offset %s + 0) [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad length (0x%x) in compilation unit header "
+ "(offset %s + 0) [in module %s]"),
header->get_length_without_initial (), sect_offset_str (header->sect_off),
filename);
}
#include "gdbsupport/thread-pool.h"
#include "run-on-main-thread.h"
#include "dwarf2/parent-map.h"
+#include "dwarf2/error.h"
/* When == 1, print basic high level tracing messages.
When > 1, be more verbose.
/* This is not an assert because it can be caused by bad debug info. */
if (sig_type->signature != cu->header.signature)
{
- error (_("Dwarf Error: signature mismatch %s vs %s while reading"
- " TU at offset %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "signature mismatch %s vs %s while reading TU at offset %s"
+ " [in module %s]"),
hex_string (sig_type->signature),
hex_string (cu->header.signature),
sect_offset_str (dwo_unit->sect_off),
std::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
if (!signature.has_value ())
- error (_("Dwarf Error: missing dwo_id for dwo_name %s"
+ error (_(DWARF_ERROR_PREFIX
+ "missing dwo_id for dwo_name %s"
" [in module %s]"),
dwo_name, bfd_get_filename (per_cu->per_bfd->obfd));
per_objfile->per_bfd->all_units.clear ();
/* See enhancement PR symtab/30838. */
- error (_("Dwarf Error: .debug_types section not supported in dwz file"));
+ error (_(DWARF_ERROR_PREFIX
+ ".debug_types section not supported in dwz file"));
}
}
= reader.abbrev_table->lookup_abbrev (abbrev_number);
if (!abbrev)
{
- error (_("Dwarf Error: Could not find abbrev number %d in %s"
- " at offset %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Could not find abbrev number %d in %s at offset %s"
+ " [in module %s]"),
abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU",
sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd));
}
goto skip_attribute;
default:
- error (_("Dwarf Error: Cannot handle %s "
- "in DWARF reader [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Cannot handle %s in DWARF reader [in module %s]"),
dwarf_form_name (form),
bfd_get_filename (abfd));
}
case DW_TAG_type_unit:
break;
default:
- error (_("Dwarf Error: unexpected tag '%s' at offset %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "unexpected tag '%s' at offset %s [in module %s]"),
dwarf_tag_name (cu->dies->tag),
sect_offset_str (cu->per_cu->sect_off),
objfile_name (per_objfile->objfile));
/* For now we don't handle imported units in type units. */
if (cu->per_cu->is_debug_types)
{
- error (_("Dwarf Error: DW_TAG_imported_unit is not"
- " supported in type units [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "DW_TAG_imported_unit is not supported in type units"
+ " [in module %s]"),
objfile_name (cu->per_objfile->objfile));
}
std::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
if (!signature.has_value ())
{
- complaint (_("Dwarf Error: debug entry at offset %s is missing"
- " its dwo_id [in module %s]"),
+ complaint (_(DWARF_ERROR_PREFIX
+ "debug entry at offset %s is missing its dwo_id"
+ " [in module %s]"),
sect_offset_str (sect_off), dwo_file->dwo_name.c_str ());
return;
}
if (version != 1 && version != 2 && version != 5)
{
- error (_("Dwarf Error: unsupported DWP file version (%s)"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "unsupported DWP file version (%s) [in module %s]"),
pulongest (version), dwp_file->name);
}
if (nr_slots != (nr_slots & -nr_slots))
{
- error (_("Dwarf Error: number of slots in DWP hash table (%s)"
- " is not power of 2 [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "number of slots in DWP hash table (%s) is not power of 2"
+ " [in module %s]"),
pulongest (nr_slots), dwp_file->name);
}
if (nr_columns < 2)
{
- error (_("Dwarf Error: bad DWP hash table, too few columns"
- " in section table [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, too few columns in section table"
+ " [in module %s]"),
dwp_file->name);
}
if (nr_columns > MAX_NR_V2_DWO_SECTIONS)
{
- error (_("Dwarf Error: bad DWP hash table, too many columns"
- " in section table [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, too many columns in section table"
+ " [in module %s]"),
dwp_file->name);
}
memset (ids, 255, sizeof_ids);
if (id < DW_SECT_MIN || id > DW_SECT_MAX)
{
- error (_("Dwarf Error: bad DWP hash table, bad section id %d"
- " in section table [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, bad section id %d in section table"
+ " [in module %s]"),
id, dwp_file->name);
}
if (ids_seen[id] != -1)
{
- error (_("Dwarf Error: bad DWP hash table, duplicate section"
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, duplicate section"
" id %d in section table [in module %s]"),
id, dwp_file->name);
}
+ (ids_seen[DW_SECT_TYPES] != -1))
!= 1)
{
- error (_("Dwarf Error: bad DWP hash table, missing/duplicate"
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, missing/duplicate"
" DWO info/types section [in module %s]"),
dwp_file->name);
}
/* Must have an abbrev section. */
if (ids_seen[DW_SECT_ABBREV] == -1)
{
- error (_("Dwarf Error: bad DWP hash table, missing DWO abbrev"
- " section [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, missing DWO abbrev section"
+ " [in module %s]"),
dwp_file->name);
}
htab->section_pool.v2.offsets = ids_ptr + sizeof (uint32_t) * nr_columns;
* nr_units * nr_columns))
> index_end)
{
- error (_("Dwarf Error: DWP index section is corrupt (too small)"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "DWP index section is corrupt (too small) [in module %s]"),
dwp_file->name);
}
}
if (nr_columns < 2)
{
- error (_("Dwarf Error: bad DWP hash table, too few columns"
- " in section table [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, too few columns in section table"
+ " [in module %s]"),
dwp_file->name);
}
if (nr_columns > MAX_NR_V5_DWO_SECTIONS)
{
- error (_("Dwarf Error: bad DWP hash table, too many columns"
- " in section table [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, too many columns in section table"
+ " [in module %s]"),
dwp_file->name);
}
memset (ids, 255, sizeof_ids);
if (id < DW_SECT_MIN || id > DW_SECT_MAX_V5)
{
- error (_("Dwarf Error: bad DWP hash table, bad section id %d"
- " in section table [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, bad section id %d in section table"
+ " [in module %s]"),
id, dwp_file->name);
}
if (ids_seen[id] != -1)
{
- error (_("Dwarf Error: bad DWP hash table, duplicate section"
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, duplicate section"
" id %d in section table [in module %s]"),
id, dwp_file->name);
}
/* Must have seen an info section. */
if (ids_seen[DW_SECT_INFO_V5] == -1)
{
- error (_("Dwarf Error: bad DWP hash table, missing/duplicate"
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, missing/duplicate"
" DWO info/types section [in module %s]"),
dwp_file->name);
}
/* Must have an abbrev section. */
if (ids_seen[DW_SECT_ABBREV_V5] == -1)
{
- error (_("Dwarf Error: bad DWP hash table, missing DWO abbrev"
- " section [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, missing DWO abbrev section"
+ " [in module %s]"),
dwp_file->name);
}
htab->section_pool.v5.offsets = ids_ptr + sizeof (uint32_t) * nr_columns;
* nr_units * nr_columns))
> index_end)
{
- error (_("Dwarf Error: DWP index section is corrupt (too small)"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "DWP index section is corrupt (too small) [in module %s]"),
dwp_file->name);
}
}
break;
if (section_nr >= dwp_file->num_sections)
{
- error (_("Dwarf Error: bad DWP hash table, section number too large"
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, section number too large"
" [in module %s]"),
dwp_file->name);
}
sectp = dwp_file->elf_sections[section_nr];
if (! locate_v1_virtual_dwo_sections (sectp, §ions))
{
- error (_("Dwarf Error: bad DWP hash table, invalid section found"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, invalid section found [in module %s]"),
dwp_file->name);
}
}
|| sections.info_or_types.empty ()
|| sections.abbrev.empty ())
{
- error (_("Dwarf Error: bad DWP hash table, missing DWO sections"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, missing DWO sections [in module %s]"),
dwp_file->name);
}
if (i == MAX_NR_V1_DWO_SECTIONS)
{
- error (_("Dwarf Error: bad DWP hash table, too many DWO sections"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, too many DWO sections [in module %s]"),
dwp_file->name);
}
if (sectp == NULL
|| offset + size > bfd_section_size (sectp))
{
- error (_("Dwarf Error: Bad DWP V2 or V5 section info, doesn't fit"
- " in section %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Bad DWP V2 or V5 section info, doesn't fit in section %s"
+ " [in module %s]"),
sectp ? bfd_section_name (sectp) : "<unknown>",
objfile_name (per_objfile->objfile));
}
hash = (hash + hash2) & mask;
}
- error (_("Dwarf Error: bad DWP hash table, lookup didn't terminate"
- " [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "bad DWP hash table, lookup didn't terminate [in module %s]"),
dwp_file->name);
}
/* Technically speaking, we should try to limp along, but this is
pretty bizarre. We use pulongest here because that's the established
portability solution (e.g, we cannot use %u for uint32_t). */
- error (_("Dwarf Error: DWP file CU version %s doesn't match"
- " TU version %s [in DWP file %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "DWP file CU version %s doesn't match TU version %s"
+ " [in DWP file %s]"),
pulongest (dwp_file->cus->version),
pulongest (dwp_file->tus->version), dwp_name.c_str ());
}
abbrev = reader->abbrev_table->lookup_abbrev (abbrev_number);
if (!abbrev)
- error (_("Dwarf Error: could not find abbrev number %d [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "could not find abbrev number %d [in module %s]"),
abbrev_number,
bfd_get_filename (abfd));
&bytes_read);
if (new_abbrev == nullptr)
- error (_("Dwarf Error: Unexpected null DIE at offset %s "
- "[in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Unexpected null DIE at offset %s [in module %s]"),
sect_offset_str (origin_offset),
bfd_get_filename (new_reader->abfd));
}
break;
default:
- error (_("Dwarf Error: Cannot handle %s in DWARF reader [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Cannot handle %s in DWARF reader [in module %s]"),
dwarf_form_name (form),
bfd_get_filename (abfd));
}
type_attr = dwarf2_attr (die, DW_AT_containing_type, cu);
if (!type_attr)
- error (_("Dwarf Error: Problem turning containing type into gdb type "
- "[in module %s]"), objfile_name (objfile));
+ error (_(DWARF_ERROR_PREFIX
+ "Problem turning containing type into gdb type "
+ "[in module %s]"),
+ objfile_name (objfile));
return lookup_die_type (die, type_attr, cu);
}
}
else
{
- complaint (_("Dwarf Error: Bad type attribute %s in DIE"
- " at %s [in module %s]"),
+ complaint (_(DWARF_ERROR_PREFIX
+ "Bad type attribute %s in DIE at %s [in module %s]"),
dwarf_attr_name (attr->name), sect_offset_str (die->sect_off),
objfile_name (objfile));
return build_error_marker_type (cu, die);
else
{
src_die->error_dump ();
- error (_("Dwarf Error: Expected reference attribute [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Expected reference attribute [in module %s]"),
objfile_name ((*ref_cu)->per_objfile->objfile));
}
|| cu->per_cu->is_dwz),
ref_cu);
if (!die)
- error (_("Dwarf Error: Cannot find DIE at %s referenced from DIE "
- "at %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Cannot find DIE at %s referenced from DIE at %s [in module %s]"),
sect_offset_str (sect_off), sect_offset_str (src_die->sect_off),
objfile_name (cu->per_objfile->objfile));
{
/* We shouldn't get here for a dummy CU, but don't crash on the user.
Instead just throw an error, not much else we can do. */
- error (_("Dwarf Error: Dummy CU at %s referenced [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Dummy CU at %s referenced [in module %s]"),
sect_offset_str (sect_off), objfile_name (objfile));
}
die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
if (!die)
- error (_("Dwarf Error: Cannot find DIE at %s referenced [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Cannot find DIE at %s referenced [in module %s]"),
sect_offset_str (sect_off), objfile_name (objfile));
attr = dwarf2_attr (die, DW_AT_location, cu);
else
{
if (!attr->form_is_block ())
- error (_("Dwarf Error: DIE at %s is neither DW_FORM_block* nor"
- " DW_FORM_exprloc [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "DIE at %s is neither DW_FORM_block* nor DW_FORM_exprloc"
+ " [in module %s]"),
sect_offset_str (sect_off), objfile_name (objfile));
struct dwarf_block *block = attr->as_block ();
{
/* We shouldn't get here for a dummy CU, but don't crash on the user.
Instead just throw an error, not much else we can do. */
- error (_("Dwarf Error: Dummy CU at %s referenced [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Dummy CU at %s referenced [in module %s]"),
sect_offset_str (sect_off), objfile_name (objfile));
}
die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
if (!die)
- error (_("Dwarf Error: Cannot find DIE at %s referenced [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Cannot find DIE at %s referenced [in module %s]"),
sect_offset_str (sect_off), objfile_name (objfile));
attr = dwarf2_attr (die, DW_AT_const_value, cu);
the debug info. */
if (sig_type == NULL)
{
- error (_("Dwarf Error: Cannot find signatured DIE %s referenced"
- " from DIE at %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Cannot find signatured DIE %s referenced from DIE at %s"
+ " [in module %s]"),
hex_string (signature), sect_offset_str (src_die->sect_off),
objfile_name ((*ref_cu)->per_objfile->objfile));
}
if (die == NULL)
{
src_die->error_dump ();
- error (_("Dwarf Error: Problem reading signatured DIE %s referenced"
- " from DIE at %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "Problem reading signatured DIE %s referenced from DIE at %s"
+ " [in module %s]"),
hex_string (signature), sect_offset_str (src_die->sect_off),
objfile_name ((*ref_cu)->per_objfile->objfile));
}
the debug info. */
if (sig_type == NULL)
{
- complaint (_("Dwarf Error: Cannot find signatured DIE %s referenced"
- " from DIE at %s [in module %s]"),
+ complaint (_(DWARF_ERROR_PREFIX
+ "Cannot find signatured DIE %s referenced from DIE at %s"
+ " [in module %s]"),
hex_string (signature), sect_offset_str (die->sect_off),
objfile_name (per_objfile->objfile));
return build_error_marker_type (cu, die);
type = read_type_die (type_die, type_cu);
if (type == NULL)
{
- complaint (_("Dwarf Error: Cannot build signatured type %s"
+ complaint (_(DWARF_ERROR_PREFIX
+ "Cannot build signatured type %s"
" referenced from DIE at %s [in module %s]"),
hex_string (signature), sect_offset_str (die->sect_off),
objfile_name (per_objfile->objfile));
}
else
{
- complaint (_("Dwarf Error: Problem reading signatured DIE %s referenced"
+ complaint (_(DWARF_ERROR_PREFIX
+ "Problem reading signatured DIE %s referenced"
" from DIE at %s [in module %s]"),
hex_string (signature), sect_offset_str (die->sect_off),
objfile_name (per_objfile->objfile));
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
- complaint (_("Dwarf Error: DW_AT_signature has bad form %s in DIE"
- " at %s [in module %s]"),
+ complaint (_(DWARF_ERROR_PREFIX
+ "DW_AT_signature has bad form %s in DIE at %s"
+ " [in module %s]"),
dwarf_form_name (attr->form), sect_offset_str (die->sect_off),
objfile_name (per_objfile->objfile));
return build_error_marker_type (cu, die);
if (this_cu->is_dwz != offset_in_dwz || this_cu->sect_off > sect_off)
{
if (low == 0 || this_cu->is_dwz != offset_in_dwz)
- error (_("Dwarf Error: could not find CU containing "
- "offset %s [in module %s]"),
+ error (_(DWARF_ERROR_PREFIX
+ "could not find CU containing offset %s [in module %s]"),
sect_offset_str (sect_off),
bfd_get_filename (per_bfd->obfd));
cu->per_cu->set_unit_type (DW_UT_type);
break;
default:
- error (_("Dwarf Error: unexpected tag '%s' at offset %s"),
+ error (_(DWARF_ERROR_PREFIX
+ "unexpected tag '%s' at offset %s"),
dwarf_tag_name (comp_unit_die->tag),
sect_offset_str (cu->per_cu->sect_off));
}