ruby-changes:49307
From: ko1 <ko1@a...>
Date: Sat, 23 Dec 2017 20:00:53 +0900 (JST)
Subject: [ruby-changes:49307] ko1:r61424 (trunk): revert line number spec of *return events.
ko1 2017-12-23 20:00:48 +0900 (Sat, 23 Dec 2017) New Revision: 61424 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61424 Log: revert line number spec of *return events. * compile.c (rb_iseq_compile_node): line number spec of :return, :b_return and :end events of 'TracePoint` is changed for [Feature #14104]. Quoted from [Feature #14104]: > Line numbers on :return/:b_return events show the last executed lines, > instead of end lines (without return statement). Note that :end event also affected. However, "buybug", a well-known ruby debugger depends on previous behavior so that I reverted this specification. * test/ruby/test_settracefunc.rb: catch up this fix. Modified files: trunk/compile.c trunk/test/ruby/test_settracefunc.rb Index: compile.c =================================================================== --- compile.c (revision 61423) +++ compile.c (revision 61424) @@ -646,6 +646,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, co https://github.com/ruby/ruby/blob/trunk/compile.c#L646 CHECK(COMPILE(ret, "block body", node->nd_body)); ADD_LABEL(ret, end); ADD_TRACE(ret, RUBY_EVENT_B_RETURN); + ISEQ_COMPILE_DATA(iseq)->last_line = iseq->body->location.code_range.last_loc.lineno; /* wide range catch handler must put at last */ ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, NULL, start); @@ -657,6 +658,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, co https://github.com/ruby/ruby/blob/trunk/compile.c#L658 ADD_TRACE(ret, RUBY_EVENT_CLASS); CHECK(COMPILE(ret, "scoped node", node->nd_body)); ADD_TRACE(ret, RUBY_EVENT_END); + ISEQ_COMPILE_DATA(iseq)->last_line = nd_line(node); break; } case ISEQ_TYPE_METHOD: @@ -664,6 +666,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, co https://github.com/ruby/ruby/blob/trunk/compile.c#L666 ADD_TRACE(ret, RUBY_EVENT_CALL); CHECK(COMPILE(ret, "scoped node", node->nd_body)); ADD_TRACE(ret, RUBY_EVENT_RETURN); + ISEQ_COMPILE_DATA(iseq)->last_line = nd_line(node); break; } default: { Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 61423) +++ test/ruby/test_settracefunc.rb (revision 61424) @@ -77,7 +77,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L77 events.shift) assert_equal(["c-return", 5, :+, Integer], events.shift) - assert_equal(["return", 5, :add, self.class], + assert_equal(["return", 6, :add, self.class], events.shift) assert_equal(["line", 8, __method__, self.class], events.shift) @@ -116,7 +116,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L116 events.shift) assert_equal(["c-return", 5, :method_added, Module], events.shift) - assert_equal(["end", 5, nil, nil], + assert_equal(["end", 7, nil, nil], events.shift) assert_equal(["line", 8, __method__, self.class], events.shift) @@ -130,7 +130,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L130 events.shift) assert_equal(["call", 5, :bar, Foo], events.shift) - assert_equal(["return", 5, :bar, Foo], + assert_equal(["return", 6, :bar, Foo], events.shift) assert_equal(["line", 9, __method__, self.class], events.shift) @@ -176,7 +176,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L176 events.shift) assert_equal(["line", 5, :meth_return, self.class], events.shift) - assert_equal(["return", 5, :meth_return, self.class], + assert_equal(["return", 7, :meth_return, self.class], events.shift) assert_equal(["line", 10, :test_return, self.class], events.shift) @@ -215,7 +215,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L215 events.shift) assert_equal(["line", 6, :meth_return2, self.class], events.shift) - assert_equal(["return", 6, :meth_return2, self.class], + assert_equal(["return", 7, :meth_return2, self.class], events.shift) assert_equal(["line", 9, :test_return2, self.class], events.shift) @@ -343,7 +343,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L343 ["line", 4, nil, nil], ["c-call", 4, :method_added, Module], ["c-return", 4, :method_added, Module], - ["end", 4, nil, nil], + ["end", 7, nil, nil], ["line", 8, __method__, self.class], ["c-call", 8, :new, Class], ["c-call", 8, :initialize, BasicObject], @@ -353,7 +353,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L353 ["line", 5, :foo, ThreadTraceInnerClass], ["c-call", 5, :+, Integer], ["c-return", 5, :+, Integer], - ["return", 5, :foo, ThreadTraceInnerClass], + ["return", 6, :foo, ThreadTraceInnerClass], ["line", 9, __method__, self.class], ["c-call", 9, :set_trace_func, Thread]].each do |e| [:set, :add].each do |type| @@ -487,7 +487,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L487 [:line, 13, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing], [:c_call, 13, "xyzzy", Module, :method_added, xyzzy.class, :XYZZY_outer, :nothing], [:c_return,13, "xyzzy", Module, :method_added, xyzzy.class, :XYZZY_outer, nil], - [:end, 13, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing], + [:end, 17, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing], [:line, 18, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing], [:c_call, 18, "xyzzy", Class, :new, xyzzy.class, :outer, :nothing], [:c_call, 18, "xyzzy", BasicObject, :initialize, xyzzy, :outer, :nothing], @@ -502,8 +502,8 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L502 [:line, 15, "xyzzy", xyzzy.class, :bar, xyzzy, :XYZZY_bar, :nothing], [:c_call, 15, "xyzzy", Kernel, :tap, xyzzy, :XYZZY_bar, :nothing], [:c_return,15, "xyzzy", Kernel, :tap, xyzzy, :XYZZY_bar, xyzzy], - [:return, 15, "xyzzy", xyzzy.class, :bar, xyzzy, :XYZZY_bar, xyzzy], - [:return, 11, "xyzzy", xyzzy.class, :foo, xyzzy, :XYZZY_foo, xyzzy], + [:return, 16, "xyzzy", xyzzy.class, :bar, xyzzy, :XYZZY_bar, xyzzy], + [:return, 12, "xyzzy", xyzzy.class, :foo, xyzzy, :XYZZY_foo, xyzzy], [:line, 20, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing], [:c_call, 20, "xyzzy", Kernel, :raise, self, :outer, :nothing], [:c_call, 20, "xyzzy", Exception, :exception, RuntimeError, :outer, :nothing], @@ -1800,7 +1800,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1800 assert_equal ["line", base_line + 7], events[4] assert_equal ["line", base_line + 8], events[5] assert_equal ["call", base_line + -6], events[6] - assert_equal ["return", base_line + -6], events[7] + assert_equal ["return", base_line + -4], events[7] assert_equal ["line", base_line + 9], events[8] assert_equal nil, events[9] @@ -1835,7 +1835,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1835 assert_equal ["line", base_line + 32], events[1] assert_equal ["line", base_line + 33], events[2] assert_equal ["call", base_line + -6], events[3] - assert_equal ["return", base_line + -6], events[4] + assert_equal ["return", base_line + -4], events[4] assert_equal ["line", base_line + 34], events[5] assert_equal ["line", base_line + 35], events[6] assert_equal ["c-call", base_line + 35], events[7] # Thread.current -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/