Project

General

Profile

Feature #17616 ยป ruby-linux-non_glibc-libunwind-backtrace.patch

xtkoba (Tee KOBAYASHI), 02/09/2021 12:58 PM

View differences:

configure.ac
2946 2946
	AC_CHECK_FUNCS(procstat_getvmmap)
2947 2947
    ])
2948 2948
    ])
2949
AC_CHECK_HEADERS([execinfo.h])
2949 2950
AS_CASE(["$target_cpu-$target_os"],
2951
[*-linux*], [
2952
    AS_IF([test "x$ac_cv_header_execinfo_h" = xno], [
2953
	AC_CHECK_LIB([unwind], [unw_backtrace])
2954
    ])],
2950 2955
[*-darwin*], [
2951 2956
    AC_CHECK_HEADERS([libproc.h])
2952
    AC_CHECK_HEADERS([execinfo.h])
2953 2957
    AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [
2954 2958
	AC_CHECK_LIB([execinfo], [backtrace])
2955 2959
	AC_CHECK_HEADERS([libunwind.h])
2956 2960
    ])],
2957 2961
[*-freebsd*|x86_64-netbsd*], [
2958
    AC_CHECK_HEADERS([execinfo.h])
2959 2962
    AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [
2960 2963
	AC_CHECK_LIB([execinfo], [backtrace])
2961 2964
	AC_CHECK_LIB([unwind], [unw_backtrace])
2962
-- a/vm.c
2965
++ b/vm.c
......
3256 3256
nsdr(VALUE self)
3257 3257
{
3258 3258
    VALUE ary = rb_ary_new();
3259
#if HAVE_BACKTRACE
3259
#if HAVE_BACKTRACE && defined(HAVE_EXECINFO_H)
3260 3260
#include <execinfo.h>
3261 3261
#define MAX_NATIVE_TRACE 1024
3262 3262
    static void *trace[MAX_NATIVE_TRACE];
3263
-- a/vm_dump.c
3263
++ b/vm_dump.c
......
471 471

  
472 472
#if defined(HAVE_BACKTRACE)
473 473
# ifdef HAVE_LIBUNWIND
474
#  ifdef __linux__
475
#   include <libunwind.h>
476
#  endif
474 477
#  undef backtrace
475 478
#  define backtrace unw_backtrace
476 479
# elif defined(__APPLE__) && defined(__x86_64__) && defined(HAVE_LIBUNWIND_H)
......
580 583
#endif
581 584

  
582 585
#if HAVE_BACKTRACE
583
# include <execinfo.h>
586
# ifdef HAVE_EXECINFO_H
587
#  include <execinfo.h>
588
# endif
584 589
#elif defined(_WIN32)
585 590
# include <imagehlp.h>
586 591
# ifndef SYMOPT_DEBUG
......
758 763
    int n = (int)backtrace(trace, MAX_NATIVE_TRACE);
759 764
#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H)) && defined(HAVE_DLADDR) && !defined(__sparc)
760 765
    rb_dump_backtrace_with_lines(n, trace);
761
#else
766
#elif defined(HAVE_EXECINFO_H)
762 767
    char **syms = backtrace_symbols(trace, n);
763 768
    if (syms) {
764 769
	int i;