[1/3] gdb/dwarf: remove create_cu_from_index_list

Message ID 20250303213653.738360-2-simon.marchi@efficios.com
State New
Headers
Series More random DWARF cleanups |

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 fail Patch failed to apply

Commit Message

Simon Marchi March 3, 2025, 9:35 p.m. UTC
  I noticed that create_cu_from_index_list is only used in
read-gdb-index.c, so I started by moving it there.  But given that this
function is use at only one spot and doesn't do much, I opted to inline
its code in the caller instead.

Change-Id: Iebe0dc20d345fa70a2f11aa9ff1a04fe26a31407
---
 gdb/dwarf2/read-gdb-index.c |  6 +++---
 gdb/dwarf2/read.c           | 14 --------------
 gdb/dwarf2/read.h           |  7 -------
 3 files changed, 3 insertions(+), 24 deletions(-)
  

Comments

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

Simon> I noticed that create_cu_from_index_list is only used in
Simon> read-gdb-index.c, so I started by moving it there.  But given that this
Simon> function is use at only one spot and doesn't do much, I opted to inline
Simon> its code in the caller instead.

This is ok.  FWIW my other series rewrites read-gdb-index.c.

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

Tom
  

Patch

diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 66d7209c1dde..282ac5b4ef4b 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -1324,9 +1324,9 @@  create_cus_from_gdb_index_list (dwarf2_per_bfd *per_bfd,
       ULONGEST length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE);
       cu_list += 2 * 8;
 
-      dwarf2_per_cu_up per_cu
-	= create_cu_from_index_list (per_bfd, section, is_dwz, sect_off,
-				     length);
+      dwarf2_per_cu_up per_cu = per_bfd->allocate_per_cu (section, sect_off, length);
+      per_cu->is_dwz = is_dwz;
+
       per_bfd->all_units.push_back (std::move (per_cu));
     }
 }
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b2394588cb8f..0bef46a10e4b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1841,20 +1841,6 @@  dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section,
   return result;
 }
 
-/* See read.h.  */
-
-dwarf2_per_cu_up
-create_cu_from_index_list (dwarf2_per_bfd *per_bfd,
-			   struct dwarf2_section_info *section,
-			   int is_dwz,
-			   sect_offset sect_off, ULONGEST length)
-{
-  dwarf2_per_cu_up the_cu
-    = per_bfd->allocate_per_cu (section, sect_off, length);
-  the_cu->is_dwz = is_dwz;
-  return the_cu;
-}
-
 /* die_reader_func for dw2_get_file_names.  */
 
 static void
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 43d0e5d2ebf9..7a98eb4f66e1 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -998,13 +998,6 @@  extern void dw_expand_symtabs_matching_file_matcher
 extern const char *read_indirect_string_at_offset
   (dwarf2_per_objfile *per_objfile, LONGEST str_offset);
 
-/* Return a new dwarf2_per_cu allocated on the per-bfd obstack, and constructed
-   with the specified field values.  */
-
-extern dwarf2_per_cu_up create_cu_from_index_list
-  (dwarf2_per_bfd *per_bfd, struct dwarf2_section_info *section,
-   int is_dwz, sect_offset sect_off, ULONGEST length);
-
 /* Initialize the views on all_units.  */
 
 extern void finalize_all_units (dwarf2_per_bfd *per_bfd);