зеркало из https://github.com/github/ruby.git
vm_backtrace.c: backtrace functions per threads
* vm_backtrace.c (rb_threadptr_backtrace_object): rename and extern. * vm_backtrace.c (rb_threadptr_backtrace_str_ary): rename as threadptr since the parameter is rb_thread_t*. * vm_backtrace.c (rb_threadptr_backtrace_location_ary): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a0219e2f51
Коммит
269421084e
4
eval.c
4
eval.c
|
@ -516,7 +516,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
VALUE at;
|
||||
if (sysstack_error_p(mesg)) {
|
||||
if (NIL_P(rb_attr_get(mesg, idBt))) {
|
||||
at = rb_vm_backtrace_object();
|
||||
at = rb_threadptr_backtrace_object(th);
|
||||
rb_ivar_set(mesg, idBt, at);
|
||||
rb_ivar_set(mesg, idBt_locations, at);
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
if (rb_threadptr_set_raised(th)) goto fatal;
|
||||
bt = rb_get_backtrace(mesg);
|
||||
if (NIL_P(bt)) {
|
||||
at = rb_vm_backtrace_object();
|
||||
at = rb_threadptr_backtrace_object(th);
|
||||
if (OBJ_FROZEN(mesg)) {
|
||||
mesg = rb_obj_dup(mesg);
|
||||
}
|
||||
|
|
|
@ -293,6 +293,11 @@ void rb_vm_set_progname(VALUE filename);
|
|||
void rb_thread_terminate_all(void);
|
||||
VALUE rb_vm_cbase(void);
|
||||
|
||||
/* vm_backtrace.c */
|
||||
VALUE rb_threadptr_backtrace_object(rb_thread_t *th);
|
||||
VALUE rb_threadptr_backtrace_str_ary(rb_thread_t *th, long lev, long n);
|
||||
VALUE rb_threadptr_backtrace_location_ary(rb_thread_t *th, long lev, long n);
|
||||
|
||||
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
|
||||
# ifdef HAVE_MBLEN
|
||||
# define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))
|
||||
|
|
|
@ -1749,7 +1749,6 @@ int rb_backtrace_p(VALUE obj);
|
|||
VALUE rb_backtrace_to_str_ary(VALUE obj);
|
||||
VALUE rb_backtrace_to_location_ary(VALUE obj);
|
||||
void rb_backtrace_print_to(VALUE output);
|
||||
VALUE rb_vm_backtrace_object(void);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
const char *rb_objspace_data_type_name(VALUE obj);
|
||||
|
|
3
thread.c
3
thread.c
|
@ -4935,7 +4935,6 @@ ruby_native_thread_p(void)
|
|||
return th != 0;
|
||||
}
|
||||
|
||||
VALUE rb_vm_backtrace_str_ary(rb_thread_t *th, long lev, long n);
|
||||
static void
|
||||
debug_deadlock_check(rb_vm_t *vm, VALUE msg)
|
||||
{
|
||||
|
@ -4968,7 +4967,7 @@ debug_deadlock_check(rb_vm_t *vm, VALUE msg)
|
|||
}
|
||||
}
|
||||
rb_str_catf(msg, "\n ");
|
||||
rb_str_concat(msg, rb_ary_join(rb_vm_backtrace_str_ary(th, 0, 0), sep));
|
||||
rb_str_concat(msg, rb_ary_join(rb_threadptr_backtrace_str_ary(th, 0, 0), sep));
|
||||
rb_str_catf(msg, "\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -706,11 +706,11 @@ raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc)
|
|||
vm_push_frame(th, iseq, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL, Qnil /* self */,
|
||||
VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */,
|
||||
iseq->body->iseq_encoded, th->cfp->sp, 0, 0 /* stack_max */);
|
||||
at = rb_vm_backtrace_object();
|
||||
at = rb_threadptr_backtrace_object(th);
|
||||
rb_vm_pop_frame(th);
|
||||
}
|
||||
else {
|
||||
at = rb_vm_backtrace_object();
|
||||
at = rb_threadptr_backtrace_object(th);
|
||||
}
|
||||
|
||||
rb_ivar_set(exc, idBt_locations, at);
|
||||
|
|
|
@ -511,8 +511,8 @@ bt_iter_cfunc(void *ptr, const rb_control_frame_t *cfp, ID mid)
|
|||
loc->body.cfunc.prev_loc = arg->prev_loc;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
backtrace_object(rb_thread_t *th)
|
||||
VALUE
|
||||
rb_threadptr_backtrace_object(rb_thread_t *th)
|
||||
{
|
||||
struct bt_iter_arg arg;
|
||||
arg.prev_loc = 0;
|
||||
|
@ -526,12 +526,6 @@ backtrace_object(rb_thread_t *th)
|
|||
return arg.btobj;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_vm_backtrace_object(void)
|
||||
{
|
||||
return backtrace_object(GET_THREAD());
|
||||
}
|
||||
|
||||
static VALUE
|
||||
backtrace_collect(rb_backtrace_t *bt, long lev, long n, VALUE (*func)(rb_backtrace_location_t *, void *arg), void *arg)
|
||||
{
|
||||
|
@ -656,15 +650,15 @@ backtrace_load_data(VALUE self, VALUE str)
|
|||
}
|
||||
|
||||
VALUE
|
||||
rb_vm_backtrace_str_ary(rb_thread_t *th, long lev, long n)
|
||||
rb_threadptr_backtrace_str_ary(rb_thread_t *th, long lev, long n)
|
||||
{
|
||||
return backtrace_to_str_ary(backtrace_object(th), lev, n);
|
||||
return backtrace_to_str_ary(rb_threadptr_backtrace_object(th), lev, n);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_vm_backtrace_location_ary(rb_thread_t *th, long lev, long n)
|
||||
rb_threadptr_backtrace_location_ary(rb_thread_t *th, long lev, long n)
|
||||
{
|
||||
return backtrace_to_location_ary(backtrace_object(th), lev, n);
|
||||
return backtrace_to_location_ary(rb_threadptr_backtrace_object(th), lev, n);
|
||||
}
|
||||
|
||||
/* make old style backtrace directly */
|
||||
|
@ -810,15 +804,15 @@ rb_backtrace_print_to(VALUE output)
|
|||
VALUE
|
||||
rb_make_backtrace(void)
|
||||
{
|
||||
return rb_vm_backtrace_str_ary(GET_THREAD(), 0, 0);
|
||||
return rb_threadptr_backtrace_str_ary(GET_THREAD(), 0, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
vm_backtrace_to_ary(rb_thread_t *th, int argc, const VALUE *argv, int lev_default, int lev_plus, int to_str)
|
||||
threadptr_backtrace_to_ary(rb_thread_t *th, int argc, const VALUE *argv, int lev_default, int lev_plus, int to_str)
|
||||
{
|
||||
VALUE level, vn;
|
||||
long lev, n;
|
||||
VALUE btval = backtrace_object(th);
|
||||
VALUE btval = rb_threadptr_backtrace_object(th);
|
||||
VALUE r;
|
||||
rb_backtrace_t *bt;
|
||||
|
||||
|
@ -893,7 +887,7 @@ thread_backtrace_to_ary(int argc, const VALUE *argv, VALUE thval, int to_str)
|
|||
if (th->to_kill || th->status == THREAD_KILLED)
|
||||
return Qnil;
|
||||
|
||||
return vm_backtrace_to_ary(th, argc, argv, 0, 0, to_str);
|
||||
return threadptr_backtrace_to_ary(th, argc, argv, 0, 0, to_str);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -949,7 +943,7 @@ rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
|
|||
static VALUE
|
||||
rb_f_caller(int argc, VALUE *argv)
|
||||
{
|
||||
return vm_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 1);
|
||||
return threadptr_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -977,7 +971,7 @@ rb_f_caller(int argc, VALUE *argv)
|
|||
static VALUE
|
||||
rb_f_caller_locations(int argc, VALUE *argv)
|
||||
{
|
||||
return vm_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 0);
|
||||
return threadptr_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 0);
|
||||
}
|
||||
|
||||
/* called from Init_vm() in vm.c */
|
||||
|
@ -1177,7 +1171,7 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
|
|||
|
||||
dbg_context.th = th;
|
||||
dbg_context.cfp = dbg_context.th->cfp;
|
||||
dbg_context.backtrace = rb_vm_backtrace_location_ary(th, 0, 0);
|
||||
dbg_context.backtrace = rb_threadptr_backtrace_location_ary(th, 0, 0);
|
||||
dbg_context.backtrace_size = RARRAY_LEN(dbg_context.backtrace);
|
||||
dbg_context.contexts = collect_caller_bindings(th);
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ static VALUE rb_eUncaughtThrow;
|
|||
static ID id_result, id_tag, id_value;
|
||||
#define id_mesg idMesg
|
||||
|
||||
/* vm_backtrace.c */
|
||||
VALUE rb_vm_backtrace_str_ary(rb_thread_t *th, int lev, int n);
|
||||
|
||||
typedef enum call_type {
|
||||
CALL_PUBLIC,
|
||||
CALL_FCALL,
|
||||
|
@ -1269,7 +1266,7 @@ adjust_backtrace_in_eval(rb_thread_t *th, VALUE errinfo)
|
|||
VALUE errat = rb_get_backtrace(errinfo);
|
||||
VALUE mesg = rb_attr_get(errinfo, id_mesg);
|
||||
if (RB_TYPE_P(errat, T_ARRAY)) {
|
||||
VALUE bt2 = rb_vm_backtrace_str_ary(th, 0, 0);
|
||||
VALUE bt2 = rb_threadptr_backtrace_str_ary(th, 0, 0);
|
||||
if (RARRAY_LEN(bt2) > 0) {
|
||||
if (RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) {
|
||||
rb_ivar_set(errinfo, id_mesg, RARRAY_AREF(errat, 0));
|
||||
|
|
Загрузка…
Ссылка в новой задаче