This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: catch SIGSEGV in the demangler
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>, gdb-patches at sourceware dot org
- Date: Fri, 18 Jan 2013 11:22:41 +0000
- Subject: Re: catch SIGSEGV in the demangler
- References: <87fw23o70u.fsf@fleche.redhat.com> <19236.9665638127$1358374641@news.gmane.org> <87622vd2vd.fsf@fleche.redhat.com>
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