[PATCH 01/24] gdb: remove empty clear_solib functions

Simon Marchi
2023-10-10T20:42:32Z

Make the target_so_ops::clear_solib method optional, remove two empty
implementations.

Change-Id: Ifda297d50c74327d337091c58cdb5b3b60382591
---
gdb/solib-aix.c | 10 +---------
gdb/solib-target.c | 8 +-------
gdb/solib.c | 6 ++++--
3 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index fd6b1e7a4543..0b6ad83eed92 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -373,14 +373,6 @@ solib_aix_free_so (struct so_list *so)
delete li;
}

-/* Implement the "clear_solib" target_so_ops method. */
-
-static void
-solib_aix_clear_solib (void)
-{
- /* Nothing needed. */
-}
-
/* Compute and return the OBJFILE's section_offset array, using
the associated loader info (INFO). */

@@ -715,7 +707,7 @@ const struct target_so_ops solib_aix_so_ops =
solib_aix_relocate_section_addresses,
solib_aix_free_so,
nullptr,
- solib_aix_clear_solib,
+ nullptr,
solib_aix_solib_create_inferior_hook,
solib_aix_current_sos,
solib_aix_open_symbol_file_object,
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index ca9478f2ec30..865235de2995 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -281,12 +281,6 @@ solib_target_solib_create_inferior_hook (int from_tty)
/* Nothing needed. */
}

-static void
-solib_target_clear_solib (void)
-{
- /* Nothing needed. */
-}
-
static void
solib_target_free_so (struct so_list *so)
{
@@ -440,7 +434,7 @@ const struct target_so_ops solib_target_so_ops =
solib_target_relocate_section_addresses,
solib_target_free_so,
nullptr,
- solib_target_clear_solib,
+ nullptr,
solib_target_solib_create_inferior_hook,
solib_target_current_sos,
solib_target_open_symbol_file_object,
diff --git a/gdb/solib.c b/gdb/solib.c
index a2a8a031f343..e8211814283a 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1240,7 +1240,8 @@ clear_solib (void)
free_so (so);
}

- ops->clear_solib ();
+ if (ops->clear_solib != nullptr)
+ ops->clear_solib ();
}

/* Shared library startup support. When GDB starts up the inferior,
@@ -1409,7 +1410,8 @@ reload_shared_libraries (const char *ignored, int from_tty,
{
/* Reset or free private data structures not associated with
so_list entries. */
- ops->clear_solib ();
+ if (ops->clear_solib != nullptr)
+ ops->clear_solib ();

/* Remove any previous solib event breakpoint. This is usually
done in common code, at breakpoint_init_inferior time, but
--
2.42.0