if (print_inferior_events)
printf_unfiltered (_("[New inferior %d (%s)]\n"),
inf->num,
- target_pid_to_str (pid_to_ptid (pid)));
+ target_pid_to_str (ptid_t (pid)));
return inf;
}
struct delete_thread_of_inferior_arg *arg
= (struct delete_thread_of_inferior_arg *) data;
- if (ptid_get_pid (tp->ptid) == arg->pid)
+ if (tp->ptid.pid () == arg->pid)
{
if (arg->silent)
- delete_thread_silent (tp->ptid);
+ delete_thread_silent (tp);
else
- delete_thread (tp->ptid);
+ delete_thread (tp);
}
return 0;
}
void
-exit_inferior (int pid)
+exit_inferior (inferior *inf)
{
- struct inferior *inf = find_inferior_pid (pid);
-
exit_inferior_1 (inf, 0);
}
}
void
-exit_inferior_num_silent (int num)
+exit_inferior_silent (inferior *inf)
{
- struct inferior *inf = find_inferior_id (num);
-
exit_inferior_1 (inf, 1);
}
if (print_inferior_events)
printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
inf->num,
- target_pid_to_str (pid_to_ptid (pid)));
-}
-
-/* See inferior.h. */
-
-void
-detach_inferior (int pid)
-{
- detach_inferior (find_inferior_pid (pid));
+ target_pid_to_str (ptid_t (pid)));
}
void
for (inf = inferior_list; inf; inf = inf->next)
{
if (inf->pid != 0)
- exit_inferior_silent (inf->pid);
+ exit_inferior_silent (inf);
}
}
struct inferior *
find_inferior_ptid (ptid_t ptid)
{
- return find_inferior_pid (ptid_get_pid (ptid));
+ return find_inferior_pid (ptid.pid ());
}
/* See inferior.h. */
return NULL;
}
-int
-valid_gdb_inferior_id (int num)
-{
- struct inferior *inf;
-
- for (inf = inferior_list; inf; inf = inf->next)
- if (inf->num == num)
- return 1;
-
- return 0;
-}
-
-int
-pid_to_gdb_inferior_id (int pid)
-{
- struct inferior *inf;
-
- for (inf = inferior_list; inf; inf = inf->next)
- if (inf->pid == pid)
- return inf->num;
-
- return 0;
-}
-
-int
-gdb_inferior_id_to_pid (int num)
-{
- struct inferior *inferior = find_inferior_id (num);
- if (inferior)
- return inferior->pid;
- else
- return -1;
-}
-
-int
-in_inferior_list (int pid)
-{
- struct inferior *inf;
-
- for (inf = inferior_list; inf; inf = inf->next)
- if (inf->pid == pid)
- return 1;
-
- return 0;
-}
-
int
have_inferiors (void)
{
struct thread_info *tp;
ALL_NON_EXITED_THREADS (tp)
- if (tp && ptid_get_pid (tp->ptid) == inf->pid)
+ if (tp && tp->ptid.pid () == inf->pid)
if (target_has_execution_1 (tp->ptid))
{
/* Found a live thread in this inferior, go to the next
inferior_pid_to_str (int pid)
{
if (pid != 0)
- return target_pid_to_str (pid_to_ptid (pid));
+ return target_pid_to_str (ptid_t (pid));
else
return _("<null>");
}
static void
detach_inferior_command (const char *args, int from_tty)
{
- struct thread_info *tp;
-
if (!args || !*args)
error (_("Requires argument (inferior id(s) to detach)"));
{
int num = parser.get_number ();
- if (!valid_gdb_inferior_id (num))
+ inferior *inf = find_inferior_id (num);
+ if (inf == NULL)
{
warning (_("Inferior ID %d not known."), num);
continue;
}
- int pid = gdb_inferior_id_to_pid (num);
- if (pid == 0)
+ if (inf->pid == 0)
{
warning (_("Inferior ID %d is not running."), num);
continue;
}
- tp = any_thread_of_process (pid);
- if (!tp)
+ thread_info *tp = any_thread_of_inferior (inf);
+ if (tp == NULL)
{
warning (_("Inferior ID %d has no threads."), num);
continue;
}
- switch_to_thread (tp->ptid);
+ switch_to_thread (tp);
detach_command (NULL, from_tty);
}
static void
kill_inferior_command (const char *args, int from_tty)
{
- struct thread_info *tp;
-
if (!args || !*args)
error (_("Requires argument (inferior id(s) to kill)"));
{
int num = parser.get_number ();
- if (!valid_gdb_inferior_id (num))
+ inferior *inf = find_inferior_id (num);
+ if (inf == NULL)
{
warning (_("Inferior ID %d not known."), num);
continue;
}
- int pid = gdb_inferior_id_to_pid (num);
- if (pid == 0)
+ if (inf->pid == 0)
{
warning (_("Inferior ID %d is not running."), num);
continue;
}
- tp = any_thread_of_process (pid);
- if (!tp)
+ thread_info *tp = any_thread_of_inferior (inf);
+ if (tp == NULL)
{
warning (_("Inferior ID %d has no threads."), num);
continue;
}
- switch_to_thread (tp->ptid);
+ switch_to_thread (tp);
target_kill ();
}
if (inf->pid != 0)
{
- if (inf->pid != ptid_get_pid (inferior_ptid))
+ if (inf != current_inferior ())
{
- struct thread_info *tp;
-
- tp = any_thread_of_process (inf->pid);
- if (!tp)
+ thread_info *tp = any_thread_of_inferior (inf);
+ if (tp == NULL)
error (_("Inferior has no threads."));
- switch_to_thread (tp->ptid);
+ switch_to_thread (tp);
}
gdb::observers::user_selected_context_changed.notify
else
{
set_current_inferior (inf);
- switch_to_thread (null_ptid);
+ switch_to_no_thread ();
set_current_program_space (inf->pspace);
gdb::observers::user_selected_context_changed.notify
symbols.q. */
set_current_program_space (inf->pspace);
set_current_inferior (inf);
- switch_to_thread (null_ptid);
+ switch_to_no_thread ();
exec_file_attach (exec.get (), from_tty);
symbol_file_add_main (exec.get (), add_flags);
printf_filtered (_("Added inferior %d.\n"), inf->num);
set_current_inferior (inf);
- switch_to_thread (null_ptid);
+ switch_to_no_thread ();
clone_program_space (pspace, orginf->pspace);
}
}