summaryrefslogtreecommitdiff
path: root/vm_dump.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-02 07:02:54 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-02 07:02:54 +0000
commita1a6fd90bb4045b95963788fb923a9a54fdaf502 (patch)
tree37738c5339abaefed3812606f737945e79e63fc0 /vm_dump.c
parent5376610d0c671fd9076cd8347e2aac388b93dde2 (diff)
* vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.
* internal.h (rb_print_backtrace): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/vm_dump.c b/vm_dump.c
index 54de8ca..d0bfe59 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -675,6 +675,34 @@ dump_thread(void *arg)
#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)
#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 */