From: Andrew Burgess Date: Wed, 24 Dec 2025 20:36:54 +0000 (+0000) Subject: gdb/dwarf: remove the line_header argument from dwarf2_start_subfile X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3121014844c29f419de0d46d4e7129c04ac3e127;p=thirdparty%2Fbinutils-gdb.git gdb/dwarf: remove the line_header argument from dwarf2_start_subfile 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. Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c index bac315eef38..06eb762eb8a 100644 --- a/gdb/dwarf2/line-program.c +++ b/gdb/dwarf2/line-program.c @@ -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) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5311016b257..2f4cbd60720 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6265,7 +6265,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 (); @@ -15983,12 +15983,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. @@ -16003,8 +16002,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 diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 1e81bb2056d..c29e414cc29 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -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. */