btrace: temporarily set inferior_ptid in record_btrace_start_replaying
[deliverable/binutils-gdb.git] / gdb / fbsd-nat.c
index 214f411c82c9695937ddcc9d14be6fb3b04923b0..44d9e054a796733ab4b5e816b675e993f70fc666 100644 (file)
 #include "regcache.h"
 #include "regset.h"
 #include "gdbthread.h"
+#include "gdb_wait.h"
 #include <sys/types.h>
 #include <sys/procfs.h>
 #include <sys/ptrace.h>
 #include <sys/sysctl.h>
-#include <sys/wait.h>
 #ifdef HAVE_KINFO_GETVMMAP
 #include <sys/user.h>
 #include <libutil.h>
@@ -257,9 +257,7 @@ static struct fbsd_fork_child_info *fbsd_pending_children;
 static void
 fbsd_remember_child (pid_t pid)
 {
-  struct fbsd_fork_child_info *info;
-
-  info = xcalloc (1, sizeof *info);
+  struct fbsd_fork_child_info *info = XCNEW (struct fbsd_fork_child_info);
 
   info->child = pid;
   info->next = fbsd_pending_children;
@@ -376,6 +374,16 @@ fbsd_wait (struct target_ops *ops,
              continue;
            }
 #endif
+
+#ifdef PL_FLAG_EXEC
+         if (pl.pl_flags & PL_FLAG_EXEC)
+           {
+             ourstatus->kind = TARGET_WAITKIND_EXECD;
+             ourstatus->value.execd_pathname
+               = xstrdup (fbsd_pid_to_exec_file (NULL, pid));
+             return wptid;
+           }
+#endif
        }
       return wptid;
     }
@@ -458,6 +466,23 @@ fbsd_post_attach (struct target_ops *self, int pid)
   fbsd_enable_follow_fork (pid);
 }
 #endif
+
+#ifdef PL_FLAG_EXEC
+/* If the FreeBSD kernel supports PL_FLAG_EXEC, then traced processes
+   will always stop after exec.  */
+
+static int
+fbsd_insert_exec_catchpoint (struct target_ops *self, int pid)
+{
+  return 0;
+}
+
+static int
+fbsd_remove_exec_catchpoint (struct target_ops *self, int pid)
+{
+  return 0;
+}
+#endif
 #endif
 
 void
@@ -477,6 +502,10 @@ fbsd_nat_add_target (struct target_ops *t)
   t->to_post_startup_inferior = fbsd_post_startup_inferior;
   t->to_post_attach = fbsd_post_attach;
 #endif
+#ifdef PL_FLAG_EXEC
+  t->to_insert_exec_catchpoint = fbsd_insert_exec_catchpoint;
+  t->to_remove_exec_catchpoint = fbsd_remove_exec_catchpoint;
+#endif
 #endif
   add_target (t);
 }
This page took 0.02445 seconds and 4 git commands to generate.