/* DWARF 2 debugging format support for GDB.
- Copyright (C) 1994-2021 Free Software Foundation, Inc.
+ Copyright (C) 1994-2022 Free Software Foundation, Inc.
Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
Inc. with support from Florida State University (under contract
#include "dwarf2/attribute.h"
#include "dwarf2/comp-unit-head.h"
#include "dwarf2/cu.h"
-#include "dwarf2/file-and-dir.h"
#include "dwarf2/index-cache.h"
#include "dwarf2/index-common.h"
#include "dwarf2/leb.h"
delete data;
}
-static file_and_directory find_file_and_directory (struct die_info *die,
- struct dwarf2_cu *cu);
+static file_and_directory &find_file_and_directory
+ (struct die_info *die, struct dwarf2_cu *cu);
static const char *compute_include_file_name
(const struct line_header *lh,
lh = dwarf_decode_line_header (line_offset, cu);
}
- file_and_directory fnd = find_file_and_directory (comp_unit_die, cu);
+ file_and_directory &fnd = find_file_and_directory (comp_unit_die, cu);
int offset = 0;
- if (fnd.is_unknown ())
+ if (!fnd.is_unknown ())
++offset;
else if (lh == nullptr)
return;
if (cust == NULL)
return NULL;
- return compunit_primary_filetab (cust);
+ return cust->primary_filetab ();
}
/* See read.h. */
{
int i;
- if (COMPUNIT_BLOCKVECTOR (cust) != NULL
- && blockvector_contains_pc (COMPUNIT_BLOCKVECTOR (cust), pc))
+ if (cust->blockvector () != nullptr
+ && blockvector_contains_pc (cust->blockvector (), pc))
return cust;
if (cust->includes == NULL)
prepare_one_comp_unit (cu, comp_unit_die, pretend_language);
/* Allocate a new partial symbol table structure. */
- gdb::unique_xmalloc_ptr<char> debug_filename;
static const char artificial[] = "<artificial>";
- file_and_directory fnd = find_file_and_directory (comp_unit_die, cu);
+ file_and_directory &fnd = find_file_and_directory (comp_unit_die, cu);
if (strcmp (fnd.get_name (), artificial) == 0)
{
- debug_filename.reset (concat (artificial, "@",
- sect_offset_str (per_cu->sect_off),
- (char *) NULL));
- fnd.set_name (debug_filename.get ());
+ gdb::unique_xmalloc_ptr<char> debug_filename
+ (concat (artificial, "@",
+ sect_offset_str (per_cu->sect_off),
+ (char *) NULL));
+ fnd.set_name (std::move (debug_filename));
}
pst = create_partial_symtab (per_cu, per_objfile, fnd.get_name ());
compilation is from a C file generated by language preprocessors, do
not set the language if it was already deduced by start_subfile. */
if (!(cu->per_cu->lang == language_c
- && COMPUNIT_FILETABS (cust)->language != language_unknown))
- COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang;
+ && cust->primary_filetab ()->language != language_unknown))
+ cust->primary_filetab ()->language = cu->per_cu->lang;
/* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can
produce DW_AT_location with location lists but it can be possibly
options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
*/
if (cu->has_loclist && gcc_4_minor >= 5)
- cust->locations_valid = 1;
+ cust->set_locations_valid (true);
if (gcc_4_minor >= 5)
cust->epilogue_unwind_valid = 1;
do not set the language if it was already deduced by
start_subfile. */
if (!(cu->per_cu->lang == language_c
- && COMPUNIT_FILETABS (cust)->language != language_c))
- COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang;
+ && cust->primary_filetab ()->language != language_c))
+ cust->primary_filetab ()->language = cu->per_cu->lang;
}
}
else
return cu->producer_is_gcc_lt_4_3;
}
-static file_and_directory
+static file_and_directory &
find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
{
+ if (cu->per_cu->fnd != nullptr)
+ return *cu->per_cu->fnd;
+
/* Find the filename. Do not use dwarf2_name here, since the filename
is not a source language identifier. */
file_and_directory res (dwarf2_string_attr (die, DW_AT_name, cu),
&& IS_ABSOLUTE_PATH (res.get_name ()))
res.set_comp_dir (ldirname (res.get_name ()));
- return res;
+ cu->per_cu->fnd.reset (new file_and_directory (std::move (res)));
+ return *cu->per_cu->fnd;
}
/* Handle DW_AT_stmt_list for a compilation unit.
lowpc = highpc;
lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
- file_and_directory fnd = find_file_and_directory (die, cu);
+ file_and_directory &fnd = find_file_and_directory (die, cu);
cu->start_symtab (fnd.get_name (), fnd.intern_comp_dir (objfile), lowpc);
/* Decode line number information if present. We do this before
processing child DIEs, so that the line header table is available
- for DW_AT_decl_file. */
- handle_DW_AT_stmt_list (die, cu, fnd, lowpc);
+ for DW_AT_decl_file. The PC check is here because, if LOWPC and
+ HIGHPC are both 0x0, then there won't be any interesting code in
+ the CU, but a check later on (in
+ lnp_state_machine::check_line_address) will fail to properly
+ exclude an entry that was removed via --gc-sections. */
+ if (lowpc != highpc)
+ handle_DW_AT_stmt_list (die, cu, fnd, lowpc);
/* Process all dies in compilation unit. */
if (die->child != NULL)
gdb_assert (m_builder == nullptr);
struct compunit_symtab *cust = tug_unshare->compunit_symtab;
m_builder.reset (new struct buildsym_compunit
- (COMPUNIT_OBJFILE (cust), "",
- COMPUNIT_DIRNAME (cust),
+ (cust->objfile (), "",
+ cust->dirname (),
compunit_language (cust),
0, cust));
list_in_scope = get_builder ()->get_file_symbols ();
time. */
tug_unshare->symtabs
- = XOBNEWVEC (&COMPUNIT_OBJFILE (cust)->objfile_obstack,
+ = XOBNEWVEC (&cust->objfile ()->objfile_obstack,
struct symtab *, line_header->file_names_size ());
auto &file_names = line_header->file_names ();
gdb_assert (m_builder == nullptr);
struct compunit_symtab *cust = tug_unshare->compunit_symtab;
m_builder.reset (new struct buildsym_compunit
- (COMPUNIT_OBJFILE (cust), "",
- COMPUNIT_DIRNAME (cust),
+ (cust->objfile (), "",
+ cust->dirname (),
compunit_language (cust),
0, cust));
list_in_scope = get_builder ()->get_file_symbols ();
{
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))
{
if (attr->form_is_constant ())
{
LONGEST offset = attr->constant_value (0);
+
+ /* Work around this GCC 11 bug, where it would erroneously use -1
+ data member locations, instead of 0:
+
+ Negative DW_AT_data_member_location
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378
+ */
+ if (offset == -1 && cu->producer_is_gcc_11)
+ {
+ complaint (_("DW_AT_data_member_location value of -1, assuming 0"));
+ offset = 0;
+ }
+
field->set_loc_bitpos (offset * bits_per_byte);
}
else if (attr->form_is_section_offset ())
{
unsigned int i;
- print_spaces (indent, f);
- fprintf_unfiltered (f, "Die: %s (abbrev %d, offset %s)\n",
+ fprintf_unfiltered (f, "%*sDie: %s (abbrev %d, offset %s)\n",
+ indent, "",
dwarf_tag_name (die->tag), die->abbrev,
sect_offset_str (die->sect_off));
if (die->parent != NULL)
- {
- print_spaces (indent, f);
- fprintf_unfiltered (f, " parent at offset: %s\n",
- sect_offset_str (die->parent->sect_off));
- }
+ fprintf_unfiltered (f, "%*s parent at offset: %s\n",
+ indent, "",
+ sect_offset_str (die->parent->sect_off));
- print_spaces (indent, f);
- fprintf_unfiltered (f, " has children: %s\n",
- dwarf_bool_name (die->child != NULL));
+ fprintf_unfiltered (f, "%*s has children: %s\n",
+ indent, "",
+ dwarf_bool_name (die->child != NULL));
- print_spaces (indent, f);
- fprintf_unfiltered (f, " attributes:\n");
+ fprintf_unfiltered (f, "%*s attributes:\n", indent, "");
for (i = 0; i < die->num_attrs; ++i)
{
- print_spaces (indent, f);
- fprintf_unfiltered (f, " %s (%s) ",
- dwarf_attr_name (die->attrs[i].name),
- dwarf_form_name (die->attrs[i].form));
+ fprintf_unfiltered (f, "%*s %s (%s) ",
+ indent, "",
+ dwarf_attr_name (die->attrs[i].name),
+ dwarf_form_name (die->attrs[i].form));
switch (die->attrs[i].form)
{
if (die->child != NULL)
{
- print_spaces (indent, f);
- fprintf_unfiltered (f, " Children:");
+ fprintf_unfiltered (f, "%*s Children:", indent, "");
if (level + 1 < max_level)
{
fprintf_unfiltered (f, "\n");