ruby-changes:46260
From: nobu <ko1@a...>
Date: Mon, 17 Apr 2017 10:23:55 +0900 (JST)
Subject: [ruby-changes:46260] nobu:r58377 (trunk): vm_backtrace.c: backtrace functions per threads
nobu 2017-04-17 10:23:50 +0900 (Mon, 17 Apr 2017) New Revision: 58377 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58377 Log: 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. Modified files: trunk/eval.c trunk/eval_intern.h trunk/internal.h trunk/thread.c trunk/vm_args.c trunk/vm_backtrace.c trunk/vm_eval.c Index: vm_backtrace.c =================================================================== --- vm_backtrace.c (revision 58376) +++ vm_backtrace.c (revision 58377) @@ -511,8 +511,8 @@ bt_iter_cfunc(void *ptr, const rb_contro https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L511 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) https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L526 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 st https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L650 } 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) https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L804 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 https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L887 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 arg https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L943 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) https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L971 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_inspect https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1171 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); Index: eval.c =================================================================== --- eval.c (revision 58376) +++ eval.c (revision 58377) @@ -516,7 +516,7 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L516 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 https://github.com/ruby/ruby/blob/trunk/eval.c#L530 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); } Index: internal.h =================================================================== --- internal.h (revision 58376) +++ internal.h (revision 58377) @@ -1749,7 +1749,6 @@ int rb_backtrace_p(VALUE obj); https://github.com/ruby/ruby/blob/trunk/internal.h#L1749 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); Index: vm_args.c =================================================================== --- vm_args.c (revision 58376) +++ vm_args.c (revision 58377) @@ -706,11 +706,11 @@ raise_argument_error(rb_thread_t *th, co https://github.com/ruby/ruby/blob/trunk/vm_args.c#L706 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); Index: eval_intern.h =================================================================== --- eval_intern.h (revision 58376) +++ eval_intern.h (revision 58377) @@ -293,6 +293,11 @@ void rb_vm_set_progname(VALUE filename); https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L293 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)) Index: vm_eval.c =================================================================== --- vm_eval.c (revision 58376) +++ vm_eval.c (revision 58377) @@ -28,9 +28,6 @@ static VALUE rb_eUncaughtThrow; https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L28 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 https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1266 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)); Index: thread.c =================================================================== --- thread.c (revision 58376) +++ thread.c (revision 58377) @@ -4935,7 +4935,6 @@ ruby_native_thread_p(void) https://github.com/ruby/ruby/blob/trunk/thread.c#L4935 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 https://github.com/ruby/ruby/blob/trunk/thread.c#L4967 } } 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"); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/