ruby-changes:40561
From: usa <ko1@a...>
Date: Wed, 18 Nov 2015 20:24:46 +0900 (JST)
Subject: [ruby-changes:40561] usa:r52640 (ruby_2_1): merge revision(s) 48609: [Backport #10449] [Backport #11651]
usa 2015-11-18 20:24:36 +0900 (Wed, 18 Nov 2015) New Revision: 52640 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52640 Log: merge revision(s) 48609: [Backport #10449] [Backport #11651] * compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449] * test/ruby/test_settracefunc.rb: add and fix tests. Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/compile.c branches/ruby_2_1/test/ruby/test_settracefunc.rb branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 52639) +++ ruby_2_1/ChangeLog (revision 52640) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Wed Nov 18 20:19:49 2015 Koichi Sasada <ko1@a...> + + * compile.c (iseq_compile_each): remove duplicated line event. + [Bug #10449] + + * test/ruby/test_settracefunc.rb: add and fix tests. + Wed Nov 18 20:14:38 2015 Koichi Sasada <ko1@a...> * vm.c (hook_before_rewind): prevent kicking :return event while Index: ruby_2_1/compile.c =================================================================== --- ruby_2_1/compile.c (revision 52639) +++ ruby_2_1/compile.c (revision 52640) @@ -3264,16 +3264,23 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/compile.c#L3264 return COMPILE_OK; } - iseq->compile_data->last_line = line = (int)nd_line(node); + line = (int)nd_line(node); + + if (iseq->compile_data->last_line == line) { + /* ignore */ + } + else { + if (node->flags & NODE_FL_NEWLINE) { + iseq->compile_data->last_line = line; + ADD_TRACE(ret, line, RUBY_EVENT_LINE); + saved_last_element = ret->last; + } + } + debug_node_start(node); type = nd_type(node); - if (node->flags & NODE_FL_NEWLINE) { - ADD_TRACE(ret, line, RUBY_EVENT_LINE); - saved_last_element = ret->last; - } - switch (type) { case NODE_BLOCK:{ while (node && nd_type(node) == NODE_BLOCK) { Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 52639) +++ ruby_2_1/version.h (revision 52640) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.8" #define RUBY_RELEASE_DATE "2015-11-18" -#define RUBY_PATCHLEVEL 415 +#define RUBY_PATCHLEVEL 416 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 11 Index: ruby_2_1/test/ruby/test_settracefunc.rb =================================================================== --- ruby_2_1/test/ruby/test_settracefunc.rb (revision 52639) +++ ruby_2_1/test/ruby/test_settracefunc.rb (revision 52640) @@ -509,7 +509,6 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L509 [: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], - [: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], [:c_call, 20, "xyzzy", Exception, :initialize, raised_exc, :outer, :nothing], @@ -565,14 +564,17 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L564 def test_tracepoint events1, answer_events = *trace_by_tracepoint(:line, :class, :end, :call, :return, :c_call, :c_return, :raise) - mesg = events1.map{|e| - if false - p [:event, e[0]] - p [:line_file, e[1], e[2]] - p [:id, e[4]] + ms = [events1, answer_events].map{|evs| + evs.map{|e| + "#{e[0]} - #{e[2]}:#{e[1]} id; #{e[4]}" + } + } + + mesg = ms[0].zip(ms[1]).map{|a, b| + if a != b + "#{a} <-> #{b}" end - "#{e[0]} - #{e[2]}:#{e[1]} id: #{e[4]}" - }.join("\n") + }.compact.join("\n") answer_events.zip(events1){|answer, event| assert_equal answer, event, mesg } @@ -1417,6 +1419,20 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L1419 end end + def test_no_duplicate_line_events + lines = [] + dummy = [] + + TracePoint.new(:line){|tp| + next unless target_thread? + lines << tp.lineno + }.enable{ + dummy << (1) + (2) + dummy << (1) + (2) + } + assert_equal [__LINE__ - 3, __LINE__ - 2], lines, 'Bug #10449' + end + class Bug10724 def initialize loop{return} Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r48609 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/