[2/7] gdb/dwarf: make init_cu_die_reader a method of cutu_reader

Message ID 20250305211037.205294-2-simon.marchi@efficios.com
State New
Headers
Series [1/7] gdb/dwarf: make read_cutu_die_from_dwo a method of cutu_reader |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Simon Marchi March 5, 2025, 9:10 p.m. UTC
  init_cu_die_reader is only used inside cutu_reader, to initialize fields
of cutu_reader, so make it a private method.

Change-Id: Iaa80d4dbb8d0fa35bcac18ee70e147276874cc1b
---
 gdb/dwarf2/read.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)
  

Comments

Tom Tromey March 6, 2025, 2:31 p.m. UTC | #1
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> init_cu_die_reader is only used inside cutu_reader, to initialize fields
Simon> of cutu_reader, so make it a private method.

Makes sense.  Probably at some point this should be renamed since I
think the name is a reference to the now-deleted die_reader_specs.

Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Simon Marchi March 6, 2025, 4:16 p.m. UTC | #2
On 2025-03-06 09:31, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
> 
> Simon> init_cu_die_reader is only used inside cutu_reader, to initialize fields
> Simon> of cutu_reader, so make it a private method.
> 
> Makes sense.  Probably at some point this should be renamed since I
> think the name is a reference to the now-deleted die_reader_specs.

Yes I agree, I'd like to do a pass of renaming to better reflect the
current reality, eventually, but I need to understand things better to
be able to do that.  Also, many comments are out of date and refer to
parameters that don't exist anymore.

Simon
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 987dda5a6a16..4159c9a08aad 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -686,6 +686,10 @@  class cutu_reader
   }
 
 private:
+  void init_cu_die_reader (dwarf2_cu *cu, dwarf2_section_info *section,
+			   struct dwo_file *dwo_file,
+			   const struct abbrev_table *abbrev_table);
+
   void init_tu_and_read_dwo_dies (dwarf2_per_cu *this_cu,
 				  dwarf2_per_objfile *per_objfile,
 				  dwarf2_cu *existing_cu,
@@ -2907,19 +2911,19 @@  lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
 
 /* Initialize a cutu_reader from a dwarf2_cu.  */
 
-static void
-init_cu_die_reader (cutu_reader *reader, dwarf2_cu *cu,
-		    dwarf2_section_info *section, dwo_file *dwo_file,
-		    const abbrev_table *abbrev_table)
+void
+cutu_reader::init_cu_die_reader (dwarf2_cu *cu, dwarf2_section_info *section,
+				 struct dwo_file *dwo_file,
+				 const struct abbrev_table *abbrev_table)
 {
   gdb_assert (section->readin && section->buffer != NULL);
-  reader->abfd = section->get_bfd_owner ();
-  reader->cu = cu;
-  reader->dwo_file = dwo_file;
-  reader->die_section = section;
-  reader->buffer = section->buffer;
-  reader->buffer_end = section->buffer + section->size;
-  reader->abbrev_table = abbrev_table;
+  this->abfd = section->get_bfd_owner ();
+  this->cu = cu;
+  this->dwo_file = dwo_file;
+  this->die_section = section;
+  this->buffer = section->buffer;
+  this->buffer_end = section->buffer + section->size;
+  this->abbrev_table = abbrev_table;
 }
 
 /* Subroutine of cutu_reader to simplify it.
@@ -3067,8 +3071,8 @@  cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit,
   dwo_abbrev_section->read (objfile);
   *result_dwo_abbrev_table
     = abbrev_table::read (dwo_abbrev_section, cu->header.abbrev_sect_off);
-  init_cu_die_reader (this, cu, section, dwo_unit->dwo_file,
-		      result_dwo_abbrev_table->get ());
+  this->init_cu_die_reader (cu, section, dwo_unit->dwo_file,
+			    result_dwo_abbrev_table->get ());
 
   /* Read in the die, filling in the attributes from the stub.  This
      has the benefit of simplifying the rest of the code - all the
@@ -3351,7 +3355,7 @@  cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
 	}
 
       /* Read the top level CU/TU die.  */
-      init_cu_die_reader (this, cu, section, NULL, abbrev_table);
+      this->init_cu_die_reader (cu, section, NULL, abbrev_table);
       info_ptr = read_toplevel_die (this, &comp_unit_die, info_ptr);
 
       if (skip_partial && comp_unit_die->tag == DW_TAG_partial_unit)
@@ -3496,8 +3500,8 @@  cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
 	= abbrev_table::read (abbrev_section,
 			      m_new_cu->header.abbrev_sect_off);
 
-      init_cu_die_reader (this, m_new_cu.get (), section, dwo_file,
-			  m_abbrev_table_holder.get ());
+      this->init_cu_die_reader (m_new_cu.get (), section, dwo_file,
+				m_abbrev_table_holder.get ());
       info_ptr = read_toplevel_die (this, &comp_unit_die, info_ptr);
     }