[PATCH 1/5] gdb: add inferior parameter to target_current_description

Simon Marchi simon.marchi@efficios.com
Thu Nov 24 16:04:24 GMT 2022


From: Simon Marchi <simon.marchi@polymtl.ca>

Make target_current_description not dependent on the current inferior on
entry.  Update all callers to pass the current inferior, so no change in
behavior is expected.

Change-Id: Ic3c501bc83eb6950db077001a96a5c70dc8ae942
---
 gdb/arch-utils.c          | 4 ++--
 gdb/target-descriptions.c | 4 ++--
 gdb/target-descriptions.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 7b84daf046e..dc67c632155 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -586,7 +586,7 @@ gdbarch_update_p (struct gdbarch_info info)
 
   /* Check for the current target description.  */
   if (info.target_desc == NULL)
-    info.target_desc = target_current_description ();
+    info.target_desc = target_current_description (current_inferior ());
 
   new_gdbarch = gdbarch_find_by_info (info);
 
@@ -644,7 +644,7 @@ set_gdbarch_from_file (bfd *abfd)
   struct gdbarch *gdbarch;
 
   info.abfd = abfd;
-  info.target_desc = target_current_description ();
+  info.target_desc = target_current_description (current_inferior ());
   gdbarch = gdbarch_find_by_info (info);
 
   if (gdbarch == NULL)
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 44dea711a39..0d50aadddb8 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -607,9 +607,9 @@ target_clear_description (void)
    an existing gdbarch.  */
 
 const struct target_desc *
-target_current_description (void)
+target_current_description (inferior *inf)
 {
-  target_desc_info *tdesc_info = get_tdesc_info (current_inferior ());
+  target_desc_info *tdesc_info = get_tdesc_info (inf);
 
   if (tdesc_info->fetched)
     return tdesc_info->tdesc;
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 3ab0ae2542d..3049b783e2f 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -46,7 +46,7 @@ void target_clear_description (void);
    be used by gdbarch initialization code; most access should be
    through an existing gdbarch.  */
 
-const struct target_desc *target_current_description (void);
+const struct target_desc *target_current_description (inferior *inf);
 
 /* Copy inferior target description data.  Used for example when
    handling (v)forks, where child's description is the same as the
-- 
2.37.3



More information about the Gdb-patches mailing list