]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: rename dwarf2_start_subfile to dwarf2_cu::start_subfile
authorAndrew Burgess <aburgess@redhat.com>
Thu, 25 Dec 2025 11:15:09 +0000 (11:15 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 6 Jan 2026 10:53:17 +0000 (10:53 +0000)
Rename dwarf2_start_subfile to dwarf2_cu::start_subfile.  This
refactor continues the work started in the previous commit.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/cu.c
gdb/dwarf2/cu.h
gdb/dwarf2/line-program.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index 0abf25bf8a14e490ec6aa39b7f486c6ab5759c26..1cf320267fb365b447f1a996430ff338d243c302 100644 (file)
@@ -250,7 +250,7 @@ dwarf2_cu::create_subfiles_and_symtabs ()
 
   for (file_entry &fe : this->line_header->file_names ())
     {
-      dwarf2_start_subfile (*this, fe);
+      this->start_subfile (fe);
       subfile *sf = builder->get_current_subfile ();
 
       if (sf->symtab == nullptr)
@@ -260,3 +260,30 @@ dwarf2_cu::create_subfiles_and_symtabs ()
       fe.symtab = sf->symtab;
     }
 }
+
+/* See dwarf2/cu.h.  */
+
+void
+dwarf2_cu::start_subfile (const file_entry &fe)
+{
+  std::string filename_holder;
+  const char *filename = fe.name;
+  const char *dirname = this->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.
+     Note that the Dwarf3 standard says (speaking of filenames in line
+     information): ``The directory index is ignored for file names
+     that represent full path names''.  Thus ignoring dirname in the
+     `else' branch below isn't an issue.  */
+
+  if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
+    {
+      filename_holder = path_join (dirname, filename);
+      filename = filename_holder.c_str ();
+    }
+
+  std::string filename_for_id = this->line_header->file_file_name (fe);
+  this->get_builder ()->start_subfile (filename, filename_for_id.c_str ());
+}
+
index c0596c35876a6e125ad4ea1b7f6a36835203ddf2..97c0b87121bc2ce27de0117e7874b211284fb580 100644 (file)
@@ -26,6 +26,7 @@
 #include "language.h"
 #include "gdbsupport/unordered_set.h"
 #include "dwarf2/die.h"
+#include "line-header.h"
 
 /* Type used for delaying computation of method physnames.
    See comments for compute_delayed_physnames.  */
@@ -75,6 +76,9 @@ struct dwarf2_cu
   /* Create a subfile and symtab for every entry in the line_header.  */
   void create_subfiles_and_symtabs ();
 
+  /* Start a subfile for FE within this CU.  */
+  void start_subfile (const file_entry &fe);
+
   /* Reset the builder.  */
   void reset_builder () { m_builder.reset (); }
 
index 0b8af07d47a01da031183d875deb71a74a0df71e..18f010919c2003d75e0b10a58d3abbaab92730bc 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->start_subfile (*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);
+       cu->start_subfile (*fe);
 
       /* Decode the table.  */
       while (line_ptr < line_end && !end_sequence)
index a99a2760af54ef3cce760c91280d9dc0b3464712..4edd9cf2591c43b25df412a4d187f87d1b5b9c06 100644 (file)
@@ -15966,32 +15966,6 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu,
                                   comp_dir);
 }
 
-/* See dwarf2/read.h.  */
-
-void
-dwarf2_start_subfile (dwarf2_cu &cu, const file_entry &fe)
-{
-  std::string filename_holder;
-  const char *filename = fe.name;
-  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.
-     Note that the Dwarf3 standard says (speaking of filenames in line
-     information): ``The directory index is ignored for file names
-     that represent full path names''.  Thus ignoring dirname in the
-     `else' branch below isn't an issue.  */
-
-  if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
-    {
-      filename_holder = path_join (dirname, filename);
-      filename = filename_holder.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
 var_decode_location (struct attribute *attr, struct symbol *sym,
                     struct dwarf2_cu *cu)
index c29e414cc296f8ea6d0b95bf12b6c2fc5b69d77a..1a6d9767413ec661d8c15ffe1bf26e892babd7e2 100644 (file)
@@ -1410,29 +1410,6 @@ 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 FE within CU.
-
-   This routine tries to keep line numbers from identical absolute and
-   relative file names in a common subfile.
-
-   Using the `list' example from the GDB testsuite, which resides in
-   /srcdir and compiling it with Irix6.2 cc in /compdir using a filename
-   of /srcdir/list0.c yields the following debugging information for list0.c:
-
-   DW_AT_name:          /srcdir/list0.c
-   DW_AT_comp_dir:      /compdir
-   files.files[0].name: list0.h
-   files.files[0].dir:  /srcdir
-   files.files[1].name: list0.c
-   files.files[1].dir:  /srcdir
-
-   The line number information for list0.c has to end up in a single
-   subfile, so that `break /srcdir/list0.c:1' works as expected.
-   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);
-
 /* A helper function that decides if a given symbol is an Ada Pragma
    Import or Pragma Export.  */