void vlc_enable_override (void);
-static bool override = false;
-
-void vlc_enable_override (void)
-{
- override = true;
-}
-
#if defined (__GNUC__) /* typeof and statement-expression */ \
&& (defined (__ELF__) && !defined (__sun__))
/* Solaris crashes on printf("%s", NULL); which is legal, but annoying. */
#include <stdlib.h>
#include <dlfcn.h>
#include <pthread.h>
+#ifdef HAVE_EXECINFO_H
+# include <execinfo.h>
+#endif
+
+static bool override = false;
+
+static void vlc_reset_override (void)
+{
+ override = false;
+}
+
+void vlc_enable_override (void)
+{
+ override = true;
+ pthread_atfork (NULL, NULL, vlc_reset_override);
+}
static void vlogbug (const char *level, const char *func, const char *fmt,
va_list ap)
{
+#ifdef HAVE_BACKTRACE
+ const size_t framec = 8;
+ void *framev[framec];
+
+ backtrace (framev, framec);
+#endif
flockfile (stderr);
fprintf (stderr, "%s: call to %s(", level, func);
vfprintf (stderr, fmt, ap);
fputs (")\n", stderr);
+ fflush (stderr);
+#ifdef HAVE_BACKTRACE
+ backtrace_symbols_fd (framev + 2, framec - 2, fileno (stderr));
+#endif
funlockfile (stderr);
}
}
-#endif /* __ELF__ */
+#else
+static void vlc_enable_override (void)
+{
+}
+#endif