]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: remove the line_header argument from dwarf2_start_subfile
authorAndrew Burgess <aburgess@redhat.com>
Wed, 24 Dec 2025 20:36:54 +0000 (20:36 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 6 Jan 2026 10:53:09 +0000 (10:53 +0000)
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 <tom@tromey.com>
gdb/dwarf2/line-program.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index bac315eef382507b8737eb8596e0bdce05799cc6..06eb762eb8ac221bcaee6a4e869a977b22a609d7 100644 (file)
@@ -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)
index 5311016b257cf00872356a4ce31b618a1e4883a0..2f4cbd60720f7f70ede8e5f0822629827c021213 100644 (file)
@@ -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
index 1e81bb2056df2ab3d2f351f6d80032162ea93064..c29e414cc296f8ea6d0b95bf12b6c2fc5b69d77a 100644 (file)
@@ -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.  */