This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 33b95fd86ead735cd54f3b0f7cf87c779a4370ad (commit) from 18f21817f0ccdf5e4024183595e127eec8ce7744 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/33b95fd86ead735cd54f3b0f7cf87c779a437...
commit 33b95fd86ead735cd54f3b0f7cf87c779a4370ad Author: Tomas Gavenciak gavento@ucw.cz Date: Sat Dec 22 22:37:06 2012 +0100
core: Add a C backtrace to GP_ABORT
diff --git a/configure b/configure index 6eead34..d2f2d43 100755 --- a/configure +++ b/configure @@ -238,7 +238,7 @@ if __name__ == '__main__': # # name, description, [detection], cflags, ldflags, list of modules library is needed for # - l = libraries([["libpng", + l = libraries([["libpng", "Portable Network Graphics Library", [header_exists, "png.h"], "", "-lpng", ["loaders"]], ["libsdl", @@ -262,6 +262,10 @@ if __name__ == '__main__': ["dl", "Dynamic linker", [header_exists, "dlfcn.h"], "", "-ldl", ["core"]], + ["backtrace", + "C stack trace writeout", + [c_try_compile, "#include <execinfo.h>nint main(void) { backtrace(0, 0); }", + "Checking for backtrace() ... "], "", "", ["core"]], ["V4L2", "Video for linux 2", [header_exists, "linux/videodev2.h"], "", "", ["grabbers"]]], cfg) diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h index 95731b7..1140e76 100644 --- a/include/core/GP_Common.h +++ b/include/core/GP_Common.h @@ -99,13 +99,14 @@ * and prints message and calls abort(). * GP_GENERAL_CHECK is a check with specified message prefix * (for assert and check) - * - * SWIG_print_trace() prints a trace of Python stack if a Python interpreter - * is set up. In case more wrappers are written, should print a trace - * for the currently active. */
-void SWIG_print_trace(void); +/* + * Print as much trace info as possible. Currently, the (C) call stack and + * the Python stack if a Python interpreter is set up. In case more wrappers + * are written, it should print a trace for the currently active. + */ +void GP_PrintAbortInfo(void);
#define GP_INTERNAL_ABORT_BUFSIZE 1024 #define GP_INTERNAL_ABORT(str_abort_msg_, ...) do { @@ -118,8 +119,8 @@ void SWIG_print_trace(void); buf += snprintf(buf, bufend - buf, "abort()"); else buf += snprintf(buf, bufend - buf, " " __VA_ARGS__); - SWIG_print_trace(); fprintf(stderr, "%sn", bufstart); + GP_PrintAbortInfo(); abort(); } while (0)
diff --git a/libs/core/GP_Common.c b/libs/core/GP_Common.c index 2cf6fc9..52c4920 100644 --- a/libs/core/GP_Common.c +++ b/libs/core/GP_Common.c @@ -24,14 +24,35 @@
#include "../config.h"
-#include "core/GP_Common.h" +#include <stdio.h> + +#ifdef HAVE_BACKTRACE +#include <execinfo.h> +#endif /* HAVE_BACKTRACE */
#ifdef HAVE_DL #include <dlfcn.h> #endif /* HAVE_DL */
+#include "core/GP_Common.h" + +#define GP_ABORT_INFO_TRACE_LEVELS 20 + + +void GP_PrintCStack(void) +{ +#ifdef HAVE_BACKTRACE +#if GP_ABORT_INFO_TRACE_LEVELS > 0 + void * buffer[GP_ABORT_INFO_TRACE_LEVELS + 1]; + int size = backtrace(buffer, GP_ABORT_INFO_TRACE_LEVELS); + fprintf(stderr, "nC stack trace (most recent call first):n"); + fflush(stderr); + backtrace_symbols_fd(buffer, size, fileno(stderr)); +#endif /* GP_ABORT_INFO_TRACE_LEVELS > 0 */ +#endif /* HAVE_BACKTRACE */ +}
-void SWIG_print_trace(void) +void GP_PrintPythonStack(void) { #ifdef HAVE_DL /* Print python stack trace in case python lib is loaded and @@ -40,7 +61,17 @@ void SWIG_print_trace(void) int (*dl_PyRun_SimpleString)(const char *); dl_Py_IsInitialized = dlsym(RTLD_DEFAULT, "Py_IsInitialized"); dl_PyRun_SimpleString = dlsym(RTLD_DEFAULT, "PyRun_SimpleString"); - if (dl_Py_IsInitialized && dl_PyRun_SimpleString && dl_Py_IsInitialized()) + if (dl_Py_IsInitialized && dl_PyRun_SimpleString && dl_Py_IsInitialized()) { + fprintf(stderr, "nPython stack trace (most recent call last; ignore last line):n"); + fflush(stderr); dl_PyRun_SimpleString("import traceback; traceback.print_stack();"); + } #endif /* HAVE_DL */ } + +void GP_PrintAbortInfo(void) +{ + GP_PrintPythonStack(); + GP_PrintCStack(); +} +
-----------------------------------------------------------------------
Summary of changes: configure | 6 +++++- include/core/GP_Common.h | 13 +++++++------ libs/core/GP_Common.c | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 10 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.