This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: catch SIGSEGV in the demangler


On 01/17/2013 07:29 PM, Tom Tromey wrote:
> 
> Then, have a special throw_segv that first looks to see if anything
> expects to catch it, and if not, reset the handler and re-raise the
> signal.

+static void
+handle_segv (int sig)
+{
+  struct gdb_exception except;
+
+  if (!in_demangler)
+    {
+      signal (sig, SIG_DFL);
+      raise (sig);
+    }

The original idea was to do return instead of raise:

+static void
+handle_segv (int sig)
+{
+  struct gdb_exception except;
+
+  if (!in_demangler)
+    {
+      signal (sig, SIG_DFL);
+      return;
+    }

SIGSEGV being a synchronous signal, this makes it so that the original
instruction that triggered the segv is reexecuted, and the SIGSEGV is raised
again.  The difference is that this way our handler is transparent -- the
segv's siginfo will be more rich, including a si_addr that points at the
address that caused the fault, (si_code will still show it was a userspace
generated signal), and "handle_segv" will not appear in the backtrace.
Did you try that and decided against?

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]