Project

General

Profile

Feature #17638 ยป ruby-cygwin-backtrace.patch

xtkoba (Tee KOBAYASHI), 02/27/2021 10:48 PM

View differences:

configure.ac
2985 2985
    AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [
2986 2986
	AC_CHECK_LIB([execinfo], [backtrace])
2987 2987
	AC_CHECK_LIB([unwind], [unw_backtrace])
2988
    ])])
2988
    ])],
2989
[*-cygwin*], [
2990
    AS_IF([test "x$ac_cv_func_sigaltstack" = xno], [
2991
	AC_CACHE_CHECK(for CaptureStackBackTrace, rb_cv_have_CaptureStackBackTrace, [
2992
	    AC_LINK_IFELSE([AC_LANG_SOURCE([[
2993
#include <windows.h>
2994

  
2995
#define TRACE_SIZE 256
2996
void *trace[TRACE_SIZE];
2997

  
2998
int
2999
main()
3000
{
3001
    CaptureStackBackTrace(0, TRACE_SIZE, trace, NULL);
3002
    return 0;
3003
}
3004
]])],
3005
		rb_cv_have_CaptureStackBackTrace=yes,
3006
		rb_cv_have_CaptureStackBackTrace=no)
3007
	])
3008
	AS_IF([test "$rb_cv_have_CaptureStackBackTrace" = yes], [
3009
	    AC_DEFINE(HAVE_CAPTURESTACKBACKTRACE, 1)
3010
	])])])
2989 3011
AC_CHECK_FUNCS(backtrace)
2990 3012

  
2991 3013
AS_IF([test "x$ac_cv_func_backtrace" = xyes], [
2992
-- a/vm_dump.c
3014
++ b/vm_dump.c
......
582 582
#  undef HAVE_BACKTRACE
583 583
#  define HAVE_BACKTRACE 0
584 584
# endif
585
#elif defined(__CYGWIN__) && defined(HAVE_CAPTURESTACKBACKTRACE) && \
586
    defined(USE_LIBBACKTRACE)
587
# define HAVE_BACKTRACE 1
588
# include <windows.h>
589
# undef backtrace
590
# define backtrace(buffer, size) CaptureStackBackTrace(0, size, buffer, NULL)
585 591
#else
586 592
# define HAVE_BACKTRACE 0
587 593
#endif