ruby-changes:26076
From: ko1 <ko1@a...>
Date: Sun, 2 Dec 2012 05:08:13 +0900 (JST)
Subject: [ruby-changes:26076] ko1:r38133 (trunk): * iseq.c (rb_iseq_line_trace_each): iterate `line' event only.
ko1 2012-12-02 05:07:58 +0900 (Sun, 02 Dec 2012) New Revision: 38133 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38133 Log: * iseq.c (rb_iseq_line_trace_each): iterate `line' event only. * test/ruby/test_iseq.rb: add a test for this change. Modified files: trunk/ChangeLog trunk/iseq.c trunk/test/ruby/test_iseq.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38132) +++ ChangeLog (revision 38133) @@ -1,3 +1,9 @@ +Sun Dec 2 05:01:58 2012 Koichi Sasada <ko1@a...> + + * iseq.c (rb_iseq_line_trace_each): iterate `line' event only. + + * test/ruby/test_iseq.rb: add a test for this change. + Sun Dec 2 02:46:04 2012 Koichi Sasada <ko1@a...> * vm_trace.c: add TracePoint#inspect. Index: iseq.c =================================================================== --- iseq.c (revision 38132) +++ iseq.c (revision 38133) @@ -1954,15 +1954,19 @@ if (insn == BIN(trace)) { rb_event_flag_t current_events = (VALUE)iseq->iseq[pos+1]; - rb_event_flag_t events = current_events & RUBY_EVENT_SPECIFIED_LINE; - trace_num++; - if (func) { - int line = find_line_no(iseq, pos); - /* printf("line: %d\n", line); */ - cont = (*func)(line, &events, data); - if (current_events != events) { - iseq->iseq[pos+1] = iseq->iseq_encoded[pos+1] = (VALUE)(current_events | (events & RUBY_EVENT_SPECIFIED_LINE)); + if (current_events & RUBY_EVENT_LINE) { + rb_event_flag_t events = current_events & RUBY_EVENT_SPECIFIED_LINE; + trace_num++; + + if (func) { + int line = find_line_no(iseq, pos); + /* printf("line: %d\n", line); */ + cont = (*func)(line, &events, data); + if (current_events != events) { + iseq->iseq[pos+1] = iseq->iseq_encoded[pos+1] = + (VALUE)(current_events | (events & RUBY_EVENT_SPECIFIED_LINE)); + } } } } Index: test/ruby/test_iseq.rb =================================================================== --- test/ruby/test_iseq.rb (revision 38132) +++ test/ruby/test_iseq.rb (revision 38133) @@ -26,6 +26,15 @@ Encoding.default_internal = enc end + LINE_BEFORE_METHOD = __LINE__ + def method_test_line_trace + + a = 1 + + b = 2 + + end + def test_line_trace iseq = ISeq.compile \ %q{ a = 1 @@ -48,6 +57,9 @@ iseq.eval } assert_equal([2, 5], result) + + iseq = ISeq.of(self.class.instance_method(:method_test_line_trace)) + assert_equal([LINE_BEFORE_METHOD + 3, LINE_BEFORE_METHOD + 5], iseq.line_trace_all) end LINE_OF_HERE = __LINE__ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/