[前][次][番号順一覧][スレッド一覧]

ruby-changes:27249

From: naruse <ko1@a...>
Date: Tue, 19 Feb 2013 06:21:10 +0900 (JST)
Subject: [ruby-changes:27249] naruse:r39301 (trunk): * configure.in: check whether backtrace(3) works well or not.

naruse	2013-02-19 06:20:59 +0900 (Tue, 19 Feb 2013)

  New Revision: 39301

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39301

  Log:
    * configure.in: check whether backtrace(3) works well or not.
    
    * vm_dump.c: set HAVE_BACKTRACE 0 if BROKEN_BACKTRACE.

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/vm_dump.c

Index: configure.in
===================================================================
--- configure.in	(revision 39300)
+++ configure.in	(revision 39301)
@@ -2433,6 +2433,64 @@ AS_CASE(["$target_cpu-$target_os"], https://github.com/ruby/ruby/blob/trunk/configure.in#L2433
     fi])
 AC_CHECK_FUNCS(backtrace)
 
+if test "x$ac_cv_func_backtrace" = xyes; then
+  AC_CACHE_CHECK(for broken backtrace, rb_cv_broken_backtrace,
+    [AC_TRY_RUN([
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <signal.h>
+#include <execinfo.h>
+
+#define TRACE_SIZE 256
+
+void sigsegv(int signum, siginfo_t *info, void *ctx){
+    void *trace[TRACE_SIZE];
+    int n = backtrace(trace, TRACE_SIZE);
+    if (n > 0) {
+	fprintf(stdout, "backtrace:%d\n",n);
+    } else {
+	abort();
+    }
+    _exit(0);
+}
+int
+main()
+{
+    stack_t ss;
+    ss.ss_sp = malloc(SIGSTKSZ);
+    if (ss.ss_sp == NULL) {
+	fprintf(stderr, "cannot allocate memory for sigaltstack\n");
+	abort();
+    }
+    ss.ss_size = SIGSTKSZ;
+    ss.ss_flags = 0;
+    if (sigaltstack(&ss, NULL) == -1) {
+	fprintf(stderr, "sigaltstack failed\n");
+	abort();
+    }
+    struct sigaction sa;
+    memset(&sa, 0, sizeof(struct sigaction));
+    sigemptyset(&sa.sa_mask);
+    sa.sa_sigaction = sigsegv;
+    sa.sa_flags |= SA_SIGINFO;
+    sa.sa_flags |= SA_ONSTACK;
+    sigaction(SIGSEGV, &sa, NULL);
+    int *a = NULL;
+    a[0] = 1;
+    return 0;
+}
+],
+	rb_cv_broken_backtrace=no,
+	rb_cv_broken_backtrace=yes,
+	rb_cv_broken_backtrace=no)])
+  if test "$rb_cv_broken_backtrace" = yes; then
+    AC_DEFINE(BROKEN_BACKTRACE, 1)
+  fi
+fi
+
 AC_ARG_WITH(valgrind,
         AS_HELP_STRING([--without-valgrind],[disable valgrind memcheck support]),
         [], with_valgrind=yes)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39300)
+++ ChangeLog	(revision 39301)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Feb 19 04:26:29 2013  NARUSE, Yui  <naruse@r...>
+
+	* configure.in: check whether backtrace(3) works well or not.
+
+	* vm_dump.c: set HAVE_BACKTRACE 0 if BROKEN_BACKTRACE.
+
 Mon Feb 18 16:30:18 2013  Akinori MUSHA  <knu@i...>
 
 	* lib/ipaddr.rb (IPAddr#in6_addr): Fix a typo with the closing
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 39300)
+++ vm_dump.c	(revision 39301)
@@ -427,6 +427,10 @@ rb_vmdebug_thread_dump_state(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L427
 #ifndef HAVE_BACKTRACE
 #define HAVE_BACKTRACE 0
 #endif
+#ifdef BROKEN_BACKTRACE
+# undef HAVE_BACKTRACE
+# define HAVE_BACKTRACE 0
+#endif
 #if HAVE_BACKTRACE
 # include <execinfo.h>
 #elif defined(_WIN32)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]