summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-18 11:24:36 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-18 11:24:36 +0000
commit9f8d00ff9aa85d097def654494b16c2ce09d8e92 (patch)
tree0fcc61192c6ddd51daed139482b9761c4d4f69bc
parentbc090868b8e480ac4d179bc6b7d2ba65d4f82aef (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@52640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--compile.c19
-rw-r--r--test/ruby/test_settracefunc.rb32
-rw-r--r--version.h2
4 files changed, 45 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index a037fbc367..34eec00cd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Nov 18 20:19:49 2015 Koichi Sasada <ko1@atdot.net>
+
+ * 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@atdot.net>
* vm.c (hook_before_rewind): prevent kicking :return event while
diff --git a/compile.c b/compile.c
index c8ed314f1c..40319dc0a6 100644
--- a/compile.c
+++ b/compile.c
@@ -3264,16 +3264,23 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
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) {
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index ba9e618ea9..2e9caa3e8c 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -509,7 +509,6 @@ class TestSetTraceFunc < Test::Unit::TestCase
[: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::TestCase
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::TestCase
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}
diff --git a/version.h b/version.h
index a22c891591..f32d81db14 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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