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
AC_CHECK_FUNCS(procstat_getvmmap)
])
])
AC_CHECK_HEADERS([execinfo.h])
AS_CASE(["$target_cpu-$target_os"],
[*-linux*], [
AS_IF([test "x$ac_cv_header_execinfo_h" = xno], [
AC_CHECK_LIB([unwind], [unw_backtrace])
])],
[*-darwin*], [
AC_CHECK_HEADERS([libproc.h])
AC_CHECK_HEADERS([execinfo.h])
AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [
AC_CHECK_LIB([execinfo], [backtrace])
AC_CHECK_HEADERS([libunwind.h])
])],
[*-freebsd*|x86_64-netbsd*], [
AC_CHECK_HEADERS([execinfo.h])
AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [
AC_CHECK_LIB([execinfo], [backtrace])
AC_CHECK_LIB([unwind], [unw_backtrace])
-- a/vm.c
++ b/vm.c
......
nsdr(VALUE self)
{
VALUE ary = rb_ary_new();
#if HAVE_BACKTRACE
#if HAVE_BACKTRACE && defined(HAVE_EXECINFO_H)
#include <execinfo.h>
#define MAX_NATIVE_TRACE 1024
static void *trace[MAX_NATIVE_TRACE];
-- a/vm_dump.c
++ b/vm_dump.c
......
#if defined(HAVE_BACKTRACE)
# ifdef HAVE_LIBUNWIND
# ifdef __linux__
# include <libunwind.h>
# endif
# undef backtrace
# define backtrace unw_backtrace
# elif defined(__APPLE__) && defined(__x86_64__) && defined(HAVE_LIBUNWIND_H)
......
#endif
#if HAVE_BACKTRACE
# include <execinfo.h>
# ifdef HAVE_EXECINFO_H
# include <execinfo.h>
# endif
#elif defined(_WIN32)
# include <imagehlp.h>
# ifndef SYMOPT_DEBUG
......
int n = (int)backtrace(trace, MAX_NATIVE_TRACE);
#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H)) && defined(HAVE_DLADDR) && !defined(__sparc)
rb_dump_backtrace_with_lines(n, trace);
#else
#elif defined(HAVE_EXECINFO_H)
char **syms = backtrace_symbols(trace, n);
if (syms) {
int i;
    (1-1/1)