aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/line-header.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-04-26 21:40:51 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2022-07-29 20:54:49 -0400
commitddc01737d34f16074b2c9a92c5a808be5c91340f (patch)
tree8acce31c8736d1749f358e57d2f4761a58b4c89d /gdb/dwarf2/line-header.h
parent80affb9f80d22ee4b1463f23a36b083e05b6d2c3 (diff)
downloadbinutils-ddc01737d34f16074b2c9a92c5a808be5c91340f.zip
binutils-ddc01737d34f16074b2c9a92c5a808be5c91340f.tar.gz
binutils-ddc01737d34f16074b2c9a92c5a808be5c91340f.tar.bz2
gdb/dwarf: pass compilation directory to line header
The following patch changes line_header::file_file_name to prepend the compilation directory to the file name, if needed. For that, the line header needs to know about the compilation directory. Prepare for that by adding a constructor that takes it as a parameter, and passing the value down everywhere needed. Add a second constructor for the special case of building a line_header for doing a hash table lookup, since that case doesn't require a compilation directory value. Change-Id: Iba3ba0293e4e2d13a64b257cf9a3094684d54330
Diffstat (limited to 'gdb/dwarf2/line-header.h')
-rw-r--r--gdb/dwarf2/line-header.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index 59b317d..32f52c4 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -68,8 +68,18 @@ struct file_entry
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. */
@@ -161,6 +171,11 @@ struct line_header
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. */
@@ -171,6 +186,10 @@ struct line_header
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;
@@ -191,6 +210,7 @@ file_entry::include_dir (const line_header *lh) const
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 */