Feature #17638 » ruby-libbacktrace.patch
configure.ac | ||
---|---|---|
])
|
||
])
|
||
AC_CACHE_CHECK(for libbacktrace, rb_cv_use_libbacktrace, [
|
||
AS_UNSET(ORIG_LIBS)
|
||
ORIG_LIBS="$LIBS"
|
||
LIBS="$LIBS -lbacktrace"
|
||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||
#include <backtrace-supported.h>
|
||
#include <backtrace.h>
|
||
int
|
||
main(void)
|
||
{
|
||
#if BACKTRACE_SUPPORTED
|
||
struct backtrace_state *state = backtrace_create_state(NULL, 0, NULL, NULL);
|
||
return 0;
|
||
#else
|
||
#error libbacktrace is not supported
|
||
return 1;
|
||
#endif
|
||
}
|
||
]])],
|
||
rb_cv_use_libbacktrace=yes,
|
||
rb_cv_use_libbacktrace=no)
|
||
LIBS="$ORIG_LIBS"])
|
||
AS_IF([test "$rb_cv_use_libbacktrace" = yes], [
|
||
AC_DEFINE(USE_LIBBACKTRACE, 1)
|
||
LIBS="$LIBS -lbacktrace"
|
||
])
|
||
AC_ARG_WITH(valgrind,
|
||
AS_HELP_STRING([--without-valgrind],[disable valgrind memcheck support]),
|
||
[], with_valgrind=yes)
|
||
-- a/vm_dump.c
|
||
++ b/vm_dump.c
|
||
... | ... | |
# endif
|
||
#endif
|
||
#if defined(USE_LIBBACKTRACE)
|
||
# include <backtrace.h>
|
||
#endif
|
||
#if defined(HAVE_BACKTRACE)
|
||
# ifdef HAVE_LIBUNWIND
|
||
# undef backtrace
|
||
... | ... | |
void
|
||
rb_print_backtrace(void)
|
||
{
|
||
#if HAVE_BACKTRACE
|
||
#if defined(USE_LIBBACKTRACE)
|
||
struct backtrace_state *state = backtrace_create_state(NULL, 0, NULL, NULL);
|
||
backtrace_print(state, 0, stderr);
|
||
#elif HAVE_BACKTRACE
|
||
#define MAX_NATIVE_TRACE 1024
|
||
static void *trace[MAX_NATIVE_TRACE];
|
||
int n = (int)backtrace(trace, MAX_NATIVE_TRACE);
|
||
... | ... | |
rb_dump_machine_register(ctx);
|
||
#if HAVE_BACKTRACE || defined(_WIN32)
|
||
#if defined(USE_LIBBACKTRACE) || HAVE_BACKTRACE || defined(_WIN32)
|
||
fprintf(stderr, "-- C level backtrace information "
|
||
"-------------------------------------------\n");
|
||
rb_print_backtrace();
|