summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog22
-rw-r--r--gdb/breakpoint.c19
-rw-r--r--gdb/breakpoint.h2
-rw-r--r--gdb/inf-ptrace.c4
-rw-r--r--gdb/inf-ttrace.c15
-rw-r--r--gdb/infrun.c26
-rw-r--r--gdb/linux-nat.c9
-rw-r--r--gdb/target.h12
-rw-r--r--gdb/win32-nat.c4
9 files changed, 73 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bde0c5700d0..859a9a683d1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,27 @@
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.
* inferior.h (target_executing): Delete.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ec7d6a87223..3020de21145 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2316,7 +2316,7 @@ print_it_typical (bpstat bs)
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;
@@ -2324,7 +2324,7 @@ print_it_typical (bpstat bs)
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;
@@ -2816,17 +2816,17 @@ bpstat_check_location (const struct bp_location *bl, CORE_ADDR bp_addr)
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;
@@ -3672,10 +3672,11 @@ print_one_breakpoint_location (struct breakpoint *b,
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;
@@ -4344,7 +4345,7 @@ set_raw_breakpoint_without_location (enum bptype bptype)
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;
@@ -4717,7 +4718,7 @@ create_fork_vfork_event_catchpoint (int tempflag, char *cond_string,
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);
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 4636a13351c..32238570234 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -450,7 +450,7 @@ struct breakpoint
/* 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
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index e0c3ce9369d..e4f0d1ded40 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -398,7 +398,7 @@ inf_ptrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
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);
@@ -413,7 +413,7 @@ inf_ptrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
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);
}
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index 95c296e4a24..c0b75c78161 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -839,6 +839,7 @@ inf_ttrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
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;
@@ -918,8 +919,11 @@ inf_ttrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
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,
@@ -930,16 +934,21 @@ inf_ttrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
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. */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index fd0ea248c0a..0a87371704b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -297,8 +297,8 @@ static struct
enum target_waitkind kind;
struct
{
- int parent_pid;
- int child_pid;
+ ptid_t parent_pid;
+ ptid_t child_pid;
}
fork_event;
char *execd_pathname;
@@ -362,9 +362,9 @@ follow_inferior_reset_breakpoints (void)
/* 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.
@@ -404,7 +404,7 @@ follow_exec (int pid, char *execd_pathname)
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)
{
@@ -1901,7 +1901,7 @@ handle_inferior_event (struct execution_control_state *ecs)
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))
@@ -1936,7 +1936,7 @@ handle_inferior_event (struct execution_control_state *ecs)
/* 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));
@@ -4327,7 +4327,7 @@ discard_inferior_status (struct inferior_status *inf_status)
}
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;
@@ -4337,7 +4337,7 @@ inferior_has_forked (int pid, int *child_pid)
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;
@@ -4345,7 +4345,7 @@ inferior_has_forked (int pid, int *child_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;
@@ -4355,7 +4355,7 @@ inferior_has_vforked (int pid, int *child_pid)
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;
@@ -4363,7 +4363,7 @@ inferior_has_vforked (int pid, int *child_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;
@@ -4373,7 +4373,7 @@ inferior_has_execd (int pid, char **execd_pathname)
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);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 0821e97fb5a..beec018d7f6 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -641,7 +641,7 @@ linux_child_follow_fork (struct target_ops *ops, int follow_child)
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)
{
@@ -1693,7 +1693,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
_("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;
@@ -1725,7 +1725,8 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
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);
}
@@ -2958,7 +2959,7 @@ linux_nat_kill (void)
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);
}
diff --git a/gdb/target.h b/gdb/target.h
index a7b2bb9fa0d..db2d58e44c2 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -91,13 +91,13 @@ enum target_waitkind
(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,
@@ -140,7 +140,7 @@ struct target_waitstatus
{
int integer;
enum target_signal sig;
- int related_pid;
+ ptid_t related_pid;
char *execd_pathname;
int syscall_id;
}
@@ -701,11 +701,11 @@ int target_write_memory_blocks (VEC(memory_write_request_s) *requests,
/* 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 */
diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index eb15c971422..74df866c24e 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -1302,7 +1302,7 @@ get_win32_debug_event (int pid, struct target_waitstatus *ourstatus)
/* 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++;
}
@@ -1342,7 +1342,7 @@ get_win32_debug_event (int pid, struct target_waitstatus *ourstatus)
/* 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: