Use gdb_bfd_sections in get_stap_base_address
[deliverable/binutils-gdb.git] / gdb / inf-ptrace.c
index 4519a9ebef1ed725fdbb683e3fa5c209f8cc0e47..d5a062163c7aabb028ab28c0b392cc9ab5519ca0 100644 (file)
@@ -90,9 +90,6 @@ inf_ptrace_target::create_inferior (const char *exec_file,
                                    const std::string &allargs,
                                    char **env, int from_tty)
 {
-  pid_t pid;
-  ptid_t ptid;
-
   /* Do not change either targets above or the same target if already present.
      The reason is the target stack is shared across multiple inferiors.  */
   int ops_already_pushed = target_is_pushed (this);
@@ -105,14 +102,15 @@ inf_ptrace_target::create_inferior (const char *exec_file,
       unpusher.reset (this);
     }
 
-  pid = fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL,
-                      NULL, NULL, NULL);
+  pid_t pid = fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL,
+                            NULL, NULL, NULL);
 
-  ptid = ptid_t (pid);
+  ptid_t ptid (pid);
   /* We have something that executes now.  We'll be running through
      the shell at this point (if startup-with-shell is true), but the
      pid shouldn't change.  */
-  add_thread_silent (this, ptid);
+  thread_info *thr = add_thread_silent (this, ptid);
+  switch_to_thread (thr);
 
   unpusher.release ();
 
@@ -190,11 +188,12 @@ inf_ptrace_target::attach (const char *args, int from_tty)
   inf = current_inferior ();
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
-  inferior_ptid = ptid_t (pid);
 
   /* Always add a main thread.  If some target extends the ptrace
      target, it should decorate the ptid later with more info.  */
-  thread_info *thr = add_thread_silent (this, inferior_ptid);
+  thread_info *thr = add_thread_silent (this, ptid_t (pid));
+  switch_to_thread (thr);
+
   /* Don't consider the thread stopped until we've processed its
      initial SIGSTOP stop.  */
   set_executing (this, thr->ptid, true);
@@ -232,7 +231,7 @@ inf_ptrace_target::detach (inferior *inf, int from_tty)
 void
 inf_ptrace_target::detach_success (inferior *inf)
 {
-  inferior_ptid = null_ptid;
+  switch_to_no_thread ();
   detach_inferior (inf);
 
   maybe_unpush_target ();
@@ -317,7 +316,7 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 
 ptid_t
 inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                        int options)
+                        target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
@@ -348,49 +347,11 @@ inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
        }
 
       /* Ignore terminated detached child processes.  */
-      if (!WIFSTOPPED (status) && pid != inferior_ptid.pid ())
+      if (!WIFSTOPPED (status) && find_inferior_pid (this, pid) == nullptr)
        pid = -1;
     }
   while (pid == -1);
 
-#ifdef PT_GET_PROCESS_STATE
-  if (WIFSTOPPED (status))
-    {
-      ptrace_state_t pe;
-      pid_t fpid;
-
-      if (ptrace (PT_GET_PROCESS_STATE, pid,
-                 (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-       perror_with_name (("ptrace"));
-
-      switch (pe.pe_report_event)
-       {
-       case PTRACE_FORK:
-         ourstatus->kind = TARGET_WAITKIND_FORKED;
-         ourstatus->value.related_pid = ptid_t (pe.pe_other_pid);
-
-         /* Make sure the other end of the fork is stopped too.  */
-         fpid = waitpid (pe.pe_other_pid, &status, 0);
-         if (fpid == -1)
-           perror_with_name (("waitpid"));
-
-         if (ptrace (PT_GET_PROCESS_STATE, fpid,
-                     (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
-           perror_with_name (("ptrace"));
-
-         gdb_assert (pe.pe_report_event == PTRACE_FORK);
-         gdb_assert (pe.pe_other_pid == pid);
-         if (fpid == inferior_ptid.pid ())
-           {
-             ourstatus->value.related_pid = ptid_t (pe.pe_other_pid);
-             return ptid_t (fpid);
-           }
-
-         return ptid_t (pid);
-       }
-    }
-#endif
-
   store_waitstatus (ourstatus, status);
   return ptid_t (pid);
 }
This page took 0.04701 seconds and 4 git commands to generate.