follow_fork_inferior (int follow_child, int detach_fork)
{
int has_vforked;
- int parent_pid, child_pid;
+ ptid_t parent_ptid, child_ptid;
has_vforked = (inferior_thread ()->pending_follow.kind
== TARGET_WAITKIND_VFORKED);
- parent_pid = ptid_get_lwp (inferior_ptid);
- if (parent_pid == 0)
- parent_pid = ptid_get_pid (inferior_ptid);
- child_pid
- = ptid_get_pid (inferior_thread ()->pending_follow.value.related_pid);
+ parent_ptid = inferior_ptid;
+ child_ptid = inferior_thread ()->pending_follow.value.related_pid;
if (has_vforked
&& !non_stop /* Non-stop always resumes both branches. */
{
target_terminal_ours_for_output ();
fprintf_filtered (gdb_stdlog,
- _("Detaching after %s from "
- "child process %d.\n"),
+ _("Detaching after %s from child %s.\n"),
has_vforked ? "vfork" : "fork",
- child_pid);
+ target_pid_to_str (child_ptid));
}
}
else
struct cleanup *old_chain;
/* Add process to GDB's tables. */
- child_inf = add_inferior (child_pid);
+ child_inf = add_inferior (ptid_get_pid (child_ptid));
parent_inf = current_inferior ();
child_inf->attach_flag = parent_inf->attach_flag;
old_chain = save_inferior_ptid ();
save_current_program_space ();
- inferior_ptid = ptid_build (child_pid, child_pid, 0);
+ inferior_ptid = child_ptid;
add_thread (inferior_ptid);
child_inf->symfile_flags = SYMFILE_NO_READ;
{
target_terminal_ours_for_output ();
fprintf_filtered (gdb_stdlog,
- _("Attaching after process %d "
- "%s to child process %d.\n"),
- parent_pid,
+ _("Attaching after %s %s to child %s.\n"),
+ target_pid_to_str (parent_ptid),
has_vforked ? "vfork" : "fork",
- child_pid);
+ target_pid_to_str (child_ptid));
}
/* Add the new inferior first, so that the target_detach below
doesn't unpush the target. */
- child_inf = add_inferior (child_pid);
+ child_inf = add_inferior (ptid_get_pid (child_ptid));
parent_inf = current_inferior ();
child_inf->attach_flag = parent_inf->attach_flag;
target_terminal_ours_for_output ();
fprintf_filtered (gdb_stdlog,
_("Detaching after fork from "
- "child process %d.\n"),
- child_pid);
+ "child %s.\n"),
+ target_pid_to_str (child_ptid));
}
target_detach (NULL, 0);
this new thread, before cloning the program space, and
informing the solib layer about this new process. */
- inferior_ptid = ptid_build (child_pid, child_pid, 0);
+ inferior_ptid = child_ptid;
add_thread (inferior_ptid);
/* If this is a vfork child, then the address-space is shared
int status = W_STOPCODE (0);
struct cleanup *old_chain;
int has_vforked;
+ ptid_t parent_ptid, child_ptid;
int parent_pid, child_pid;
has_vforked = (inferior_thread ()->pending_follow.kind
== TARGET_WAITKIND_VFORKED);
- parent_pid = ptid_get_lwp (inferior_ptid);
- if (parent_pid == 0)
- parent_pid = ptid_get_pid (inferior_ptid);
- child_pid
- = ptid_get_pid (inferior_thread ()->pending_follow.value.related_pid);
-
+ parent_ptid = inferior_ptid;
+ child_ptid = inferior_thread ()->pending_follow.value.related_pid;
+ parent_pid = ptid_get_lwp (parent_ptid);
+ child_pid = ptid_get_lwp (child_ptid);
/* We're already attached to the parent, by default. */
old_chain = save_inferior_ptid ();
- inferior_ptid = ptid_build (child_pid, child_pid, 0);
+ inferior_ptid = child_ptid;
child_lp = add_lwp (inferior_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
{
struct lwp_info *parent_lp;
- parent_lp = find_lwp_pid (pid_to_ptid (parent_pid));
+ parent_lp = find_lwp_pid (parent_ptid);
gdb_assert (linux_supports_tracefork () >= 0);
if (linux_supports_tracevforkdone ())