[binutils-gdb] gdb: remove find_target_at

Simon Marchi simark@sourceware.org
Thu Dec 4 16:34:21 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=390dbc4a8768c379f535ac4fd2f04ba93ceb5046

commit 390dbc4a8768c379f535ac4fd2f04ba93ceb5046
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Dec 2 16:09:26 2025 -0500

    gdb: remove find_target_at
    
    ... to make the current_inferior reference bubble up one level.  Since
    find_target_at would become a trivial wrapper around
    inferior::target_at, remove it.  I think it's clearer anyway to see
    explicitly that the "subject" of the method call is the inferior.
    
    Change-Id: I73ec44d37e7afea6e85b1689af65e32ae8e5a695
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/record.c        |  2 +-
 gdb/svr4-tls-tdep.c |  2 +-
 gdb/target.c        | 22 +++-------------------
 gdb/target.h        |  5 -----
 4 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/gdb/record.c b/gdb/record.c
index 7f3cf541bf1..38bbfbeffff 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -62,7 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL;
 struct target_ops *
 find_record_target (void)
 {
-  return find_target_at (record_stratum);
+  return current_inferior ()->target_at (record_stratum);
 }
 
 /* Check that recording is active.  Throw an error, if it isn't.  */
diff --git a/gdb/svr4-tls-tdep.c b/gdb/svr4-tls-tdep.c
index 1f36d573b0c..a898299e948 100644
--- a/gdb/svr4-tls-tdep.c
+++ b/gdb/svr4-tls-tdep.c
@@ -123,7 +123,7 @@ svr4_tls_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
      The idea here is to prefer use of of the target's thread_stratum
      method since it should be more accurate.  */
   if (gdbarch_data->get_tls_dtv_addr == nullptr
-      || (find_target_at (thread_stratum) != nullptr
+      || (current_inferior ()->target_at (thread_stratum) != nullptr
 	  && !force_internal_tls_address_lookup))
     {
       struct target_ops *target = current_inferior ()->top_target ();
diff --git a/gdb/target.c b/gdb/target.c
index 641ec1d7e72..05944319e26 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2950,12 +2950,10 @@ target_ops::info_proc (const char *args, enum info_proc_what what)
 int
 target_info_proc (const char *args, enum info_proc_what what)
 {
-  struct target_ops *t;
-
   /* If we're already connected to something that can get us OS
      related data, use it.  Otherwise, try using the native
      target.  */
-  t = find_target_at (process_stratum);
+  target_ops *t = current_inferior ()->target_at (process_stratum);
   if (t == NULL)
     t = find_default_run_target (NULL);
 
@@ -3001,12 +2999,10 @@ target_supports_multi_process (void)
 std::optional<gdb::char_vector>
 target_get_osdata (const char *type)
 {
-  struct target_ops *t;
-
   /* If we're already connected to something that can get us OS
      related data, use it.  Otherwise, try using the native
      target.  */
-  t = find_target_at (process_stratum);
+  target_ops *t = current_inferior ()->target_at (process_stratum);
   if (t == NULL)
     t = find_default_run_target ("get OS data");
 
@@ -3079,11 +3075,9 @@ target_can_run ()
 static struct target_ops *
 default_fileio_target (void)
 {
-  struct target_ops *t;
-
   /* If we're already connected to something that can perform
      file I/O, use it. Otherwise, try using the native target.  */
-  t = find_target_at (process_stratum);
+  target_ops *t = current_inferior ()->target_at (process_stratum);
   if (t != NULL)
     return t;
   return find_default_run_target ("file I/O");
@@ -3597,16 +3591,6 @@ target_stack::find_beneath (const target_ops *t) const
   return NULL;
 }
 
-/* See target.h.  */
-
-struct target_ops *
-find_target_at (enum strata stratum)
-{
-  return current_inferior ()->target_at (stratum);
-}
-
-

-
 /* See target.h  */
 
 void
diff --git a/gdb/target.h b/gdb/target.h
index 2fd70cc9dfa..bf35227b658 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -2569,11 +2569,6 @@ extern void initialize_targets (void);
 
 extern void target_require_runnable (void);
 
-/* Find the target at STRATUM.  If no target is at that stratum,
-   return NULL.  */
-
-struct target_ops *find_target_at (enum strata stratum);
-
 /* Read OS data object of type TYPE from the target, and return it in XML
    format.  The return value follows the same rules as target_read_stralloc.  */


More information about the Gdb-cvs mailing list