[PATCHv4,3/7] gdb/dwarf: remove the line_header argument from dwarf2_start_subfile
Commit Message
As with the previous two commits, this commit removes the line_header
argument from dwarf2_start_subfile. This function already takes a
dwarf2_cu argument, and the line_header passed in is always the line
header pointed to by the dwarf2_cu argument, so lets just access the
line header through the dwarf2_cu.
As dwarf2_start_subfile relies on the dwarf2_cu always being non-NULL,
I've converted the dwarf2_cu argument from a pointer to a reference.
The alternative was adding an assert within dwarf2_start_subfile that
the pointer was not NULL.
There should be no user visible changes after this commit.
---
gdb/dwarf2/line-program.c | 9 ++++-----
gdb/dwarf2/read.c | 11 +++++------
gdb/dwarf2/read.h | 8 +++-----
3 files changed, 12 insertions(+), 16 deletions(-)
Comments
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
Andrew> As with the previous two commits, this commit removes the line_header
Andrew> argument from dwarf2_start_subfile. This function already takes a
Andrew> dwarf2_cu argument, and the line_header passed in is always the line
Andrew> header pointed to by the dwarf2_cu argument, so lets just access the
Andrew> line header through the dwarf2_cu.
Andrew> As dwarf2_start_subfile relies on the dwarf2_cu always being non-NULL,
Andrew> I've converted the dwarf2_cu argument from a pointer to a reference.
Andrew> The alternative was adding an assert within dwarf2_start_subfile that
Andrew> the pointer was not NULL.
Seems reasonable to me, thanks.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
@@ -244,7 +244,7 @@ lnp_state_machine::handle_set_file (file_name_index file)
else
{
m_line_has_non_zero_discriminator = m_discriminator != 0;
- dwarf2_start_subfile (m_cu, *fe, *m_cu->line_header);
+ dwarf2_start_subfile (*m_cu, *fe);
}
}
@@ -507,7 +507,7 @@ dwarf_decode_lines_1 (struct dwarf2_cu *cu, unrelocated_addr lowpc)
const file_entry *fe = state_machine.current_file ();
if (fe != NULL)
- dwarf2_start_subfile (cu, *fe, *lh);
+ dwarf2_start_subfile (*cu, *fe);
/* Decode the table. */
while (line_ptr < line_end && !end_sequence)
@@ -702,10 +702,9 @@ dwarf_decode_lines (struct dwarf2_cu *cu, unrelocated_addr lowpc,
buildsym_compunit *builder = cu->get_builder ();
struct compunit_symtab *cust = builder->get_compunit_symtab ();
- struct line_header *lh = cu->line_header;
- for (file_entry &fe : lh->file_names ())
+ for (file_entry &fe : cu->line_header->file_names ())
{
- dwarf2_start_subfile (cu, fe, *lh);
+ dwarf2_start_subfile (*cu, fe);
subfile *sf = builder->get_current_subfile ();
if (sf->symtab == nullptr)
@@ -6275,7 +6275,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
for (i = 0; i < file_names.size (); ++i)
{
file_entry &fe = file_names[i];
- dwarf2_start_subfile (this, fe, *line_header);
+ dwarf2_start_subfile (*this, fe);
buildsym_compunit *b = get_builder ();
subfile *sf = b->get_current_subfile ();
@@ -15993,12 +15993,11 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu,
/* See dwarf2/read.h. */
void
-dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
- const line_header &lh)
+dwarf2_start_subfile (dwarf2_cu &cu, const file_entry &fe)
{
std::string filename_holder;
const char *filename = fe.name;
- const char *dirname = lh.include_dir_at (fe.d_index);
+ const char *dirname = cu.line_header->include_dir_at (fe.d_index);
/* In order not to lose the line information directory,
we concatenate it to the filename when it makes sense.
@@ -16013,8 +16012,8 @@ dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
filename = filename_holder.c_str ();
}
- std::string filename_for_id = lh.file_file_name (fe);
- cu->get_builder ()->start_subfile (filename, filename_for_id.c_str ());
+ std::string filename_for_id = cu.line_header->file_file_name (fe);
+ cu.get_builder ()->start_subfile (filename, filename_for_id.c_str ());
}
static void
@@ -1410,9 +1410,8 @@ extern const dwarf2_section_info &get_section_for_ref
extern struct dwarf2_section_info *get_debug_line_section
(struct dwarf2_cu *cu);
-/* Start a subfile for DWARF. FILENAME is the name of the file and
- DIRNAME the name of the source directory which contains FILENAME
- or NULL if not known.
+/* Start a subfile for FE within CU.
+
This routine tries to keep line numbers from identical absolute and
relative file names in a common subfile.
@@ -1432,8 +1431,7 @@ extern struct dwarf2_section_info *get_debug_line_section
start_subfile will ensure that this happens provided that we pass the
concatenation of files.files[1].dir and files.files[1].name as the
subfile's name. */
-extern void dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
- const line_header &lh);
+extern void dwarf2_start_subfile (dwarf2_cu &cu, const file_entry &fe);
/* A helper function that decides if a given symbol is an Ada Pragma
Import or Pragma Export. */