mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm.c (vm_backtrace_each, vm_backtrace_push),
vm_eval.c (print_backtrace), vm_dump.c (bugreport_backtrace): rb_backtrace_iter_func now takes VALUE as file and method names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
232836ea5a
commit
cd48eb8fd5
4 changed files with 20 additions and 13 deletions
|
@ -1,7 +1,8 @@
|
||||||
Sun Aug 16 09:47:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Aug 16 10:38:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* vm_dump.c (bugreport_backtrace): rb_backtrace_iter_func now
|
* vm.c (vm_backtrace_each, vm_backtrace_push),
|
||||||
takes VALUE as file and method names.
|
vm_eval.c (print_backtrace), vm_dump.c (bugreport_backtrace):
|
||||||
|
rb_backtrace_iter_func now takes VALUE as file and method names.
|
||||||
|
|
||||||
Sun Aug 16 03:06:59 2009 Koichi Sasada <ko1@atdot.net>
|
Sun Aug 16 03:06:59 2009 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
|
19
vm.c
19
vm.c
|
@ -712,7 +712,7 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
|
||||||
{
|
{
|
||||||
const rb_control_frame_t *limit_cfp = th->cfp;
|
const rb_control_frame_t *limit_cfp = th->cfp;
|
||||||
const rb_control_frame_t *cfp = (void *)(th->stack + th->stack_size);
|
const rb_control_frame_t *cfp = (void *)(th->stack + th->stack_size);
|
||||||
const char *file = "ruby";
|
VALUE file = Qnil;
|
||||||
int line_no = 0;
|
int line_no = 0;
|
||||||
|
|
||||||
cfp -= 2;
|
cfp -= 2;
|
||||||
|
@ -722,19 +722,20 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
limit_cfp = RUBY_VM_NEXT_CONTROL_FRAME(limit_cfp);
|
limit_cfp = RUBY_VM_NEXT_CONTROL_FRAME(limit_cfp);
|
||||||
if (th->vm->progname) file = RSTRING_PTR(th->vm->progname);
|
if (th->vm->progname) file = th->vm->progname;
|
||||||
while (cfp > limit_cfp) {
|
while (cfp > limit_cfp) {
|
||||||
if (cfp->iseq != 0) {
|
if (cfp->iseq != 0) {
|
||||||
if (cfp->pc != 0) {
|
if (cfp->pc != 0) {
|
||||||
rb_iseq_t *iseq = cfp->iseq;
|
rb_iseq_t *iseq = cfp->iseq;
|
||||||
|
|
||||||
line_no = rb_vm_get_sourceline(cfp);
|
line_no = rb_vm_get_sourceline(cfp);
|
||||||
file = RSTRING_PTR(iseq->filename);
|
file = iseq->filename;
|
||||||
if ((*iter)(arg, file, line_no, RSTRING_PTR(iseq->name))) break;
|
if ((*iter)(arg, file, line_no, iseq->name)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (RUBYVM_CFUNC_FRAME_P(cfp)) {
|
else if (RUBYVM_CFUNC_FRAME_P(cfp)) {
|
||||||
if ((*iter)(arg, file, line_no, rb_id2name(cfp->me->original_id))) break;
|
if (NIL_P(file)) file = rb_str_new_cstr("ruby");
|
||||||
|
if ((*iter)(arg, file, line_no, rb_id2str(cfp->me->original_id))) break;
|
||||||
}
|
}
|
||||||
cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp);
|
cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp);
|
||||||
}
|
}
|
||||||
|
@ -742,13 +743,17 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vm_backtrace_push(void *arg, const char *file, int line_no, const char *name)
|
vm_backtrace_push(void *arg, VALUE file, int line_no, VALUE name)
|
||||||
{
|
{
|
||||||
VALUE *aryp = arg;
|
VALUE *aryp = arg;
|
||||||
|
VALUE bt;
|
||||||
|
|
||||||
if (!*aryp) {
|
if (!*aryp) {
|
||||||
*aryp = rb_ary_new();
|
*aryp = rb_ary_new();
|
||||||
}
|
}
|
||||||
rb_ary_push(*aryp, rb_sprintf("%s:%d:in `%s'", file, line_no, name));
|
bt = rb_enc_sprintf(rb_enc_compatible(file, name), "%s:%d:in `%s'",
|
||||||
|
RSTRING_PTR(file), line_no, RSTRING_PTR(name));
|
||||||
|
rb_ary_push(*aryp, bt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -588,7 +588,7 @@ VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
|
||||||
void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
|
void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
|
||||||
int ruby_thread_has_gvl_p(void);
|
int ruby_thread_has_gvl_p(void);
|
||||||
VALUE rb_make_backtrace(void);
|
VALUE rb_make_backtrace(void);
|
||||||
typedef int rb_backtrace_iter_func(void *, const char *, int, const char *);
|
typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
|
||||||
VALUE rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg);
|
VALUE rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg);
|
||||||
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
|
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
|
||||||
|
|
||||||
|
|
|
@ -1345,9 +1345,10 @@ rb_f_caller(int argc, VALUE *argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
print_backtrace(void *arg, const char *file, int line, const char *method)
|
print_backtrace(void *arg, VALUE file, int line, VALUE method)
|
||||||
{
|
{
|
||||||
fprintf((FILE *)arg, "\tfrom %s:%d:in `%s'\n", file, line, method);
|
fprintf((FILE *)arg, "\tfrom %s:%d:in `%s'\n",
|
||||||
|
RSTRING_PTR(file), line, RSTRING_PTR(method));
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue