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
This commit is contained in:
Simon Marchi 2021-03-23 09:46:49 -04:00
parent 02980c5645
commit c8fbd44a01
10 changed files with 24 additions and 29 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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);

View file

@ -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));

View file

@ -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)
{

View file

@ -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 ();

View file

@ -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,

View file

@ -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);

View file

@ -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);

View file

@ -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 ();