From bbea56886e50625353a8ee0541e95dd9753c81be Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Mon, 3 Mar 2003 17:29:07 +0000 Subject: implementing the backtrace function in the header results in the code being included in every single plugin (possibly multiple times due to inlining) -> move the code to libxineutil seems more sensible CVS patchset: 4327 CVS date: 2003/03/03 17:29:07 --- src/xine-utils/utils.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/xine-utils/utils.c') diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index cf51f5147..828d7d934 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: utils.c,v 1.11 2003/01/12 16:38:08 holstsn Exp $ + * $Id: utils.c,v 1.12 2003/03/03 17:29:07 mroi Exp $ * */ #define _POSIX_PTHREAD_SEMANTICS 1 /* for 5-arg getpwuid_r on solaris */ @@ -35,6 +35,12 @@ #include #include #include +#if HAVE_EXECINFO_H +#include +#endif +#if HAVE_UCONTEXT_H +#include +#endif #include "compat.h" @@ -133,3 +139,29 @@ void xine_usec_sleep(unsigned usec) { usleep(usec); #endif } + + +/* Obtain a backtrace and print it to stdout. */ +void xine_print_trace (void) { +#if HAVE_BACKTRACE + /* Code Taken from GNU C Library manual */ + void *array[10]; + size_t size; + char **strings; + size_t i; + + size = backtrace (array, 10); + strings = backtrace_symbols (array, size); + + printf ("Obtained %d stack frames.\n", size); + + for (i = 0; i < size; i++) { + printf ("%s\n", strings[i]); + } + free (strings); +#elif HAVE_PRINTSTACK + printstack(STDOUT_FILENO); +#else + printf("stack backtrace not available.\n"); +#endif +} -- cgit v1.2.3