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

ruby-changes:28010

From: naruse <ko1@a...>
Date: Tue, 2 Apr 2013 16:03:04 +0900 (JST)
Subject: [ruby-changes:28010] naruse:r40062 (trunk): * vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.

naruse	2013-04-02 16:02:54 +0900 (Tue, 02 Apr 2013)

  New Revision: 40062

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

  Log:
    * vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.
    
    * internal.h (rb_print_backtrace): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/vm_dump.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40061)
+++ ChangeLog	(revision 40062)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Apr  2 16:00:06 2013  NARUSE, Yui  <naruse@r...>
+
+	* vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.
+
+	* internal.h (rb_print_backtrace): ditto.
+
 Tue Apr  2 15:22:09 2013  NARUSE, Yui  <naruse@r...>
 
 	* test/ruby/envutil.rb (assert_separately): stop_auto_run of
Index: internal.h
===================================================================
--- internal.h	(revision 40061)
+++ internal.h	(revision 40062)
@@ -336,6 +336,7 @@ VALUE rb_sourcefilename(void); https://github.com/ruby/ruby/blob/trunk/internal.h#L336
 
 /* vm_dump.c */
 void rb_vm_bugreport(void);
+void rb_print_backtrace(void);
 
 /* vm_eval.c */
 void Init_vm_eval(void);
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 40061)
+++ vm_dump.c	(revision 40062)
@@ -675,6 +675,34 @@ dump_thread(void *arg) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L675
 #endif
 
 void
+rb_print_backtrace(void)
+{
+#if HAVE_BACKTRACE
+#define MAX_NATIVE_TRACE 1024
+    static void *trace[MAX_NATIVE_TRACE];
+    int n = backtrace(trace, MAX_NATIVE_TRACE);
+    char **syms = backtrace_symbols(trace, n);
+
+    if (syms) {
+#ifdef USE_ELF
+	rb_dump_backtrace_with_lines(n, trace, syms);
+#else
+	int i;
+	for (i=0; i<n; i++) {
+	    fprintf(stderr, "%s\n", syms[i]);
+	}
+#endif
+	free(syms);
+    }
+#elif defined(_WIN32)
+    DWORD tid = GetCurrentThreadId();
+    HANDLE th = (HANDLE)_beginthread(dump_thread, 0, &tid);
+    if (th != (HANDLE)-1)
+	WaitForSingleObject(th, INFINITE);
+#endif
+}
+
+void
 rb_vm_bugreport(void)
 {
 #ifdef __linux__
@@ -708,32 +736,8 @@ rb_vm_bugreport(void) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L736
 #if HAVE_BACKTRACE || defined(_WIN32)
     fprintf(stderr, "-- C level backtrace information "
 	    "-------------------------------------------\n");
+    rb_print_backtrace();
 
-    {
-#if HAVE_BACKTRACE
-#define MAX_NATIVE_TRACE 1024
-	static void *trace[MAX_NATIVE_TRACE];
-	int n = backtrace(trace, MAX_NATIVE_TRACE);
-	char **syms = backtrace_symbols(trace, n);
-
-	if (syms) {
-#ifdef USE_ELF
-	    rb_dump_backtrace_with_lines(n, trace, syms);
-#else
-	    int i;
-	    for (i=0; i<n; i++) {
-		fprintf(stderr, "%s\n", syms[i]);
-	    }
-#endif
-	    free(syms);
-	}
-#elif defined(_WIN32)
-	DWORD tid = GetCurrentThreadId();
-	HANDLE th = (HANDLE)_beginthread(dump_thread, 0, &tid);
-	if (th != (HANDLE)-1)
-	    WaitForSingleObject(th, INFINITE);
-#endif
-    }
 
     fprintf(stderr, "\n");
 #endif /* HAVE_BACKTRACE */

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

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