From e4ef629de7c4321fdcc8fe5de656d05c325e1312 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sat, 13 Aug 2005 22:23:35 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 8 +++++++ gdb/inf-ptrace.c | 62 ++++++++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4d0e3015552..558f5e33a6e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2005-08-14 Mark Kettenis + * 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. + * sparc-tdep.c (sparc_breakpoint_from_pc): Constify break_insn. * sparc-sol2-tdep.c (sparc_sol2_pc_in_sigtramp): Check for diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 033840a067c..78892aa3931 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 (¤t_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; -- 2.30.2