public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 5/5] gdb: add inferior parameter to target_clear_description
Date: Thu, 24 Nov 2022 11:04:28 -0500	[thread overview]
Message-ID: <20221124160428.83804-6-simon.marchi@efficios.com> (raw)
In-Reply-To: <20221124160428.83804-1-simon.marchi@efficios.com>

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

Make target_clear_description not dependent on the current inferior on
entry.  Add an inferior parameter, and make it switch the current
inferior temporarily where needed.

Mkae the callers pass the current inferior, no change in behavior is
expected.

Change-Id: I85e4c500fceee9fc037f209d188e608536ed3f13
---
 gdb/infrun.c              |  2 +-
 gdb/remote.c              |  2 +-
 gdb/target-descriptions.c | 13 ++++++-------
 gdb/target-descriptions.h |  2 +-
 gdb/target.c              |  2 +-
 5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index c678d5accce..02ca137f545 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1252,7 +1252,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
 	 this on "follow-exec-mode new", as the old inferior stays
 	 around (its description is later cleared/refetched on
 	 restart).  */
-      target_clear_description ();
+      target_clear_description (inf);
       target_follow_exec (inf, ptid, exec_file_target);
     }
 
diff --git a/gdb/remote.c b/gdb/remote.c
index ca6fd535a54..cf3b2c92d36 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4962,7 +4962,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
       if (remote_read_description_p (this)
 	  && gdbarch_target_desc (target_gdbarch ()) == NULL)
 	{
-	  target_clear_description ();
+	  target_clear_description (current_inferior ());
 	  target_find_description (current_inferior ());
 	}
 
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 40c04e0770f..1abe5c8ead6 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -588,13 +588,12 @@ target_find_description (inferior *inf)
   tdesc_info->fetched = true;
 }
 
-/* Discard any description fetched from the current target, and switch
-   the current architecture to one with no target description.  */
+/* See target-descriptions.h.  */
 
 void
-target_clear_description (void)
+target_clear_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;
@@ -603,7 +602,7 @@ target_clear_description (void)
   tdesc_info->tdesc = nullptr;
 
   gdbarch_info info;
-  if (!gdbarch_update_p (current_inferior (), info))
+  if (!gdbarch_update_p (inf, info))
     internal_error (_("Could not remove target-supplied description"));
 }
 
@@ -1293,7 +1292,7 @@ set_tdesc_filename_cmd (const char *args, int from_tty,
 
   tdesc_info->filename = tdesc_filename_cmd_string;
 
-  target_clear_description ();
+  target_clear_description (current_inferior ());
   target_find_description (current_inferior ());
 }
 
@@ -1320,7 +1319,7 @@ unset_tdesc_filename_cmd (const char *args, int from_tty)
   target_desc_info *tdesc_info = get_tdesc_info (current_inferior ());
 
   tdesc_info->filename.clear ();
-  target_clear_description ();
+  target_clear_description (current_inferior ());
   target_find_description (current_inferior ());
 }
 
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index ab534488d65..5f89e933b6d 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -40,7 +40,7 @@ void target_find_description (inferior *inf);
    inferior, and switch the current architecture to one with no target
    description.  */
 
-void target_clear_description (void);
+void target_clear_description (inferior *inf);
 
 /* Return the current inferior's target description.  This should only
    be used by gdbarch initialization code; most access should be
diff --git a/gdb/target.c b/gdb/target.c
index 74925e139dc..bd3b6c98a57 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2484,7 +2484,7 @@ target_pre_inferior (int from_tty)
 
       invalidate_target_mem_regions ();
 
-      target_clear_description ();
+      target_clear_description (current_inferior ());
     }
 
   /* attach_flag may be set if the previous process associated with
-- 
2.37.3


      parent reply	other threads:[~2022-11-24 16:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 16:04 [PATCH 0/5] Make some functions independent of current inferior Simon Marchi
2022-11-24 16:04 ` [PATCH 1/5] gdb: add inferior parameter to target_current_description Simon Marchi
2022-11-24 16:04 ` [PATCH 2/5] gdb: add inferior parameter to set_target_gdbarch, rename to set_inferior_gdbarch Simon Marchi
2022-11-24 16:42   ` Lancelot SIX
2022-11-24 16:47     ` Simon Marchi
2022-11-24 16:04 ` [PATCH 3/5] gdb: add inferior parameter to gdbarch_update_p Simon Marchi
2022-11-24 16:04 ` [PATCH 4/5] gdb: add inferior parameter to target_find_description Simon Marchi
2022-11-24 16:25   ` Simon Marchi
2022-11-24 16:04 ` Simon Marchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221124160428.83804-6-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).