gdb
[deliverable/binutils-gdb.git] / gdb / inf-ptrace.c
index 538816dcd592f5a5ec4ea02d2b9517fba37863bb..f088ffdc6e74c42bc3a2dffb91b3667fb373adb5 100644 (file)
@@ -32,6 +32,7 @@
 #include "gdb_wait.h"
 #include <signal.h>
 
+#include "inf-ptrace.h"
 #include "inf-child.h"
 #include "gdbthread.h"
 
@@ -73,7 +74,8 @@ inf_ptrace_follow_fork (struct target_ops *ops, int follow_child)
       CORE_ADDR step_range_start = last_tp->step_range_start;
       CORE_ADDR step_range_end = last_tp->step_range_end;
       struct frame_id step_frame_id = last_tp->step_frame_id;
-
+      int attach_flag = find_inferior_pid (pid)->attach_flag;
+      struct inferior *inf;
       struct thread_info *tp;
 
       /* Otherwise, deleting the parent would get rid of this
@@ -82,7 +84,7 @@ inf_ptrace_follow_fork (struct target_ops *ops, int follow_child)
 
       /* Before detaching from the parent, remove all breakpoints from
         it.  */
-      detach_breakpoints (pid);
+      remove_breakpoints ();
 
       if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
        perror_with_name (("ptrace"));
@@ -94,7 +96,8 @@ inf_ptrace_follow_fork (struct target_ops *ops, int follow_child)
       detach_inferior (pid);
 
       /* Add the child.  */
-      add_inferior (fpid);
+      inf = add_inferior (fpid);
+      inf->attach_flag = attach_flag;
       tp = add_thread_silent (inferior_ptid);
 
       tp->step_resume_breakpoint = step_resume_breakpoint;
@@ -317,7 +320,7 @@ inf_ptrace_detach (struct target_ops *ops, char *args, int from_tty)
 /* Kill the inferior.  */
 
 static void
-inf_ptrace_kill (void)
+inf_ptrace_kill (struct target_ops *ops)
 {
   pid_t pid = ptid_get_pid (inferior_ptid);
   int status;
@@ -349,7 +352,8 @@ inf_ptrace_stop (ptid_t ptid)
    that signal.  */
 
 static void
-inf_ptrace_resume (ptid_t ptid, int step, enum target_signal signal)
+inf_ptrace_resume (struct target_ops *ops,
+                  ptid_t ptid, int step, enum target_signal signal)
 {
   pid_t pid = ptid_get_pid (ptid);
   int request = PT_CONTINUE;
@@ -383,7 +387,8 @@ inf_ptrace_resume (ptid_t ptid, int step, enum target_signal signal)
    the status in *OURSTATUS.  */
 
 static ptid_t
-inf_ptrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
+inf_ptrace_wait (struct target_ops *ops,
+                ptid_t ptid, struct target_waitstatus *ourstatus)
 {
   pid_t pid;
   int status, save_errno;
@@ -595,7 +600,7 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object,
 /* Return non-zero if the thread specified by PTID is alive.  */
 
 static int
-inf_ptrace_thread_alive (ptid_t ptid)
+inf_ptrace_thread_alive (struct target_ops *ops, ptid_t ptid)
 {
   /* ??? Is kill the right way to do this?  */
   return (kill (ptid_get_pid (ptid), 0) != -1);
@@ -613,6 +618,12 @@ inf_ptrace_files_info (struct target_ops *ignore)
                   target_pid_to_str (inferior_ptid));
 }
 
+static char *
+inf_ptrace_pid_to_str (struct target_ops *ops, ptid_t ptid)
+{
+  return normal_pid_to_str (ptid);
+}
+
 /* Create a prototype ptrace target.  The client can override it with
    local methods.  */
 
@@ -635,7 +646,7 @@ inf_ptrace_target (void)
 #endif
   t->to_mourn_inferior = inf_ptrace_mourn_inferior;
   t->to_thread_alive = inf_ptrace_thread_alive;
-  t->to_pid_to_str = normal_pid_to_str;
+  t->to_pid_to_str = inf_ptrace_pid_to_str;
   t->to_stop = inf_ptrace_stop;
   t->to_xfer_partial = inf_ptrace_xfer_partial;
 
@@ -696,7 +707,8 @@ inf_ptrace_fetch_register (struct regcache *regcache, int regnum)
    for all registers.  */
 
 static void
-inf_ptrace_fetch_registers (struct regcache *regcache, int regnum)
+inf_ptrace_fetch_registers (struct target_ops *ops,
+                           struct regcache *regcache, int regnum)
 {
   if (regnum == -1)
     for (regnum = 0;
@@ -752,8 +764,9 @@ inf_ptrace_store_register (const struct regcache *regcache, int regnum)
 /* Store register REGNUM back into the inferior.  If REGNUM is -1, do
    this for all registers.  */
 
-void
-inf_ptrace_store_registers (struct regcache *regcache, int regnum)
+static void
+inf_ptrace_store_registers (struct target_ops *ops,
+                           struct regcache *regcache, int regnum)
 {
   if (regnum == -1)
     for (regnum = 0;
This page took 0.024789 seconds and 4 git commands to generate.