}
len = buf.size ();
- name = (char *) obstack_copy0 (&info->obstack, buf.c_str (), len);
+ name = obstack_strdup (&info->obstack, buf.string ());
/* Turn the result into a new tree. Note that this
tree will contain pointers into NAME, so NAME cannot
buf.write (d_left (comp)->u.s_name.s, d_left (comp)->u.s_name.len);
newobj.type = DEMANGLE_COMPONENT_NAME;
- newobj.u.s_name.s
- = (char *) obstack_copy0 (&info->obstack,
- buf.c_str (), buf.size ());
+ newobj.u.s_name.s = obstack_strdup (&info->obstack, buf.string ());
newobj.u.s_name.len = buf.size ();
if (inspect_type (info, &newobj, finder, data))
{
with a DEMANGLE_COMPONENT_NAME node containing the whole
name. */
ret_comp->type = DEMANGLE_COMPONENT_NAME;
- ret_comp->u.s_name.s
- = (char *) obstack_copy0 (&info->obstack,
- buf.c_str (), buf.size ());
+ ret_comp->u.s_name.s = obstack_strdup (&info->obstack, buf.string ());
ret_comp->u.s_name.len = buf.size ();
inspect_type (info, ret_comp, finder, data);
}
#ifdef HAVE_WORKING_FORK
-/* If nonzero, attempt to catch crashes in the demangler and print
+/* If true, attempt to catch crashes in the demangler and print
useful debugging information. */
-static int catch_demangler_crashes = 1;
+static bool catch_demangler_crashes = true;
/* Stack context and environment for demangler crash recovery. */
ofunc = signal (SIGSEGV, gdb_demangle_signal_handler);
#endif
- crash_signal = SIGSETJMP (gdb_demangle_jmp_buf);
+ /* The signal handler may keep the signal blocked when we longjmp out
+ of it. If we have sigprocmask, we can use it to unblock the signal
+ afterwards and we can avoid the performance overhead of saving the
+ signal mask just in case the signal gets triggered. Otherwise, just
+ tell sigsetjmp to save the mask. */
+#ifdef HAVE_SIGPROCMASK
+ crash_signal = SIGSETJMP (gdb_demangle_jmp_buf, 0);
+#else
+ crash_signal = SIGSETJMP (gdb_demangle_jmp_buf, 1);
+#endif
}
#endif
{
static int error_reported = 0;
+#ifdef HAVE_SIGPROCMASK
+ /* If we got the signal, SIGSEGV may still be blocked; restore it. */
+ sigset_t segv_sig_set;
+ sigemptyset (&segv_sig_set);
+ sigaddset (&segv_sig_set, SIGSEGV);
+ sigprocmask (SIG_UNBLOCK, &segv_sig_set, NULL);
+#endif
+
if (!error_reported)
{
std::string short_msg