diff options
| author | take_cheeze <[email protected]> | 2013-09-01 22:43:17 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2013-09-02 00:48:06 +0900 |
| commit | 3d1fffbd6bce3a6f9a77af3116078574ce8d5fe9 (patch) | |
| tree | 35d6c58a23442ca055671c3b9e34f736153bc4ec /src/backtrace.c | |
| parent | bc131350d416409220fd3294d2ffcea3ae73027d (diff) | |
| download | mruby-3d1fffbd6bce3a6f9a77af3116078574ce8d5fe9.tar.gz mruby-3d1fffbd6bce3a6f9a77af3116078574ce8d5fe9.zip | |
support multiple filename in irep
Diffstat (limited to 'src/backtrace.c')
| -rw-r--r-- | src/backtrace.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backtrace.c b/src/backtrace.c index d7881dce1..a1c35d09f 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -10,6 +10,7 @@ #include "mruby/array.h" #include "mruby/string.h" #include "mruby/class.h" +#include "mruby/debug.h" #include <stdarg.h> typedef void (*output_stream_func)(mrb_state*, void*, int, const char*, ...); @@ -70,7 +71,7 @@ mrb_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun for (i = ciidx; i >= 0; i--) { ci = &mrb->c->cibase[i]; - filename = "(unknown)"; + filename = NULL; line = -1; if (!verbose && MRB_PROC_CFUNC_P(ci->proc)) { @@ -78,21 +79,16 @@ mrb_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun } if(!MRB_PROC_CFUNC_P(ci->proc)) { mrb_irep *irep = ci->proc->body.irep; - if (irep->filename != NULL) - filename = irep->filename; - if (irep->lines != NULL) { - mrb_code *pc; - - if (i+1 <= ciidx) { - pc = mrb->c->cibase[i+1].pc; - } - else { - pc = (mrb_code*)mrb_voidp(mrb_obj_iv_get(mrb, exc, mrb_intern2(mrb, "lastpc", 6))); - } - if (irep->iseq <= pc && pc < irep->iseq + irep->ilen) { - line = irep->lines[pc - irep->iseq - 1]; - } + mrb_code *pc; + + if (i+1 <= ciidx) { + pc = mrb->c->cibase[i+1].pc; + } + else { + pc = (mrb_code*)mrb_voidp(mrb_obj_iv_get(mrb, exc, mrb_intern2(mrb, "lastpc", 6))); } + filename = mrb_get_filename(irep, pc - irep->iseq - 1); + line = mrb_get_line(irep, pc - irep->iseq - 1); } if (!verbose && line == -1) continue; if (ci->target_class == ci->proc->target_class) @@ -100,6 +96,10 @@ mrb_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun else sep = "#"; + if (!filename) { + filename = "(unknown)"; + } + method = mrb_sym2name(mrb, ci->mid); if (verbose && !method && ci->proc->env) { method = mrb_sym2name(mrb, ci->proc->env->mid); |
