aboutsummaryrefslogtreecommitdiff
path: root/gdb/inf-ptrace.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2005-08-13 22:23:35 +0000
committerMark Kettenis <kettenis@gnu.org>2005-08-13 22:23:35 +0000
commite4ef629de7c4321fdcc8fe5de656d05c325e1312 (patch)
tree6c5d34994a1cacec4316b7ebe69c7a3a18a40377 /gdb/inf-ptrace.c
parent864a1a37a3f9f104c66861db573ccb68e7f72e7b (diff)
downloadgdb-e4ef629de7c4321fdcc8fe5de656d05c325e1312.zip
gdb-e4ef629de7c4321fdcc8fe5de656d05c325e1312.tar.gz
gdb-e4ef629de7c4321fdcc8fe5de656d05c325e1312.tar.bz2
* inf-ptrace.c (inf_ptrace_him) [PT_GET_PROCESS_STATE]: Move
code... (inf_ptrace_post_startup_inferior): ...here. New function. (inf_ptrace_attach) [PT_GET_PROCESS_STATE]: Move code... (inf_ptrace_post_attach): ...here. (inf_ptrace_target) [PT_GET_PROCESS_STATE]: Set to_post_startup_inferior and to_post_attch.
Diffstat (limited to 'gdb/inf-ptrace.c')
-rw-r--r--gdb/inf-ptrace.c62
1 files changed, 36 insertions, 26 deletions
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 033840a..78892aa 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -108,19 +108,6 @@ inf_ptrace_me (void)
static void
inf_ptrace_him (int pid)
{
-#ifdef PT_GET_PROCESS_STATE
- {
- ptrace_event_t pe;
-
- /* Set the initial event mask. */
- memset (&pe, 0, sizeof pe);
- pe.pe_set_event |= PTRACE_FORK;
- if (ptrace (PT_SET_EVENT_MASK, pid,
- (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
- perror_with_name (("ptrace"));
- }
-#endif
-
push_target (ptrace_ops_hack);
/* On some targets, there must be some explicit synchronization
@@ -159,6 +146,23 @@ inf_ptrace_create_inferior (char *exec_file, char *allargs, char **env,
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
}
+#ifdef PT_GET_PROCESS_STATE
+
+static void
+inf_ptrace_post_startup_inferior (ptid_t pid)
+{
+ ptrace_event_t pe;
+
+ /* Set the initial event mask. */
+ memset (&pe, 0, sizeof pe);
+ pe.pe_set_event |= PTRACE_FORK;
+ if (ptrace (PT_SET_EVENT_MASK, ptid_get_pid (pid),
+ (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
+ perror_with_name (("ptrace"));
+}
+
+#endif
+
/* Clean up a rotting corpse of an inferior after it died. */
static void
@@ -222,19 +226,6 @@ inf_ptrace_attach (char *args, int from_tty)
error (_("This system does not support attaching to a process"));
#endif
-#ifdef PT_GET_PROCESS_STATE
- {
- ptrace_event_t pe;
-
- /* Set the initial event mask. */
- memset (&pe, 0, sizeof pe);
- pe.pe_set_event |= PTRACE_FORK;
- if (ptrace (PT_SET_EVENT_MASK, pid,
- (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
- perror_with_name (("ptrace"));
- }
-#endif
-
inferior_ptid = pid_to_ptid (pid);
push_target (ptrace_ops_hack);
@@ -243,6 +234,23 @@ inf_ptrace_attach (char *args, int from_tty)
observer_notify_inferior_created (&current_target, from_tty);
}
+#ifdef PT_GET_PROCESS_STATE
+
+void
+inf_ptrace_post_attach (int pid)
+{
+ ptrace_event_t pe;
+
+ /* Set the initial event mask. */
+ memset (&pe, 0, sizeof pe);
+ pe.pe_set_event |= PTRACE_FORK;
+ if (ptrace (PT_SET_EVENT_MASK, pid,
+ (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
+ perror_with_name (("ptrace"));
+}
+
+#endif
+
/* Detach from the inferior, optionally passing it the signal
specified ARGS. If FROM_TTY is non-zero, be chatty about it. */
@@ -590,6 +598,8 @@ inf_ptrace_target (void)
t->to_create_inferior = inf_ptrace_create_inferior;
#ifdef PT_GET_PROCESS_STATE
t->to_follow_fork = inf_ptrace_follow_fork;
+ t->to_post_startup_inferior = inf_ptrace_post_startup_inferior;
+ t->to_post_attach = inf_ptrace_post_attach;
#endif
t->to_mourn_inferior = inf_ptrace_mourn_inferior;
t->to_thread_alive = inf_ptrace_thread_alive;