[binutils-gdb] gdb: remove target_is_pushed free function
Simon Marchi
simark@sourceware.org
Tue Mar 23 13:51:09 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c8fbd44a018a9923f906bfd2be5489caa87b602a
commit c8fbd44a018a9923f906bfd2be5489caa87b602a
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Tue Mar 23 09:46:49 2021 -0400
gdb: remove target_is_pushed free function
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
Diff:
---
gdb/ChangeLog | 6 ++++++
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 +-
10 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 274e157905d..b6639ee77ad 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2021-03-23 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * target.h (target_is_pushed): Remove, update callers to use
+ inferior::target_is_pushed instead.
+ * target.c (target_is_pushed): Remove.
+
2021-03-23 Simon Marchi <simon.marchi@polymtl.ca>
* target.h (push_target): Remove, update callers to use
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index f8e4443ff40..587f5317416 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 9ea4c408934..816f901ce23 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 79c31fcd987..9899545a1e2 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 e630ba447f4..b6fa71fd2c0 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 b74392fef32..41b436cfa27 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 b37680923cd..91d2039e3f9 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 fe9731221ef..afc4b2cbbb6 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 1830d3a8106..6b71e741f6d 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 51662896d69..00f83536e33 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 (¤t_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 ();
More information about the Gdb-cvs
mailing list