mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
th
-> ec
for backtrace functions.
* vm_backtrace.c: accept `ec` and rename `threadptr` to `ec`. * rb_threadptr_backtrace_object -> rb_ec_backtrace_object * rb_threadptr_backtrace_str_ary -> rb_ec_backtrace_str_ar * rb_threadptr_backtrace_location_ary -> rb_ec_backtrace_location_ary * threadptr_backtrace_to_ary -> ec_backtrace_to_ary * vm_eval.c (adjust_backtrace_in_eval): accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7fa4beba91
commit
ad1b64d35d
7 changed files with 25 additions and 25 deletions
2
eval.c
2
eval.c
|
@ -520,7 +520,7 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
|
||||||
exc_setup_cause(mesg, cause);
|
exc_setup_cause(mesg, cause);
|
||||||
}
|
}
|
||||||
if (NIL_P(bt)) {
|
if (NIL_P(bt)) {
|
||||||
VALUE at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
|
VALUE at = rb_ec_backtrace_object(ec);
|
||||||
rb_ivar_set(mesg, idBt_locations, at);
|
rb_ivar_set(mesg, idBt_locations, at);
|
||||||
set_backtrace(mesg, at);
|
set_backtrace(mesg, at);
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,9 +314,9 @@ void rb_thread_terminate_all(void);
|
||||||
VALUE rb_vm_cbase(void);
|
VALUE rb_vm_cbase(void);
|
||||||
|
|
||||||
/* vm_backtrace.c */
|
/* vm_backtrace.c */
|
||||||
VALUE rb_threadptr_backtrace_object(rb_thread_t *th);
|
VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec);
|
||||||
VALUE rb_threadptr_backtrace_str_ary(rb_thread_t *th, long lev, long n);
|
VALUE rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n);
|
||||||
VALUE rb_threadptr_backtrace_location_ary(rb_thread_t *th, long lev, long n);
|
VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n);
|
||||||
|
|
||||||
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
|
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
|
||||||
# ifdef HAVE_MBLEN
|
# ifdef HAVE_MBLEN
|
||||||
|
|
2
thread.c
2
thread.c
|
@ -4937,7 +4937,7 @@ debug_deadlock_check(rb_vm_t *vm, VALUE msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rb_str_catf(msg, "\n ");
|
rb_str_catf(msg, "\n ");
|
||||||
rb_str_concat(msg, rb_ary_join(rb_threadptr_backtrace_str_ary(th, 0, 0), sep));
|
rb_str_concat(msg, rb_ary_join(rb_ec_backtrace_str_ary(th->ec, 0, 0), sep));
|
||||||
rb_str_catf(msg, "\n");
|
rb_str_catf(msg, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -697,11 +697,11 @@ raise_argument_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const VA
|
||||||
VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */,
|
VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */,
|
||||||
iseq->body->iseq_encoded,
|
iseq->body->iseq_encoded,
|
||||||
ec->cfp->sp, 0, 0 /* stack_max */);
|
ec->cfp->sp, 0, 0 /* stack_max */);
|
||||||
at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
|
at = rb_ec_backtrace_object(ec);
|
||||||
rb_vm_pop_frame(ec);
|
rb_vm_pop_frame(ec);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
|
at = rb_ec_backtrace_object(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_ivar_set(exc, idBt_locations, at);
|
rb_ivar_set(exc, idBt_locations, at);
|
||||||
|
|
|
@ -512,12 +512,12 @@ bt_iter_cfunc(void *ptr, const rb_control_frame_t *cfp, ID mid)
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_threadptr_backtrace_object(rb_thread_t *th)
|
rb_ec_backtrace_object(const rb_execution_context_t *ec)
|
||||||
{
|
{
|
||||||
struct bt_iter_arg arg;
|
struct bt_iter_arg arg;
|
||||||
arg.prev_loc = 0;
|
arg.prev_loc = 0;
|
||||||
|
|
||||||
backtrace_each(th->ec,
|
backtrace_each(ec,
|
||||||
bt_init,
|
bt_init,
|
||||||
bt_iter_iseq,
|
bt_iter_iseq,
|
||||||
bt_iter_cfunc,
|
bt_iter_cfunc,
|
||||||
|
@ -650,15 +650,15 @@ backtrace_load_data(VALUE self, VALUE str)
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_threadptr_backtrace_str_ary(rb_thread_t *th, long lev, long n)
|
rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n)
|
||||||
{
|
{
|
||||||
return backtrace_to_str_ary(rb_threadptr_backtrace_object(th), lev, n);
|
return backtrace_to_str_ary(rb_ec_backtrace_object(ec), lev, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_threadptr_backtrace_location_ary(rb_thread_t *th, long lev, long n)
|
rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n)
|
||||||
{
|
{
|
||||||
return backtrace_to_location_ary(rb_threadptr_backtrace_object(th), lev, n);
|
return backtrace_to_location_ary(rb_ec_backtrace_object(ec), lev, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make old style backtrace directly */
|
/* make old style backtrace directly */
|
||||||
|
@ -812,15 +812,15 @@ rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output)
|
||||||
VALUE
|
VALUE
|
||||||
rb_make_backtrace(void)
|
rb_make_backtrace(void)
|
||||||
{
|
{
|
||||||
return rb_threadptr_backtrace_str_ary(GET_THREAD(), 0, 0);
|
return rb_ec_backtrace_str_ary(GET_EC(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
threadptr_backtrace_to_ary(rb_thread_t *th, int argc, const VALUE *argv, int lev_default, int lev_plus, int to_str)
|
ec_backtrace_to_ary(const rb_execution_context_t *ec, int argc, const VALUE *argv, int lev_default, int lev_plus, int to_str)
|
||||||
{
|
{
|
||||||
VALUE level, vn;
|
VALUE level, vn;
|
||||||
long lev, n;
|
long lev, n;
|
||||||
VALUE btval = rb_threadptr_backtrace_object(th);
|
VALUE btval = rb_ec_backtrace_object(ec);
|
||||||
VALUE r;
|
VALUE r;
|
||||||
rb_backtrace_t *bt;
|
rb_backtrace_t *bt;
|
||||||
|
|
||||||
|
@ -894,7 +894,7 @@ thread_backtrace_to_ary(int argc, const VALUE *argv, VALUE thval, int to_str)
|
||||||
if (target_th->to_kill || target_th->status == THREAD_KILLED)
|
if (target_th->to_kill || target_th->status == THREAD_KILLED)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
||||||
return threadptr_backtrace_to_ary(target_th, argc, argv, 0, 0, to_str);
|
return ec_backtrace_to_ary(target_th->ec, argc, argv, 0, 0, to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -950,7 +950,7 @@ rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_caller(int argc, VALUE *argv)
|
rb_f_caller(int argc, VALUE *argv)
|
||||||
{
|
{
|
||||||
return threadptr_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 1);
|
return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -978,7 +978,7 @@ rb_f_caller(int argc, VALUE *argv)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_caller_locations(int argc, VALUE *argv)
|
rb_f_caller_locations(int argc, VALUE *argv)
|
||||||
{
|
{
|
||||||
return threadptr_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 0);
|
return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called from Init_vm() in vm.c */
|
/* called from Init_vm() in vm.c */
|
||||||
|
@ -1178,7 +1178,7 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
|
||||||
|
|
||||||
dbg_context.th = th;
|
dbg_context.th = th;
|
||||||
dbg_context.cfp = dbg_context.th->ec->cfp;
|
dbg_context.cfp = dbg_context.th->ec->cfp;
|
||||||
dbg_context.backtrace = rb_threadptr_backtrace_location_ary(th, 0, 0);
|
dbg_context.backtrace = rb_ec_backtrace_location_ary(th->ec, 0, 0);
|
||||||
dbg_context.backtrace_size = RARRAY_LEN(dbg_context.backtrace);
|
dbg_context.backtrace_size = RARRAY_LEN(dbg_context.backtrace);
|
||||||
dbg_context.contexts = collect_caller_bindings(th);
|
dbg_context.contexts = collect_caller_bindings(th);
|
||||||
|
|
||||||
|
|
|
@ -1243,12 +1243,12 @@ rb_each(VALUE obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
adjust_backtrace_in_eval(rb_thread_t *th, VALUE errinfo)
|
adjust_backtrace_in_eval(const rb_execution_context_t *ec, VALUE errinfo)
|
||||||
{
|
{
|
||||||
VALUE errat = rb_get_backtrace(errinfo);
|
VALUE errat = rb_get_backtrace(errinfo);
|
||||||
VALUE mesg = rb_attr_get(errinfo, id_mesg);
|
VALUE mesg = rb_attr_get(errinfo, id_mesg);
|
||||||
if (RB_TYPE_P(errat, T_ARRAY)) {
|
if (RB_TYPE_P(errat, T_ARRAY)) {
|
||||||
VALUE bt2 = rb_threadptr_backtrace_str_ary(th, 0, 0);
|
VALUE bt2 = rb_ec_backtrace_str_ary(ec, 0, 0);
|
||||||
if (RARRAY_LEN(bt2) > 0) {
|
if (RARRAY_LEN(bt2) > 0) {
|
||||||
if (RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) {
|
if (RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) {
|
||||||
rb_ivar_set(errinfo, id_mesg, RARRAY_AREF(errat, 0));
|
rb_ivar_set(errinfo, id_mesg, RARRAY_AREF(errat, 0));
|
||||||
|
@ -1318,7 +1318,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
|
||||||
iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
|
iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
|
||||||
|
|
||||||
if (!iseq) {
|
if (!iseq) {
|
||||||
rb_exc_raise(adjust_backtrace_in_eval(rb_ec_thread_ptr(ec), ec->errinfo));
|
rb_exc_raise(adjust_backtrace_in_eval(ec, ec->errinfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: what the code checking? */
|
/* TODO: what the code checking? */
|
||||||
|
@ -1357,7 +1357,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
if (state == TAG_RAISE) {
|
if (state == TAG_RAISE) {
|
||||||
adjust_backtrace_in_eval(rb_ec_thread_ptr(ec), ec->errinfo);
|
adjust_backtrace_in_eval(ec, ec->errinfo);
|
||||||
}
|
}
|
||||||
EC_JUMP_TAG(ec, state);
|
EC_JUMP_TAG(ec, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ ec_stack_overflow(rb_execution_context_t *ec, int setup)
|
||||||
VALUE mesg = rb_ec_vm_ptr(ec)->special_exceptions[ruby_error_sysstack];
|
VALUE mesg = rb_ec_vm_ptr(ec)->special_exceptions[ruby_error_sysstack];
|
||||||
ec->raised_flag = RAISED_STACKOVERFLOW;
|
ec->raised_flag = RAISED_STACKOVERFLOW;
|
||||||
if (setup) {
|
if (setup) {
|
||||||
VALUE at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
|
VALUE at = rb_ec_backtrace_object(ec);
|
||||||
mesg = ruby_vm_special_exception_copy(mesg);
|
mesg = ruby_vm_special_exception_copy(mesg);
|
||||||
rb_ivar_set(mesg, idBt, at);
|
rb_ivar_set(mesg, idBt, at);
|
||||||
rb_ivar_set(mesg, idBt_locations, at);
|
rb_ivar_set(mesg, idBt_locations, at);
|
||||||
|
|
Loading…
Add table
Reference in a new issue