Commit 3f14ac41 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Print backtrace in vlc_pthread_fatal

parent 234a17d0
...@@ -83,6 +83,10 @@ static inline unsigned long vlc_threadid (void) ...@@ -83,6 +83,10 @@ static inline unsigned long vlc_threadid (void)
return v.i; return v.i;
} }
#ifdef __GLIBC__
# include <execinfo.h>
#endif
/***************************************************************************** /*****************************************************************************
* vlc_thread_fatal: Report an error from the threading layer * vlc_thread_fatal: Report an error from the threading layer
***************************************************************************** *****************************************************************************
...@@ -100,7 +104,11 @@ void vlc_pthread_fatal (const char *action, int error, ...@@ -100,7 +104,11 @@ void vlc_pthread_fatal (const char *action, int error,
#ifdef __GLIBC__ #ifdef __GLIBC__
/* Avoid the strerror_r() prototype brain damage in glibc */ /* Avoid the strerror_r() prototype brain damage in glibc */
errno = error; errno = error;
fprintf (stderr, " Error message: %m\n"); dprintf (2, " Error message: %m at:\n");
void *stack[20];
int len = backtrace (stack, sizeof (stack) / sizeof (stack[0]));
backtrace_symbols_fd (stack, len, 2);
#else #else
char buf[1000]; char buf[1000];
const char *msg; const char *msg;
...@@ -118,9 +126,9 @@ void vlc_pthread_fatal (const char *action, int error, ...@@ -118,9 +126,9 @@ void vlc_pthread_fatal (const char *action, int error,
break; break;
} }
fprintf (stderr, " Error message: %s\n", msg); fprintf (stderr, " Error message: %s\n", msg);
fflush (stderr);
#endif #endif
fflush (stderr);
abort (); abort ();
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment