Same as the previous patch, but for the push_target functions.
The implementation of the move variant is moved to a new overload of
inferior::push_target.
gdb/ChangeLog:
* target.h (push_target): Remove, update callers to use
inferior::push_target.
* target.c (push_target): Remove.
* inferior.h (class inferior) <push_target>: New overload.
Change-Id: I5a95496666278b8f3965e5e8aecb76f54a97c185
+2021-03-23 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * target.h (push_target): Remove, update callers to use
+ inferior::push_target.
+ * target.c (push_target): Remove.
+ * inferior.h (class inferior) <push_target>: New overload.
+
2021-03-23 Simon Marchi <simon.marchi@polymtl.ca>
* target.h (unpush_target): Remove, update all callers
return;
/* Prepare for thread debugging. */
- push_target (&aix_thread_ops);
+ current_inferior ()->push_target (&aix_thread_ops);
pd_able = 1;
/* If we're debugging a core file or an attached inferior, the
bsd_kvm_corefile = filename;
current_inferior ()->unpush_target (&bsd_kvm_ops);
core_kd = temp_kd;
- push_target (&bsd_kvm_ops);
+ current_inferior ()->push_target (&bsd_kvm_ops);
thread_info *thr = add_thread_silent (&bsd_kvm_ops, bsd_kvm_ptid);
switch_to_thread (thr);
bsd_uthread_thread_ctx_offset =
bsd_uthread_lookup_offset ("_thread_ctx_offset", objfile);
- push_target (&bsd_uthread_ops);
+ current_inferior ()->push_target (&bsd_uthread_ops);
bsd_uthread_active = 1;
return 1;
}
if (!current_program_space->exec_bfd ())
set_gdbarch_from_file (core_bfd);
- push_target (std::move (target_holder));
+ current_inferior ()->push_target (std::move (target_holder));
switch_to_no_thread ();
target_ops *darwin_ops = get_native_target ();
if (!target_is_pushed (darwin_ops))
- push_target (darwin_ops);
+ inf->push_target (darwin_ops);
}
/* Get the thread_info object corresponding to this darwin_thread_info. */
continue;
switch_to_inferior_no_thread (inf);
- push_target (&exec_ops);
+ inf->push_target (&exec_ops);
}
}
}
exec_on_vfork ()
{
if (!current_program_space->target_sections ().empty ())
- push_target (&exec_ops);
+ current_inferior ()->push_target (&exec_ops);
}
\f
inf_debug (inf, "creating inferior");
if (!target_is_pushed (this))
- push_target (this);
+ current_inferior ()->push_target (this);
pid = fork_inferior (exec_file, allargs, env, gnu_ptrace_me,
NULL, NULL, NULL, NULL);
inf_attach (inf, pid);
- push_target (this);
-
inferior = current_inferior ();
+ inferior->push_target (this);
+
inferior_appeared (inferior, pid);
inferior->attach_flag = 1;
inferior_appeared (inf, SOME_PID);
if (!target_is_pushed (this))
- push_target (this);
+ inf->push_target (this);
thread_info *thr = add_thread_silent (ptid_t (SOME_PID));
switch_to_thread (thr);
gdb_assert (dynamic_cast<inf_child_target *> (target) != NULL);
target_preopen (from_tty);
- push_target (target);
+ current_inferior ()->push_target (target);
inf_child_explicitly_opened = 1;
if (from_tty)
printf_filtered ("Done. Use the \"run\" command to start a process.\n");
if (! ops_already_pushed)
{
/* Clear possible core file with its process_stratum. */
- push_target (this);
+ current_inferior ()->push_target (this);
unpusher.reset (this);
}
if (pid == getpid ()) /* Trying to masturbate? */
error (_("I refuse to debug myself!"));
+ inf = current_inferior ();
+
target_unpush_up unpusher;
if (! ops_already_pushed)
{
/* target_pid_to_str already uses the target. Also clear possible core
file with its process_stratum. */
- push_target (this);
+ inf->push_target (this);
unpusher.reset (this);
}
error (_("This system does not support attaching to a process"));
#endif
- inf = current_inferior ();
inferior_appeared (inf, pid);
inf->attach_flag = 1;
/* Reuse the target for new inferior. */
if (!no_connection && proc_target != NULL)
{
- push_target (proc_target);
+ new_inf->push_target (proc_target);
if (proc_target->connection_string () != NULL)
printf_filtered (_("Added inferior %d on connection %d (%s %s)\n"),
new_inf->num,
void push_target (struct target_ops *t)
{ m_target_stack.push (t); }
+ /* An overload that deletes the target on failure. */
+ void push_target (target_ops_up &&t)
+ {
+ m_target_stack.push (t.get ());
+ t.release ();
+ }
+
/* Unpush T from this inferior's target stack. */
int unpush_target (struct target_ops *t)
{ return m_target_stack.unpush (t); }
set_current_inferior (child_inf);
switch_to_no_thread ();
child_inf->symfile_flags = SYMFILE_NO_READ;
- push_target (parent_inf->process_target ());
+ child_inf->push_target (parent_inf->process_target ());
thread_info *child_thr
= add_thread_silent (child_inf->process_target (), child_ptid);
informing the solib layer about this new process. */
set_current_inferior (child_inf);
- push_target (target);
+ child_inf->push_target (target);
}
thread_info *child_thr = add_thread_silent (target, child_ptid);
inferior *org_inferior = current_inferior ();
switch_to_inferior_no_thread (inf);
- push_target (org_inferior->process_target ());
+ inf->push_target (org_inferior->process_target ());
thread_info *thr = add_thread (inf->process_target (), ptid);
switch_to_thread (thr);
}
/* The thread library was detected. Activate the thread_db target
for this process. */
- push_target (&the_thread_db_target);
+ current_inferior ()->push_target (&the_thread_db_target);
return true;
}
inf->attach_flag = 1;
if (!target_is_pushed (ops))
- push_target (ops);
+ inf->push_target (ops);
update_thread_list ();
errn, safe_strerror(errn) ); */
}
if (!target_is_pushed (ops))
- push_target (ops);
+ inf->push_target (ops);
target_terminal::init ();
if (current_program_space->exec_bfd () != NULL
target_unpush_up unpusher;
if (!target_is_pushed (this))
{
- push_target (this);
+ current_inferior ()->push_target (this);
unpusher.reset (this);
}
}
if (!target_is_pushed (this))
- push_target (this);
+ current_inferior ()->push_target (this);
pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap,
NULL, procfs_pre_trace, shell_file, NULL);
}
ravenscar_thread_target *rtarget = new ravenscar_thread_target ();
- push_target (target_ops_up (rtarget));
+ inf->push_target (target_ops_up (rtarget));
thread_info *thr = rtarget->add_active_thread ();
if (thr != nullptr)
switch_to_thread (thr);
record_btrace_auto_enable ();
- push_target (&record_btrace_ops);
+ current_inferior ()->push_target (&record_btrace_ops);
record_btrace_async_inferior_event_handler
= create_async_event_handler (record_btrace_handle_async_inferior_event,
record_full_core_sections = build_section_table (core_bfd);
- push_target (&record_full_core_ops);
+ current_inferior ()->push_target (&record_full_core_ops);
record_full_restore ();
}
error (_("Process record: the current architecture doesn't support "
"record function."));
- push_target (&record_full_ops);
+ current_inferior ()->push_target (&record_full_ops);
}
static void record_full_init_record_breakpoints (void);
/* Push the process_stratum target so we can mock accessing
registers. */
- push_target (&mock_target);
+ current_inferior ()->push_target (&mock_target);
/* Pop it again on exit (return/exception). */
struct on_exit
sim_data->gdbsim_desc = gdbsim_desc;
- push_target (&gdbsim_ops);
+ current_inferior ()->push_target (&gdbsim_ops);
printf_filtered ("Connected to the simulator.\n");
/* There's nothing running after "target sim" or "load"; not until
inf = add_inferior_with_spaces ();
}
switch_to_inferior_no_thread (inf);
- push_target (this);
+ inf->push_target (this);
inferior_appeared (inf, pid);
}
}
/* Switch to using the remote target now. */
- push_target (std::move (target_holder));
+ current_inferior ()->push_target (std::move (target_holder));
/* Register extra event sources in the event loop. */
rs->remote_async_inferior_event_token
/* Push the process_stratum target so we can mock accessing
registers. */
gdb_assert (mock_target.stratum () == process_stratum);
- push_target (&mock_target);
+ mock_inferior.push_target (&mock_target);
/* Switch to the mock thread. */
switch_to_thread (&mock_thread);
printf_unfiltered (_("[Thread debugging using libthread_db enabled]\n"));
/* The thread library was detected. Activate the sol_thread target. */
- push_target (&sol_thread_ops);
+ current_inferior ()->push_target (&sol_thread_ops);
sol_thread_active = 1;
main_ph.ptid = inferior_ptid; /* Save for xfer_memory. */
set_targetdebug (const char *args, int from_tty, struct cmd_list_element *c)
{
if (targetdebug)
- push_target (the_debug_target);
+ current_inferior ()->push_target (the_debug_target);
else
current_inferior ()->unpush_target (the_debug_target);
}
/* See target.h. */
-void
-push_target (struct target_ops *t)
-{
- current_inferior ()->push_target (t);
-}
-
-/* See target.h. */
-
-void
-push_target (target_ops_up &&t)
-{
- current_inferior ()->push_target (t.get ());
- t.release ();
-}
-
-/* See target.h. */
-
bool
target_stack::unpush (target_ops *t)
{
extern void add_deprecated_target_alias (const target_info &info,
const char *alias);
-extern void push_target (struct target_ops *);
-
-/* An overload that deletes the target on failure. */
-extern void push_target (target_ops_up &&);
-
/* A unique_ptr helper to unpush a target. */
struct target_unpusher
gdb_assert (start_pos->type == BT_SEEK_RESTORE);
trace_dirname = xstrdup (dirname);
- push_target (&ctf_ops);
+ current_inferior ()->push_target (&ctf_ops);
inferior_appeared (current_inferior (), CTF_PID);
&& (startswith (header + 1, "TRACE0\n"))))
error (_("File is not a valid trace file."));
- push_target (&tfile_ops);
+ current_inferior ()->push_target (&tfile_ops);
trace_regblock_size = 0;
ts = current_trace_status ();
#endif
current_event.dwProcessId = pid;
memset (¤t_event, 0, sizeof (current_event));
+ inf = current_inferior ();
if (!target_is_pushed (this))
- push_target (this);
+ inf->push_target (this);
disable_breakpoints_in_shlibs ();
windows_clear_solib ();
clear_proceed_status (0);
windows_set_segment_register_p (i386_windows_segment_register_p);
}
- inf = current_inferior ();
inferior_appeared (inf, pid);
inf->attach_flag = attaching;