gdb: Don't skip prologue for explicit line breakpoints in assembler
[deliverable/binutils-gdb.git] / gdb / common / signals-state-save-restore.c
index 1c00cdd9d0da4f00b42939f65bce004fb0ba4ee6..c66d2ddc62f6a36fcb5d6d816bd9d428ff8622f5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2016 Free Software Foundation, Inc.
+/* Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,7 +35,7 @@ static sigset_t original_signal_mask;
 /* See signals-state-save-restore.h.   */
 
 void
-save_original_signals_state (void)
+save_original_signals_state (bool quiet)
 {
 #ifdef HAVE_SIGACTION
   int i;
@@ -43,7 +43,9 @@ save_original_signals_state (void)
 
   res = sigprocmask (0,  NULL, &original_signal_mask);
   if (res == -1)
-    perror_with_name ("sigprocmask");
+    perror_with_name (("sigprocmask"));
+
+  bool found_preinstalled = false;
 
   for (i = 1; i < NSIG; i++)
     {
@@ -56,12 +58,33 @@ save_original_signals_state (void)
          continue;
        }
       else if (res == -1)
-       perror_with_name ("sigaction");
+       perror_with_name (("sigaction"));
 
       /* If we find a custom signal handler already installed, then
-        this function was called too late.  */
-      if (oldact->sa_handler != SIG_DFL && oldact->sa_handler != SIG_IGN)
-       internal_error (__FILE__, __LINE__, _("unexpected signal handler"));
+        this function was called too late.  This is a warning instead
+        of an internal error because this can also happen if you
+        LD_PRELOAD a library that installs a signal handler early via
+        __attribute__((constructor)), like libSegFault.so.  */
+      if (!quiet
+         && oldact->sa_handler != SIG_DFL
+         && oldact->sa_handler != SIG_IGN)
+       {
+         found_preinstalled = true;
+
+         /* Use raw fprintf here because we're being called in early
+            startup, before GDB's filtered streams are created.  */
+         fprintf (stderr,
+                  _("warning: Found custom handler for signal "
+                    "%d (%s) preinstalled.\n"), i,
+                  strsignal (i));
+       }
+    }
+
+  if (found_preinstalled)
+    {
+      fprintf (stderr, _("\
+Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)\n\
+won't be propagated to spawned programs.\n"));
     }
 #endif
 }
@@ -84,11 +107,11 @@ restore_original_signals_state (void)
          continue;
        }
       else if (res == -1)
-       perror_with_name ("sigaction");
+       perror_with_name (("sigaction"));
     }
 
   res = sigprocmask (SIG_SETMASK,  &original_signal_mask, NULL);
   if (res == -1)
-    perror_with_name ("sigprocmask");
+    perror_with_name (("sigprocmask"));
 #endif
 }
This page took 0.025344 seconds and 4 git commands to generate.