dwarf_decode_line_header (sect_offset sect_off, bool is_dwz,
dwarf2_per_objfile *per_objfile,
struct dwarf2_section_info *section,
- const struct comp_unit_head *cu_header)
+ const struct comp_unit_head *cu_header,
+ const char *comp_dir)
{
const gdb_byte *line_ptr;
unsigned int bytes_read, offset_size;
return 0;
}
- line_header_up lh (new line_header ());
+ line_header_up lh (new line_header (comp_dir));
lh->sect_off = sect_off;
lh->offset_in_dwz = is_dwz;
which contains the following information. */
struct line_header
{
- line_header ()
- : offset_in_dwz {}
+ /* COMP_DIR is the value of the DW_AT_comp_dir attribute of the compilation
+ unit in the context of which we are reading this line header, or nullptr
+ if unknown or not applicable. */
+ explicit line_header (const char *comp_dir)
+ : offset_in_dwz {}, m_comp_dir (comp_dir)
+ {}
+
+ /* This constructor should only be used to create line_header intances to do
+ hash table lookups. */
+ line_header (sect_offset sect_off, bool offset_in_dwz)
+ : sect_off (sect_off),
+ offset_in_dwz (offset_in_dwz)
{}
/* Add an entry to the include directory table. */
number FILE in this object's file name table. */
std::string file_file_name (int file) const;
+ /* Return the compilation directory of the compilation unit in the context of
+ which this line header is read. Return nullptr if non applicable. */
+ const char *comp_dir () const
+ { return m_comp_dir; }
+
private:
/* The include_directories table. Note these are observing
pointers. The memory is owned by debug_line_buffer. */
before, and is 0 in DWARF 5 and later). So the client should use
file_name_at method for access. */
std::vector<file_entry> m_file_names;
+
+ /* Compilation directory of the compilation unit in the context of which this
+ line header is read. nullptr if unknown or not applicable. */
+ const char *m_comp_dir = nullptr;
};
typedef std::unique_ptr<line_header> line_header_up;
extern line_header_up dwarf_decode_line_header
(sect_offset sect_off, bool is_dwz, dwarf2_per_objfile *per_objfile,
- struct dwarf2_section_info *section, const struct comp_unit_head *cu_header);
+ struct dwarf2_section_info *section, const struct comp_unit_head *cu_header,
+ const char *comp_dir);
#endif /* DWARF2_LINE_HEADER_H */
struct dwarf2_cu **);
static line_header_up dwarf_decode_line_header (sect_offset sect_off,
- struct dwarf2_cu *cu);
+ struct dwarf2_cu *cu,
+ const char *comp_dir);
static void dwarf_decode_lines (struct line_header *,
struct dwarf2_cu *,
line_header_up lh;
sect_offset line_offset {};
+ file_and_directory &fnd = find_file_and_directory (comp_unit_die, cu);
+
attr = dwarf2_attr (comp_unit_die, DW_AT_stmt_list, cu);
if (attr != nullptr && attr->form_is_unsigned ())
{
return;
}
- lh = dwarf_decode_line_header (line_offset, cu);
+ lh = dwarf_decode_line_header (line_offset, cu, fnd.get_comp_dir ());
}
- file_and_directory &fnd = find_file_and_directory (comp_unit_die, cu);
-
int offset = 0;
if (!fnd.is_unknown ())
++offset;
static void
handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
+ const file_and_directory &fnd,
CORE_ADDR lowpc) /* ARI: editCase function */
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
struct attribute *attr;
- struct line_header line_header_local;
hashval_t line_header_local_hash;
void **slot;
int decode_mapping;
xcalloc, xfree));
}
- line_header_local.sect_off = line_offset;
- line_header_local.offset_in_dwz = cu->per_cu->is_dwz;
+ line_header line_header_local (line_offset, cu->per_cu->is_dwz);
line_header_local_hash = line_header_hash (&line_header_local);
if (per_objfile->line_header_hash != NULL)
{
/* dwarf_decode_line_header does not yet provide sufficient information.
We always have to call also dwarf_decode_lines for it. */
- line_header_up lh = dwarf_decode_line_header (line_offset, cu);
+ line_header_up lh = dwarf_decode_line_header (line_offset, cu,
+ fnd.get_comp_dir ());
if (lh == NULL)
return;
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, lowpc);
+ handle_DW_AT_stmt_list (die, cu, fnd, lowpc);
/* Process all dies in compilation unit. */
if (die->child != NULL)
if (attr != NULL && attr->form_is_unsigned ())
{
sect_offset line_offset = (sect_offset) attr->as_unsigned ();
- lh = dwarf_decode_line_header (line_offset, this);
+ lh = dwarf_decode_line_header (line_offset, this, nullptr);
}
if (lh == NULL)
{
and must not be freed. */
static line_header_up
-dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu)
+dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu,
+ const char *comp_dir)
{
struct dwarf2_section_info *section;
dwarf2_per_objfile *per_objfile = cu->per_objfile;
}
return dwarf_decode_line_header (sect_off, cu->per_cu->is_dwz,
- per_objfile, section, &cu->header);
+ per_objfile, section, &cu->header,
+ comp_dir);
}
/* Subroutine of dwarf_decode_lines to simplify it.