gdb/dwarf: remove unnecessary abfd parameter in dwarf2_per_bfd::locate_sections

Message ID 20250228192714.3361549-1-simon.marchi@polymtl.ca
State New
Headers
Series gdb/dwarf: remove unnecessary abfd parameter in dwarf2_per_bfd::locate_sections |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Simon Marchi Feb. 28, 2025, 7:27 p.m. UTC
  From: Simon Marchi <simon.marchi@efficios.com>

The parameter `abfd` is always the same as `this->obfd`, there is no
need to pass it as a parameter.

Change-Id: If7ad58ad4efdf6b070cbf2b8a73436bd8b452fa6
---
 gdb/dwarf2/read.c | 8 ++++----
 gdb/dwarf2/read.h | 3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)


base-commit: cb9995e8d8fab4e48ba202fe8456e68cc130490a
  

Comments

Tom Tromey March 3, 2025, 8:25 p.m. UTC | #1
>>>>> "simon" == simon marchi <simon.marchi@polymtl.ca> writes:

Simon> The parameter `abfd` is always the same as `this->obfd`, there is no
Simon> need to pass it as a parameter.

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

Tom
  
Simon Marchi March 3, 2025, 9 p.m. UTC | #2
On 3/3/25 3:25 PM, Tom Tromey wrote:
>>>>>> "simon" == simon marchi <simon.marchi@polymtl.ca> writes:
> 
> Simon> The parameter `abfd` is always the same as `this->obfd`, there is no
> Simon> need to pass it as a parameter.
> 
> Looks good.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks, pushed.

Simon
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b377b07cf7ce..704962afdcdf 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1261,7 +1261,7 @@  dwarf2_per_bfd::dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names,
     names = &dwarf2_elf_names;
 
   for (asection *sec = obfd->sections; sec != NULL; sec = sec->next)
-    locate_sections (obfd, sec, *names);
+    this->locate_sections (sec, *names);
 }
 
 dwarf2_per_bfd::~dwarf2_per_bfd ()
@@ -1422,7 +1422,7 @@  dwarf2_has_info (struct objfile *objfile,
 /* See declaration.  */
 
 void
-dwarf2_per_bfd::locate_sections (bfd *abfd, asection *sectp,
+dwarf2_per_bfd::locate_sections (asection *sectp,
 				 const dwarf2_debug_sections &names)
 {
   flagword aflag = bfd_section_flags (sectp);
@@ -1430,13 +1430,13 @@  dwarf2_per_bfd::locate_sections (bfd *abfd, asection *sectp,
   if ((aflag & SEC_HAS_CONTENTS) == 0)
     {
     }
-  else if (bfd_section_size_insane (abfd, sectp))
+  else if (bfd_section_size_insane (this->obfd, sectp))
     {
       bfd_size_type size = sectp->size;
       warning (_("Discarding section %s which has an invalid size (%s) "
 		 "[in module %s]"),
 	       bfd_section_name (sectp), phex_nz (size, sizeof (size)),
-	       bfd_get_filename (abfd));
+	       this->filename ());
     }
   else if (names.info.matches (sectp->name))
     {
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index fcb7d403d9fa..e8f9410ed966 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -519,8 +519,7 @@  struct dwarf2_per_bfd
   /* This function is mapped across the sections and remembers the
      offset and size of each of the debugging sections we are
      interested in.  */
-  void locate_sections (bfd *abfd, asection *sectp,
-			const dwarf2_debug_sections &names);
+  void locate_sections (asection *sectp, const dwarf2_debug_sections &names);
 
 public:
   /* The corresponding BFD.  */