[vlc-devel] commit: Print backtrace in vlc_pthread_fatal ( Rémi Denis-Courmont )

git version control git at videolan.org
Fri May 30 17:16:25 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Fri May 30 18:17:40 2008 +0300| [3f14ac4172fe496b8e0deb2e01c2713e5b3133eb]

Print backtrace in vlc_pthread_fatal

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3f14ac4172fe496b8e0deb2e01c2713e5b3133eb
---

 src/misc/threads.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index aa66a6a..42c1112 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -83,6 +83,10 @@ static inline unsigned long vlc_threadid (void)
      return v.i;
 }
 
+#ifdef __GLIBC__
+# include <execinfo.h>
+#endif
+
 /*****************************************************************************
  * vlc_thread_fatal: Report an error from the threading layer
  *****************************************************************************
@@ -100,7 +104,11 @@ void vlc_pthread_fatal (const char *action, int error,
 #ifdef __GLIBC__
     /* Avoid the strerror_r() prototype brain damage in glibc */
     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
     char buf[1000];
     const char *msg;
@@ -118,9 +126,9 @@ void vlc_pthread_fatal (const char *action, int error,
             break;
     }
     fprintf (stderr, " Error message: %s\n", msg);
+    fflush (stderr);
 #endif
 
-    fflush (stderr);
     abort ();
 }
 #else




More information about the vlc-devel mailing list