Project

General

Profile

Feature #17638 ยป ruby-libbacktrace.patch

xtkoba (Tee KOBAYASHI), 02/17/2021 12:51 PM

View differences:

configure.ac
3022 3022
  ])
3023 3023
])
3024 3024

  
3025
AC_CACHE_CHECK(for libbacktrace, rb_cv_use_libbacktrace, [
3026
  AS_UNSET(ORIG_LIBS)
3027
  ORIG_LIBS="$LIBS"
3028
  LIBS="$LIBS -lbacktrace"
3029
  AC_LINK_IFELSE([AC_LANG_SOURCE([[
3030
#include <backtrace-supported.h>
3031
#include <backtrace.h>
3032

  
3033
int
3034
main(void)
3035
{
3036
#if BACKTRACE_SUPPORTED
3037
    struct backtrace_state *state = backtrace_create_state(NULL, 0, NULL, NULL);
3038
    return 0;
3039
#else
3040
#error libbacktrace is not supported
3041
    return 1;
3042
#endif
3043
}
3044
]])],
3045
    rb_cv_use_libbacktrace=yes,
3046
    rb_cv_use_libbacktrace=no)
3047
  LIBS="$ORIG_LIBS"])
3048
AS_IF([test "$rb_cv_use_libbacktrace" = yes], [
3049
  AC_DEFINE(USE_LIBBACKTRACE, 1)
3050
  LIBS="$LIBS -lbacktrace"
3051
])
3052

  
3025 3053
AC_ARG_WITH(valgrind,
3026 3054
        AS_HELP_STRING([--without-valgrind],[disable valgrind memcheck support]),
3027 3055
        [], with_valgrind=yes)
3028
-- a/vm_dump.c
3056
++ b/vm_dump.c
......
469 469
# endif
470 470
#endif
471 471

  
472
#if defined(USE_LIBBACKTRACE)
473
# include <backtrace.h>
474
#endif
475

  
472 476
#if defined(HAVE_BACKTRACE)
473 477
# ifdef HAVE_LIBUNWIND
474 478
#  undef backtrace
......
752 756
void
753 757
rb_print_backtrace(void)
754 758
{
755
#if HAVE_BACKTRACE
759
#if defined(USE_LIBBACKTRACE)
760
    struct backtrace_state *state = backtrace_create_state(NULL, 0, NULL, NULL);
761
    backtrace_print(state, 0, stderr);
762
#elif HAVE_BACKTRACE
756 763
#define MAX_NATIVE_TRACE 1024
757 764
    static void *trace[MAX_NATIVE_TRACE];
758 765
    int n = (int)backtrace(trace, MAX_NATIVE_TRACE);
......
1036 1043

  
1037 1044
    rb_dump_machine_register(ctx);
1038 1045

  
1039
#if HAVE_BACKTRACE || defined(_WIN32)
1046
#if defined(USE_LIBBACKTRACE) || HAVE_BACKTRACE || defined(_WIN32)
1040 1047
    fprintf(stderr, "-- C level backtrace information "
1041 1048
	    "-------------------------------------------\n");
1042 1049
    rb_print_backtrace();