diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | error.c | 7 | ||||
-rw-r--r-- | vm_dump.c | 26 |
3 files changed, 31 insertions, 6 deletions
@@ -1,3 +1,7 @@ +Wed Dec 24 22:36:06 2008 Koichi Sasada <ko1@atdot.net> + + * error.c, vm_dump.c: change message by rb_bug(). + Wed Dec 24 21:57:39 2008 Koichi Sasada <ko1@atdot.net> * compile.c (iseq_peephole_optimize): fix typo. @@ -207,10 +207,17 @@ report_bug(const char *file, int line, const char *fmt, va_list args) if (fwrite(buf, 1, len, out) == len || fwrite(buf, 1, len, (out = stdout)) == len) { + fputs("[BUG] ", out); vfprintf(out, fmt, args); fprintf(out, "\n%s\n\n", ruby_description); + rb_vm_bugreport(); + + fprintf(out, + "[NOTE]\n" + "You may encounter a bug of Ruby interpreter. Bug reports are welcome.\n" + "For details: http://www.ruby-lang.org/bugreport.html\n\n"); } } @@ -580,9 +580,16 @@ rb_vm_bugreport(void) SDR(); bt = rb_make_backtrace(); - if (TYPE(bt) == T_ARRAY) - for (i = 0; i < RARRAY_LEN(bt); i++) { - dp(RARRAY_PTR(bt)[i]); + + if (bt) { + fprintf(stderr, "-- Ruby level backtrace information" + "-----------------------------------------\n"); + + for (i = 0; i < RARRAY_LEN(bt); i++) { + VALUE str = RARRAY_PTR(bt)[i]; + fprintf(stderr, "%s\n", RSTRING_PTR(str)); + } + fprintf(stderr, "\n"); } } @@ -592,13 +599,20 @@ rb_vm_bugreport(void) { static void *trace[MAX_NATIVE_TRACE]; int n = backtrace(trace, MAX_NATIVE_TRACE); + char **syms = backtrace_symbols(trace, n); int i; - fprintf(stderr, "-- backtrace of native function call (Use addr2line) --\n"); + fprintf(stderr, "-- C level backtrace information " + "-------------------------------------------\n"); for (i=0; i<n; i++) { - fprintf(stderr, "%p\n", trace[i]); + char *info = syms ? syms[i] : ""; + fprintf(stderr, "%p %s\n", trace[i], info); + } + fprintf(stderr, "\n"); + + if (syms) { + free(syms); } - fprintf(stderr, "-------------------------------------------------------\n"); } #endif } |