+2014-12-15 Simon Marchi <simon.marchi@ericsson.com>
+
+ * inferior.c (find_inferior_ptid): New function.
+ * inferior.h (find_inferior_ptid): New declaration.
+ * ada-tasks.c (ada_get_task_number): Use find_inferior_ptid.
+ * corelow.c (core_pid_to_str): Same.
+ * darwin-nat.c (darwin_resume): Same.
+ * infrun.c (fetch_inferior_event): Same.
+ (get_inferior_stop_soon): Same.
+ (handle_inferior_event): Same.
+ (handle_signal_stop): Same.
+ * linux-nat.c (resume_lwp): Same.
+ (stop_wait_callback): Same.
+ * mi/mi-interp.c (mi_new_thread): Same.
+ (mi_thread_exit): Same.
+ * proc-service.c (ps_pglobal_lookup): Same.
+ * record-btrace.c (record_btrace_step_thread): Same.
+ * remote-sim.c (gdbsim_close_inferior): Same.
+ (gdbsim_resume): Same.
+ (gdbsim_stop): Same.
+ * sol2-tdep.c (sol2_core_pid_to_str): Same.
+ * target.c (memory_xfer_partial_1): Same.
+ (default_thread_address_space): Same.
+ * thread.c (thread_change_ptid): Same.
+ (switch_to_thread): Same.
+ (do_restore_current_thread_cleanup): Same.
+
2014-12-15 Simon Marchi <simon.marchi@ericsson.com>
* defs.h (gdb_readline): Constify argument.
ada_get_task_number (ptid_t ptid)
{
int i;
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid));
+ struct inferior *inf = find_inferior_ptid (ptid);
struct ada_tasks_inferior_data *data;
gdb_assert (inf != NULL);
Without argument, this command simply prints the current task ID"),
&cmdlist);
}
-
/* Otherwise, this isn't a "threaded" core -- use the PID field, but
only if it isn't a fake PID. */
- inf = find_inferior_pid (ptid_get_pid (ptid));
+ inf = find_inferior_ptid (ptid);
if (inf != NULL && !inf->fake_pid_p)
return normal_pid_to_str (ptid);
}
else
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid));
+ struct inferior *inf = find_inferior_ptid (ptid);
long tid = ptid_get_tid (ptid);
/* Stop the inferior (should be useless). */
return NULL;
}
+/* See inferior.h */
+
+struct inferior *
+find_inferior_ptid (ptid_t ptid)
+{
+ return find_inferior_pid (ptid_get_pid (ptid));
+}
+
/* See inferior.h. */
struct inferior *
/* Search function to lookup an inferior by target 'pid'. */
extern struct inferior *find_inferior_pid (int pid);
+/* Search function to lookup an inferior whose pid is equal to 'ptid.pid'. */
+extern struct inferior *find_inferior_ptid (ptid_t ptid);
+
/* Search function to lookup an inferior by GDB 'num'. */
extern struct inferior *find_inferior_id (int num);
if (!ecs->wait_some_more)
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid));
+ struct inferior *inf = find_inferior_ptid (ecs->ptid);
delete_just_stopped_threads_infrun_breakpoints ();
static enum stop_kind
get_inferior_stop_soon (ptid_t ptid)
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid));
+ struct inferior *inf = find_inferior_ptid (ptid);
gdb_assert (inf != NULL);
return inf->control.stop_soon;
}
inferior_ptid = ecs->ptid;
- set_current_inferior (find_inferior_pid (ptid_get_pid (ecs->ptid)));
+ set_current_inferior (find_inferior_ptid (ecs->ptid));
set_current_program_space (current_inferior ()->pspace);
handle_vfork_child_exec_or_exit (0);
target_terminal_ours (); /* Must do this before mourn anyway. */
if (displaced && ptid_equal (displaced->step_ptid, ecs->ptid))
{
struct inferior *parent_inf
- = find_inferior_pid (ptid_get_pid (ecs->ptid));
+ = find_inferior_ptid (ecs->ptid);
struct regcache *child_regcache;
CORE_ADDR parent_pc;
if (random_signal)
{
/* Signal not for debugging purposes. */
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid));
+ struct inferior *inf = find_inferior_ptid (ecs->ptid);
enum gdb_signal stop_signal = ecs->event_thread->suspend.stop_signal;
if (debug_infrun)
{
if (lp->stopped)
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (lp->ptid));
+ struct inferior *inf = find_inferior_ptid (lp->ptid);
if (inf->vfork_child != NULL)
{
static int
stop_wait_callback (struct lwp_info *lp, void *data)
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (lp->ptid));
+ struct inferior *inf = find_inferior_ptid (lp->ptid);
/* If this is a vfork parent, bail out, it is not going to report
any SIGSTOP until the vfork is done with. */
mi_new_thread (struct thread_info *t)
{
struct mi_interp *mi = top_level_interpreter_data ();
- struct inferior *inf = find_inferior_pid (ptid_get_pid (t->ptid));
+ struct inferior *inf = find_inferior_ptid (t->ptid);
gdb_assert (inf);
if (silent)
return;
- inf = find_inferior_pid (ptid_get_pid (t->ptid));
+ inf = find_inferior_ptid (t->ptid);
mi = top_level_interpreter_data ();
old_chain = make_cleanup_restore_target_terminal ();
{
struct bound_minimal_symbol ms;
struct cleanup *old_chain = save_current_program_space ();
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ph->ptid));
+ struct inferior *inf = find_inferior_ptid (ph->ptid);
ps_err_e result;
set_current_program_space (inf->pspace);
if (replay == NULL)
return btrace_step_no_history ();
- inf = find_inferior_pid (ptid_get_pid (tp->ptid));
+ inf = find_inferior_ptid (tp->ptid);
aspace = inf->aspace;
/* Determine the end of the instruction trace. */
if (replay == NULL)
replay = record_btrace_start_replaying (tp);
- inf = find_inferior_pid (ptid_get_pid (tp->ptid));
+ inf = find_inferior_ptid (tp->ptid);
aspace = inf->aspace;
for (;;)
Thus we need to verify the existence of an inferior using the
pid in question before setting inferior_ptid via
switch_to_thread() or mourning the inferior. */
- if (find_inferior_pid (ptid_get_pid (ptid)) != NULL)
+ if (find_inferior_ptid (ptid) != NULL)
{
switch_to_thread (ptid);
generic_mourn_inferior ();
either have multiple inferiors to resume or an error condition. */
if (sim_data)
- gdbsim_resume_inferior (find_inferior_pid (ptid_get_pid (ptid)), &rd);
+ gdbsim_resume_inferior (find_inferior_ptid (ptid), &rd);
else if (ptid_equal (ptid, minus_one_ptid))
iterate_over_inferiors (gdbsim_resume_inferior, &rd);
else
}
else
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid));
+ struct inferior *inf = find_inferior_ptid (ptid);
if (inf == NULL)
error (_("Can't stop pid %d. No inferior found."),
/* GDB didn't use to put a NT_PSTATUS note in Solaris cores. If
that's missing, then we're dealing with a fake PID corelow.c made
up. */
- inf = find_inferior_pid (ptid_get_pid (ptid));
+ inf = find_inferior_ptid (ptid);
if (inf == NULL || inf->fake_pid_p)
{
xsnprintf (buf, sizeof buf, "<core>");
return TARGET_XFER_E_IO;
if (!ptid_equal (inferior_ptid, null_ptid))
- inf = find_inferior_pid (ptid_get_pid (inferior_ptid));
+ inf = find_inferior_ptid (inferior_ptid);
else
inf = NULL;
struct inferior *inf;
/* Fall-back to the "main" address space of the inferior. */
- inf = find_inferior_pid (ptid_get_pid (ptid));
+ inf = find_inferior_ptid (ptid);
if (inf == NULL || inf->aspace == NULL)
internal_error (__FILE__, __LINE__,
/* It can happen that what we knew as the target inferior id
changes. E.g, target remote may only discover the remote process
pid after adding the inferior to GDB's list. */
- inf = find_inferior_pid (ptid_get_pid (old_ptid));
+ inf = find_inferior_ptid (old_ptid);
inf->pid = ptid_get_pid (new_ptid);
tp = find_thread_ptid (old_ptid);
{
struct inferior *inf;
- inf = find_inferior_pid (ptid_get_pid (ptid));
+ inf = find_inferior_ptid (ptid);
gdb_assert (inf != NULL);
set_current_program_space (inf->pspace);
set_current_inferior (inf);
then don't revert back to it, but instead simply drop back to no
thread selected. */
if (tp
- && find_inferior_pid (ptid_get_pid (tp->ptid)) != NULL)
+ && find_inferior_ptid (tp->ptid) != NULL)
restore_current_thread (old->inferior_ptid);
else
{