ruby-changes:51058
From: tenderlove <ko1@a...>
Date: Fri, 27 Apr 2018 07:49:07 +0900 (JST)
Subject: [ruby-changes:51058] tenderlove:r63265 (trunk): Fix use of `rb_profile_frames` start parameter
tenderlove 2018-04-27 07:49:00 +0900 (Fri, 27 Apr 2018) New Revision: 63265 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63265 Log: Fix use of `rb_profile_frames` start parameter rb_profile_frames was always behaving as if the value given for the start parameter was 0. The reason for this was that it would check if (start > 0) { then continue without updating the control frame pointer or anything other than decrementing start. [ruby-core:86147] [Bug #14607] Co-authored-by: Dylan Thacker-Smith <Dylan.Smith@s...> Modified files: trunk/test/-ext-/debug/test_profile_frames.rb trunk/vm_backtrace.c Index: test/-ext-/debug/test_profile_frames.rb =================================================================== --- test/-ext-/debug/test_profile_frames.rb (revision 63264) +++ test/-ext-/debug/test_profile_frames.rb (revision 63265) @@ -119,4 +119,8 @@ class TestProfileFrames < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L119 a end; end + + def test_start + assert_equal Bug::Debug.profile_frames(0, 10).tap(&:shift), Bug::Debug.profile_frames(1, 9) + end end Index: vm_backtrace.c =================================================================== --- vm_backtrace.c (revision 63264) +++ vm_backtrace.c (revision 63265) @@ -1276,7 +1276,7 @@ rb_profile_frames(int start, int limit, https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1276 const rb_control_frame_t *cfp = ec->cfp, *end_cfp = RUBY_VM_END_CONTROL_FRAME(ec); const rb_callable_method_entry_t *cme; - for (i=0; i<limit && cfp != end_cfp;) { + for (i=0; i<limit && cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) { if (cfp->iseq && cfp->pc) { if (start > 0) { start--; @@ -1296,7 +1296,6 @@ rb_profile_frames(int start, int limit, https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1296 i++; } - cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } return i; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/