Change regcache list to be an hash map
[deliverable/binutils-gdb.git] / gdb / linux-nat.c
index 2c7ded70436cbbd989484d9651762383ad8e83b6..465b2acd946c9ff463c43c0783f23baa365e3c46 100644 (file)
@@ -67,6 +67,7 @@
 #include "nat/linux-namespaces.h"
 #include "gdbsupport/fileio.h"
 #include "gdbsupport/scope-exit.h"
+#include "gdbsupport/gdb-sigmask.h"
 
 /* This comment documents high-level logic of this file.
 
@@ -764,7 +765,7 @@ block_child_signals (sigset_t *prev_mask)
   if (!sigismember (&blocked_mask, SIGCHLD))
     sigaddset (&blocked_mask, SIGCHLD);
 
-  sigprocmask (SIG_BLOCK, &blocked_mask, prev_mask);
+  gdb_sigmask (SIG_BLOCK, &blocked_mask, prev_mask);
 }
 
 /* Restore child signals mask, previously returned by
@@ -773,7 +774,7 @@ block_child_signals (sigset_t *prev_mask)
 static void
 restore_child_signals_mask (sigset_t *prev_mask)
 {
-  sigprocmask (SIG_SETMASK, prev_mask, NULL);
+  gdb_sigmask (SIG_SETMASK, prev_mask, NULL);
 }
 
 /* Mask of signals to pass directly to the inferior.  */
@@ -1132,7 +1133,7 @@ attach_proc_task_lwp_callback (ptid_t ptid)
          else
            {
              std::string reason
-               = linux_ptrace_attach_fail_reason_lwp (ptid, err);
+               = linux_ptrace_attach_fail_reason_string (ptid, err);
 
              warning (_("Cannot attach to lwp %d: %s"),
                       lwpid, reason.c_str ());
@@ -1187,9 +1188,8 @@ linux_nat_target::attach (const char *args, int from_tty)
     }
   catch (const gdb_exception_error &ex)
     {
-      int saved_errno = errno;
       pid_t pid = parse_pid_to_attach (args);
-      std::string reason = linux_ptrace_attach_fail_reason (pid, saved_errno);
+      std::string reason = linux_ptrace_attach_fail_reason (pid);
 
       if (!reason.empty ())
        throw_error (ex.error, "warning: %s\n%s", reason.c_str (),
@@ -1421,7 +1421,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
          if (ret == -1)
            {
              warning (_("Couldn't reap LWP %d while detaching: %s"),
-                      lwpid, strerror (errno));
+                      lwpid, safe_strerror (errno));
            }
          else if (!WIFEXITED (status) && !WIFSIGNALED (status))
            {
@@ -1469,7 +1469,7 @@ linux_nat_target::detach (inferior *inf, int from_tty)
      inferiors running. */
 
   /* Stop all threads before detaching.  ptrace requires that the
-     thread is stopped to sucessfully detach.  */
+     thread is stopped to successfully detach.  */
   iterate_over_lwps (ptid_t (pid), stop_callback);
   /* ... and wait until all of them have reported back that
      they're no longer running.  */
@@ -3147,9 +3147,12 @@ linux_nat_filter_event (int lwpid, int status)
 
       /* When using hardware single-step, we need to report every signal.
         Otherwise, signals in pass_mask may be short-circuited
-        except signals that might be caused by a breakpoint.  */
+        except signals that might be caused by a breakpoint, or SIGSTOP
+        if we sent the SIGSTOP and are waiting for it to arrive.  */
       if (!lp->step
          && WSTOPSIG (status) && sigismember (&pass_mask, WSTOPSIG (status))
+         && (WSTOPSIG (status) != SIGSTOP
+             || !find_thread_ptid (lp->ptid)->stop_requested)
          && !linux_wstatus_maybe_breakpoint (status))
        {
          linux_resume_one_lwp (lp, lp->step, signo);
@@ -3304,7 +3307,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
         - If the thread group leader exits while other threads in the
           thread group still exist, waitpid(TGID, ...) hangs.  That
           waitpid won't return an exit status until the other threads
-          in the group are reapped.
+          in the group are reaped.
 
         - When a non-leader thread execs, that thread just vanishes
           without reporting an exit (so we'd hang if we waited for it
@@ -3724,7 +3727,7 @@ linux_nat_target::kill ()
       ptid_t ptid = ptid_t (inferior_ptid.pid ());
 
       /* Stop all threads before killing them, since ptrace requires
-        that the thread is stopped to sucessfully PTRACE_KILL.  */
+        that the thread is stopped to successfully PTRACE_KILL.  */
       iterate_over_lwps (ptid, stop_callback);
       /* ... and wait until all of them have reported back that
         they're no longer running.  */
@@ -4562,16 +4565,12 @@ Enables printf debugging output."),
   sigaction (SIGCHLD, &sigchld_action, NULL);
 
   /* Make sure we don't block SIGCHLD during a sigsuspend.  */
-  sigprocmask (SIG_SETMASK, NULL, &suspend_mask);
+  gdb_sigmask (SIG_SETMASK, NULL, &suspend_mask);
   sigdelset (&suspend_mask, SIGCHLD);
 
   sigemptyset (&blocked_mask);
 
   lwp_lwpid_htab_create ();
-
-  /* Set the proper function to generate a message when ptrace
-     fails.  */
-  inf_ptrace_me_fail_reason = linux_ptrace_me_fail_reason;
 }
 \f
 
This page took 0.025247 seconds and 4 git commands to generate.