diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f7bce0d0399..f281914ce54 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -251,7 +251,7 @@ post_create_inferior (int from_tty)
      Targets which need to access registers during to_open,
      to_create_inferior, or to_attach should do it earlier; but many
      don't need to.  */
-  target_find_description ();
+  target_find_description (current_inferior ());
 
   /* Now that we know the register layout, retrieve current PC.  But
      if the PC is unavailable (e.g., we're opening a core file with
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 96346e1f25b..c678d5accce 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1272,7 +1272,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
      architecture, and the old executable may e.g., be 32-bit, while
      the new one 64-bit), and before anything involving memory or
      registers.  */
-  target_find_description ();
+  target_find_description (inf);
 
   gdb::observers::inferior_execd.notify (inf);
 
diff --git a/gdb/remote.c b/gdb/remote.c
index 5118ecd0a31..ca6fd535a54 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4826,7 +4826,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
 
   /* Next, if the target can specify a description, read it.  We do
      this before anything involving memory or registers.  */
-  target_find_description ();
+  target_find_description (current_inferior ());
 
   /* Next, now that we know something about the target, update the
      address spaces in the program spaces.  */
@@ -4963,7 +4963,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
 	  && gdbarch_target_desc (target_gdbarch ()) == NULL)
 	{
 	  target_clear_description ();
-	  target_find_description ();
+	  target_find_description (current_inferior ());
 	}
 
       /* Use the previously fetched status.  */
@@ -6187,7 +6187,7 @@ extended_remote_target::attach (const char *args, int from_tty)
 
   /* Next, if the target can specify a description, read it.  We do
      this before anything involving memory or registers.  */
-  target_find_description ();
+  target_find_description (current_inferior ());
 
   if (!target_is_non_stop_p ())
     {
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 57d23747f26..40c04e0770f 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -520,13 +520,12 @@ target_desc_info_free (struct target_desc_info *tdesc_info)
 
 static std::string tdesc_filename_cmd_string;
 
-/* Fetch the current target's description, and switch the current
-   architecture to one which incorporates that description.  */
+/* See target-descriptions.h.  */
 
 void
-target_find_description (void)
+target_find_description (inferior *inf)
 {
-  target_desc_info *tdesc_info = get_tdesc_info (current_inferior ());
+  target_desc_info *tdesc_info = get_tdesc_info (inf);
 
   /* If we've already fetched a description from the target, don't do
      it again.  This allows a target to fetch the description early,
@@ -538,7 +537,7 @@ target_find_description (void)
   /* The current architecture should not have any target description
      specified.  It should have been cleared, e.g. when we
      disconnected from the previous target.  */
-  gdb_assert (gdbarch_target_desc (target_gdbarch ()) == NULL);
+  gdb_assert (gdbarch_target_desc (inf->gdbarch) == nullptr);
 
   /* First try to fetch an XML description from the user-specified
      file.  */
@@ -546,16 +545,22 @@ target_find_description (void)
   if (!tdesc_info->filename.empty ())
     tdesc_info->tdesc = file_read_description_xml (tdesc_info->filename.data ());
 
+  /* The calls that get the target description from the target depend on INF
+     being the current inferior, and some targets need a specific thread to
+     be selected.  */
+  scoped_restore_current_thread restore_thread;
+  thread_info *thread = any_thread_of_inferior (inf);
+  gdb_assert (thread != nullptr);
+  switch_to_thread (thread);
+
   /* Next try to read the description from the current target using
      target objects.  */
   if (tdesc_info->tdesc == nullptr)
-    tdesc_info->tdesc = target_read_description_xml
-      (current_inferior ()->top_target ());
+    tdesc_info->tdesc = target_read_description_xml (inf->top_target ());
 
   /* If that failed try a target-specific hook.  */
   if (tdesc_info->tdesc == nullptr)
-    tdesc_info->tdesc = target_read_description
-      (current_inferior ()->top_target ());
+    tdesc_info->tdesc = target_read_description (inf->top_target ());
 
   /* If a non-NULL description was returned, then update the current
      architecture.  */
@@ -564,13 +569,13 @@ target_find_description (void)
       struct gdbarch_info info;
 
       info.target_desc = tdesc_info->tdesc;
-      if (!gdbarch_update_p (current_inferior (), info))
+      if (!gdbarch_update_p (inf, info))
 	warning (_("Architecture rejected target-supplied description"));
       else
 	{
 	  struct tdesc_arch_data *data;
 
-	  data = get_arch_data (target_gdbarch ());
+	  data = get_arch_data (inf->gdbarch);
 	  if (tdesc_has_registers (tdesc_info->tdesc)
 	      && data->arch_regs.empty ())
 	    warning (_("Target-supplied registers are not supported "
@@ -1289,7 +1294,7 @@ set_tdesc_filename_cmd (const char *args, int from_tty,
   tdesc_info->filename = tdesc_filename_cmd_string;
 
   target_clear_description ();
-  target_find_description ();
+  target_find_description (current_inferior ());
 }
 
 static void
@@ -1316,7 +1321,7 @@ unset_tdesc_filename_cmd (const char *args, int from_tty)
 
   tdesc_info->filename.clear ();
   target_clear_description ();
-  target_find_description ();
+  target_find_description (current_inferior ());
 }
 
 /* Print target description in C.  */
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 3049b783e2f..ab534488d65 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -31,10 +31,10 @@ struct target_ops;
 struct target_desc_info;
 struct inferior;
 
-/* Fetch the current inferior's description, and switch its current
-   architecture to one which incorporates that description.  */
+/* Fetch INFERIOR's target description, and switch its architecture to one which
+   incorporates that description.  */
 
-void target_find_description (void);
+void target_find_description (inferior *inf);
 
 /* Discard any description fetched from the target for the current
    inferior, and switch the current architecture to one with no target
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 3266f357a27..b8302902af4 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -538,7 +538,7 @@ tfile_target_open (const char *arg, int from_tty)
 	}
 
       /* By now, tdesc lines have been read from tfile - let's parse them.  */
-      target_find_description ();
+      target_find_description (current_inferior ());
 
       /* Record the starting offset of the binary trace data.  */
       trace_frames_offset = bytes;
