public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] gdb: remove target_is_pushed free function
Date: Sun, 21 Mar 2021 23:20:27 -0400	[thread overview]
Message-ID: <20210322032027.3397705-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20210322032027.3397705-1-simon.marchi@polymtl.ca>

Same principle as the previous patches.

gdb/ChangeLog:

	* target.h (target_is_pushed): Remove, update callers to use
	inferior::target_is_pushed instead.
	* target.c (target_is_pushed): Remove.

Change-Id: I9862e6205acc65672da807cbe4b46cde009e7b9d
---
 gdb/darwin-nat.c  |  2 +-
 gdb/gnu-nat.c     |  5 +++--
 gdb/go32-nat.c    |  2 +-
 gdb/inf-ptrace.c  | 15 +++++++--------
 gdb/nto-procfs.c  |  4 ++--
 gdb/procfs.c      |  4 ++--
 gdb/target.c      | 11 +----------
 gdb/target.h      |  2 --
 gdb/windows-nat.c |  2 +-
 9 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index f8e4443ff408..587f53174163 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1658,7 +1658,7 @@ darwin_attach_pid (struct inferior *inf)
     }
 
   target_ops *darwin_ops = get_native_target ();
-  if (!target_is_pushed (darwin_ops))
+  if (!inf->target_is_pushed (darwin_ops))
     inf->push_target (darwin_ops);
 }
 
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 9ea4c4089340..816f901ce23e 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2109,12 +2109,13 @@ gnu_nat_target::create_inferior (const char *exec_file,
 				 int from_tty)
 {
   struct inf *inf = cur_inf ();
+  inferior *inferior = current_inferior ();
   int pid;
 
   inf_debug (inf, "creating inferior");
 
-  if (!target_is_pushed (this))
-    current_inferior ()->push_target (this);
+  if (!inf->target_is_pushed (this))
+    inf->push_target (this);
 
   pid = fork_inferior (exec_file, allargs, env, gnu_ptrace_me,
 		       NULL, NULL, NULL, NULL);
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 79c31fcd9877..9899545a1e21 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -756,7 +756,7 @@ go32_nat_target::create_inferior (const char *exec_file,
   inf = current_inferior ();
   inferior_appeared (inf, SOME_PID);
 
-  if (!target_is_pushed (this))
+  if (!inf->target_is_pushed (this))
     inf->push_target (this);
 
   thread_info *thr = add_thread_silent (ptid_t (SOME_PID));
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index e630ba447f40..b6fa71fd2c0b 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -74,15 +74,17 @@ inf_ptrace_target::create_inferior (const char *exec_file,
 				    const std::string &allargs,
 				    char **env, int from_tty)
 {
+  inferior *inf = current_inferior ();
+
   /* Do not change either targets above or the same target if already present.
      The reason is the target stack is shared across multiple inferiors.  */
-  int ops_already_pushed = target_is_pushed (this);
+  int ops_already_pushed = inf->target_is_pushed (this);
 
   target_unpush_up unpusher;
   if (! ops_already_pushed)
     {
       /* Clear possible core file with its process_stratum.  */
-      current_inferior ()->push_target (this);
+      inf->push_target (this);
       unpusher.reset (this);
     }
 
@@ -127,20 +129,17 @@ inf_ptrace_target::mourn_inferior ()
 void
 inf_ptrace_target::attach (const char *args, int from_tty)
 {
-  pid_t pid;
-  struct inferior *inf;
+  inferior *inf = current_inferior ();
 
   /* Do not change either targets above or the same target if already present.
      The reason is the target stack is shared across multiple inferiors.  */
-  int ops_already_pushed = target_is_pushed (this);
+  int ops_already_pushed = inf->target_is_pushed (this);
 
-  pid = parse_pid_to_attach (args);
+  pid_t pid = parse_pid_to_attach (args);
 
   if (pid == getpid ())		/* Trying to masturbate?  */
     error (_("I refuse to debug myself!"));
 
-  inf = current_inferior ();
-
   target_unpush_up unpusher;
   if (! ops_already_pushed)
     {
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index b74392fef320..41b436cfa27f 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -717,7 +717,7 @@ nto_procfs_target::attach (const char *args, int from_tty)
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
 
-  if (!target_is_pushed (ops))
+  if (!inf->target_is_pushed (ops))
     inf->push_target (ops);
 
   update_thread_list ();
@@ -1318,7 +1318,7 @@ nto_procfs_target::create_inferior (const char *exec_file,
       /* warning( "Failed to set Kill-on-Last-Close flag: errno = %d(%s)\n",
 	 errn, safe_strerror(errn) ); */
     }
-  if (!target_is_pushed (ops))
+  if (!inf->target_is_pushed (ops))
     inf->push_target (ops);
   target_terminal::init ();
 
diff --git a/gdb/procfs.c b/gdb/procfs.c
index b37680923cd8..91d2039e3f9a 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1769,7 +1769,7 @@ procfs_target::attach (const char *args, int from_tty)
 
   /* Push the target if needed, ensure it gets un-pushed it if attach fails.  */
   target_unpush_up unpusher;
-  if (!target_is_pushed (this))
+  if (!inf->target_is_pushed (this))
     {
       current_inferior ()->push_target (this);
       unpusher.reset (this);
@@ -2862,7 +2862,7 @@ procfs_target::create_inferior (const char *exec_file,
       shell_file = tryname;
     }
 
-  if (!target_is_pushed (this))
+  if (!inf->target_is_pushed (this))
     current_inferior ()->push_target (this);
 
   pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap,
diff --git a/gdb/target.c b/gdb/target.c
index fe9731221efd..afc4b2cbbb60 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -647,15 +647,6 @@ pop_all_targets (void)
   pop_all_targets_above (dummy_stratum);
 }
 
-/* Return true if T is now pushed in the current inferior's target
-   stack.  Return false otherwise.  */
-
-bool
-target_is_pushed (target_ops *t)
-{
-  return current_inferior ()->target_is_pushed (t);
-}
-
 void
 target_unpusher::operator() (struct target_ops *ops) const
 {
@@ -3097,7 +3088,7 @@ debug_target::info () const
 void
 target_close (struct target_ops *targ)
 {
-  gdb_assert (!target_is_pushed (targ));
+  gdb_assert (!current_inferior ()->target_is_pushed (targ));
 
   fileio_handles_invalidate_target (targ);
 
diff --git a/gdb/target.h b/gdb/target.h
index 1830d3a8106f..6b71e741f6d7 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -2411,8 +2411,6 @@ extern void pop_all_targets_at_and_above (enum strata stratum);
    strictly above ABOVE_STRATUM.  */
 extern void pop_all_targets_above (enum strata above_stratum);
 
-extern bool target_is_pushed (target_ops *t);
-
 extern CORE_ADDR target_translate_tls_address (struct objfile *objfile,
 					       CORE_ADDR offset);
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 51662896d691..00f83536e330 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2028,7 +2028,7 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching)
   current_event.dwProcessId = pid;
   memset (&current_event, 0, sizeof (current_event));
   inf = current_inferior ();
-  if (!target_is_pushed (this))
+  if (!inf->target_is_pushed (this))
     inf->push_target (this);
   disable_breakpoints_in_shlibs ();
   windows_clear_solib ();
-- 
2.30.1


  parent reply	other threads:[~2021-03-22  3:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  3:20 [PATCH 1/3] gdb: remove unpush_target " Simon Marchi
2021-03-22  3:20 ` [PATCH 2/3] gdb: remove push_target free functions Simon Marchi
2021-03-22 16:30   ` Aktemur, Tankut Baris
2021-03-22 17:31     ` Simon Marchi
2021-03-22 18:21       ` Simon Marchi
2021-03-23 10:25         ` Aktemur, Tankut Baris
2021-03-23 13:50         ` Simon Marchi
2021-03-22  3:20 ` Simon Marchi [this message]
2021-03-22 16:22 ` [PATCH 1/3] gdb: remove unpush_target free function Aktemur, Tankut Baris
2021-03-22 17:25   ` Simon Marchi
2021-03-22 18:11     ` Simon Marchi

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=20210322032027.3397705-3-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /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).