* target.h (struct target_waitstatus): Store related_pid as a ptid.
(inferior_has_forked, inferior_has_vforked, inferior_has_execd):
Take a ptid_t.
* breakpoint.h (struct breakpoint): Change forked_inferior_pid
type to ptid.
* breakpoint.c (print_it_typical, bpstat_check_location)
(print_one_breakpoint_location, set_raw_breakpoint_without_location)
(create_fork_vfork_event_catchpoint): Adjust.
* infrun.c (fork_event): Change parent_pid and child_pid types to
ptid.
(follow_exec, inferior_has_forked, inferior_has_vforked)
(inferior_has_execd): Take a ptid_t and don't trim it.
* linux-thread-db.c (thread_db_wait): Don't trim the returned ptid.
* linux-nat.c (linux_child_follow_fork): Adjust.
* inf-ptrace.c (inf_ptrace_wait): Adjust.
* inf-ttrace.c (inf_ttrace_wait): Adjust.
* win32-nat.c (get_win32_debug_event): Don't set related_pid.
+2008-07-09 Pedro Alves <pedro@codesourcery.com>
+
+ Adjust fork/vfork/exec to pass ptids around.
+
+ * target.h (struct target_waitstatus): Store related_pid as a ptid.
+ (inferior_has_forked, inferior_has_vforked, inferior_has_execd):
+ Take a ptid_t.
+ * breakpoint.h (struct breakpoint): Change forked_inferior_pid
+ type to ptid.
+ * breakpoint.c (print_it_typical, bpstat_check_location)
+ (print_one_breakpoint_location, set_raw_breakpoint_without_location)
+ (create_fork_vfork_event_catchpoint): Adjust.
+ * infrun.c (fork_event): Change parent_pid and child_pid types to
+ ptid.
+ (follow_exec, inferior_has_forked, inferior_has_vforked)
+ (inferior_has_execd): Take a ptid_t and don't trim it.
+ * linux-thread-db.c (thread_db_wait): Don't trim the returned ptid.
+ * linux-nat.c (linux_child_follow_fork): Adjust.
+ * inf-ptrace.c (inf_ptrace_wait): Adjust.
+ * inf-ttrace.c (inf_ttrace_wait): Adjust.
+ * win32-nat.c (get_win32_debug_event): Don't set related_pid.
+
2008-07-09 Pedro Alves <pedro@codesourcery.com>
Add "executing" property to threads.
annotate_catchpoint (b->number);
printf_filtered (_("\nCatchpoint %d (forked process %d), "),
b->number,
- b->forked_inferior_pid);
+ ptid_get_pid (b->forked_inferior_pid));
return PRINT_SRC_AND_LOC;
break;
annotate_catchpoint (b->number);
printf_filtered (_("\nCatchpoint %d (vforked process %d), "),
b->number,
- b->forked_inferior_pid);
+ ptid_get_pid (b->forked_inferior_pid));
return PRINT_SRC_AND_LOC;
break;
return 0;
if ((b->type == bp_catch_fork)
- && !inferior_has_forked (PIDGET (inferior_ptid),
+ && !inferior_has_forked (inferior_ptid,
&b->forked_inferior_pid))
return 0;
if ((b->type == bp_catch_vfork)
- && !inferior_has_vforked (PIDGET (inferior_ptid),
+ && !inferior_has_vforked (inferior_ptid,
&b->forked_inferior_pid))
return 0;
if ((b->type == bp_catch_exec)
- && !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
+ && !inferior_has_execd (inferior_ptid, &b->exec_pathname))
return 0;
return 1;
if (addressprint)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
- if (b->forked_inferior_pid != 0)
+ if (!ptid_equal (b->forked_inferior_pid, null_ptid))
{
ui_out_text (uiout, "process ");
- ui_out_field_int (uiout, "what", b->forked_inferior_pid);
+ ui_out_field_int (uiout, "what",
+ ptid_get_pid (b->forked_inferior_pid));
ui_out_spaces (uiout, 1);
}
break;
b->frame_id = null_frame_id;
b->dll_pathname = NULL;
b->triggered_dll_pathname = NULL;
- b->forked_inferior_pid = 0;
+ b->forked_inferior_pid = null_ptid;
b->exec_pathname = NULL;
b->ops = NULL;
b->condition_not_parsed = 0;
b->addr_string = NULL;
b->enable_state = bp_enabled;
b->disposition = tempflag ? disp_del : disp_donttouch;
- b->forked_inferior_pid = 0;
+ b->forked_inferior_pid = null_ptid;
update_global_location_list (1);
/* Process id of a child process whose forking triggered this
catchpoint. This field is only valid immediately after this
catchpoint has triggered. */
- int forked_inferior_pid;
+ ptid_t forked_inferior_pid;
/* Filename of a program whose exec triggered this catchpoint.
This field is only valid immediately after this catchpoint has
{
case PTRACE_FORK:
ourstatus->kind = TARGET_WAITKIND_FORKED;
- ourstatus->value.related_pid = pe.pe_other_pid;
+ ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
/* Make sure the other end of the fork is stopped too. */
fpid = waitpid (pe.pe_other_pid, &status, 0);
gdb_assert (pe.pe_other_pid == pid);
if (fpid == ptid_get_pid (inferior_ptid))
{
- ourstatus->value.related_pid = pe.pe_other_pid;
+ ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
return pid_to_ptid (fpid);
}
lwpid_t lwpid = ptid_get_lwp (ptid);
ttstate_t tts;
struct thread_info *ti;
+ ptid_t related_ptid;
/* Until proven otherwise. */
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
break;
case TTEVT_FORK:
+ related_ptid = ptid_build (tts.tts_u.tts_fork.tts_fpid,
+ tts.tts_u.tts_fork.tts_flwpid, 0);
+
ourstatus->kind = TARGET_WAITKIND_FORKED;
- ourstatus->value.related_pid = tts.tts_u.tts_fork.tts_fpid;
+ ourstatus->value.related_pid = related_ptid;
/* Make sure the other end of the fork is stopped too. */
if (ttrace_wait (tts.tts_u.tts_fork.tts_fpid,
gdb_assert (tts.tts_event == TTEVT_FORK);
if (tts.tts_u.tts_fork.tts_isparent)
{
+ related_ptid = ptid_build (tts.tts_u.tts_fork.tts_fpid,
+ tts.tts_u.tts_fork.tts_flwpid, 0);
ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0);
- ourstatus->value.related_pid = tts.tts_u.tts_fork.tts_fpid;
+ ourstatus->value.related_pid = related_ptid;
}
break;
case TTEVT_VFORK:
gdb_assert (!tts.tts_u.tts_fork.tts_isparent);
+ related_ptid = ptid_build (tts.tts_u.tts_fork.tts_fpid,
+ tts.tts_u.tts_fork.tts_flwpid, 0);
+
ourstatus->kind = TARGET_WAITKIND_VFORKED;
- ourstatus->value.related_pid = tts.tts_u.tts_fork.tts_fpid;
+ ourstatus->value.related_pid = related_ptid;
/* HACK: To avoid touching the parent during the vfork, switch
away from it. */
enum target_waitkind kind;
struct
{
- int parent_pid;
- int child_pid;
+ ptid_t parent_pid;
+ ptid_t child_pid;
}
fork_event;
char *execd_pathname;
/* EXECD_PATHNAME is assumed to be non-NULL. */
static void
-follow_exec (int pid, char *execd_pathname)
+follow_exec (ptid_t pid, char *execd_pathname)
{
- int saved_pid = pid;
+ ptid_t saved_pid = pid;
struct target_ops *tgt;
/* This is an exec event that we actually wish to pay attention to.
gdb_flush (gdb_stdout);
generic_mourn_inferior ();
/* Because mourn_inferior resets inferior_ptid. */
- inferior_ptid = pid_to_ptid (saved_pid);
+ inferior_ptid = saved_pid;
if (gdb_sysroot && *gdb_sysroot)
{
stop_signal = TARGET_SIGNAL_TRAP;
pending_follow.kind = ecs->ws.kind;
- pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid);
+ pending_follow.fork_event.parent_pid = ecs->ptid;
pending_follow.fork_event.child_pid = ecs->ws.value.related_pid;
if (!ptid_equal (ecs->ptid, inferior_ptid))
/* This causes the eventpoints and symbol table to be reset. Must
do this now, before trying to determine whether to stop. */
- follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname);
+ follow_exec (inferior_ptid, pending_follow.execd_pathname);
xfree (pending_follow.execd_pathname);
stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
}
int
-inferior_has_forked (int pid, int *child_pid)
+inferior_has_forked (ptid_t pid, ptid_t *child_pid)
{
struct target_waitstatus last;
ptid_t last_ptid;
if (last.kind != TARGET_WAITKIND_FORKED)
return 0;
- if (ptid_get_pid (last_ptid) != pid)
+ if (!ptid_equal (last_ptid, pid))
return 0;
*child_pid = last.value.related_pid;
}
int
-inferior_has_vforked (int pid, int *child_pid)
+inferior_has_vforked (ptid_t pid, ptid_t *child_pid)
{
struct target_waitstatus last;
ptid_t last_ptid;
if (last.kind != TARGET_WAITKIND_VFORKED)
return 0;
- if (ptid_get_pid (last_ptid) != pid)
+ if (!ptid_equal (last_ptid, pid))
return 0;
*child_pid = last.value.related_pid;
}
int
-inferior_has_execd (int pid, char **execd_pathname)
+inferior_has_execd (ptid_t pid, char **execd_pathname)
{
struct target_waitstatus last;
ptid_t last_ptid;
if (last.kind != TARGET_WAITKIND_EXECD)
return 0;
- if (ptid_get_pid (last_ptid) != pid)
+ if (!ptid_equal (last_ptid, pid))
return 0;
*execd_pathname = xstrdup (last.value.execd_pathname);
parent_pid = ptid_get_lwp (last_ptid);
if (parent_pid == 0)
parent_pid = ptid_get_pid (last_ptid);
- child_pid = last_status.value.related_pid;
+ child_pid = PIDGET (last_status.value.related_pid);
if (! follow_child)
{
_("wait returned unexpected status 0x%x"), status);
}
- ourstatus->value.related_pid = new_pid;
+ ourstatus->value.related_pid = ptid_build (new_pid, new_pid, 0);
if (event == PTRACE_EVENT_FORK)
ourstatus->kind = TARGET_WAITKIND_FORKED;
else
{
new_lp->resumed = 1;
- ptrace (PTRACE_CONT, lp->waitstatus.value.related_pid, 0,
+ ptrace (PTRACE_CONT,
+ PIDGET (lp->waitstatus.value.related_pid), 0,
status ? WSTOPSIG (status) : 0);
}
if (last.kind == TARGET_WAITKIND_FORKED
|| last.kind == TARGET_WAITKIND_VFORKED)
{
- ptrace (PT_KILL, last.value.related_pid, 0, 0);
+ ptrace (PT_KILL, PIDGET (last.value.related_pid), 0, 0);
wait (&status);
}
(e.g. it called load(2) on AIX). */
TARGET_WAITKIND_LOADED,
- /* The program has forked. A "related" process' ID is in
+ /* The program has forked. A "related" process' PTID is in
value.related_pid. I.e., if the child forks, value.related_pid
is the parent's ID. */
TARGET_WAITKIND_FORKED,
- /* The program has vforked. A "related" process's ID is in
+ /* The program has vforked. A "related" process's PTID is in
value.related_pid. */
TARGET_WAITKIND_VFORKED,
{
int integer;
enum target_signal sig;
- int related_pid;
+ ptid_t related_pid;
char *execd_pathname;
int syscall_id;
}
/* From infrun.c. */
-extern int inferior_has_forked (int pid, int *child_pid);
+extern int inferior_has_forked (ptid_t pid, ptid_t *child_pid);
-extern int inferior_has_vforked (int pid, int *child_pid);
+extern int inferior_has_vforked (ptid_t pid, ptid_t *child_pid);
-extern int inferior_has_execd (int pid, char **execd_pathname);
+extern int inferior_has_execd (ptid_t pid, char **execd_pathname);
/* From exec.c */
/* Kludge around a Windows bug where first event is a create
thread event. Caused when attached process does not have
a main thread. */
- retval = ourstatus->value.related_pid = fake_create_process ();
+ retval = fake_create_process ();
if (retval)
saw_create++;
}
/* Add the main thread */
th = win32_add_thread (main_thread_id,
current_event.u.CreateProcessInfo.hThread);
- retval = ourstatus->value.related_pid = current_event.dwThreadId;
+ retval = current_event.dwThreadId;
break;
case EXIT_PROCESS_DEBUG_EVENT:
/* Kludge around a Windows bug where first event is a create
thread event. Caused when attached process does not have
a main thread. */
- retval = ourstatus->value.related_pid = fake_create_process ();
+ retval = fake_create_process ();
if (retval)
saw_create++;
}
/* Add the main thread */
th = win32_add_thread (main_thread_id,
current_event.u.CreateProcessInfo.hThread);
- retval = ourstatus->value.related_pid = current_event.dwThreadId;
+ retval = current_event.dwThreadId;
break;
case EXIT_PROCESS_DEBUG_EVENT: