aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/line-header.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-04-26 22:50:22 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2022-07-29 20:54:49 -0400
commit0aa306fed318f679c1db21974b64e29d236d51e5 (patch)
treeade6684b512c4e5dfa3f00b9a79ce0642c2a12e9 /gdb/dwarf2/line-header.h
parentddc01737d34f16074b2c9a92c5a808be5c91340f (diff)
downloadbinutils-0aa306fed318f679c1db21974b64e29d236d51e5.zip
binutils-0aa306fed318f679c1db21974b64e29d236d51e5.tar.gz
binutils-0aa306fed318f679c1db21974b64e29d236d51e5.tar.bz2
gdb/dwarf: pass a file_entry to line_header::file_file_name
In the following patch, there will be some callers of file_file_name that will already have access to the file_entry object for which they want the file name. It would be inefficient to have them pass an index, only for line_header::file_file_name to re-lookup the same file_entry object. Change line_header::file_file_name to accept a file_entry object reference, instead of an index to look up. I think this change makes sense in any case. Callers that have an index can first obtain a file_entry using line_header::file_name_at or line_header::file_names. When passing a file_entry object, we can assume that the file_entry's index is valid, unlike when passing an index. So, push the special case about an invalid index to the sole current caller of file_file_name, macro_start_file. I think that error belongs there anyway, since it specifically talks about "bad file number in macro information". This requires recording the file index in the file_entry structure, so add that. Change-Id: Ic6e44c407539d92b7863d7ba82405ade17f384ad
Diffstat (limited to 'gdb/dwarf2/line-header.h')
-rw-r--r--gdb/dwarf2/line-header.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index 32f52c4..e6b52f7 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -36,9 +36,10 @@ struct file_entry
{
file_entry () = default;
- file_entry (const char *name_, dir_index d_index_,
+ file_entry (const char *name_, file_name_index index_, dir_index d_index_,
unsigned int mod_time_, unsigned int length_)
: name (name_),
+ index (index_),
d_index (d_index_),
mod_time (mod_time_),
length (length_)
@@ -52,6 +53,9 @@ struct file_entry
owned by debug_line_buffer. */
const char *name {};
+ /* The index of this file in the file table. */
+ file_name_index index {};
+
/* The directory index (1-based). */
dir_index d_index {};
@@ -168,8 +172,8 @@ struct line_header
const gdb_byte *statement_program_start {}, *statement_program_end {};
/* Return file name relative to the compilation directory of file
- number FILE in this object's file name table. */
- std::string file_file_name (int file) const;
+ FE in this object's file name table. */
+ std::string file_file_name (const file_entry &fe) const;
/* Return the compilation directory of the compilation unit in the context of
which this line header is read. Return nullptr if non applicable. */