Project

General

Profile

Bug #10449

[TracePoint API] Duplicated line events when using parenthesis

Added by deivid (David Rodríguez) almost 5 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.4p265 (2014-10-27 revision 48166) [i686-linux]
[ruby-core:65995]

Description

Sometimes, when using parenthesis, I get duplicated lines events from the TracePoint API. See the failing test case, it generates 2 line events where I think it should generate just one.

def test_no_duplicate_line_events
  events = []
  TracePoint.new(:line) { |tp| events << tp.event }.enable { a = (1) * 5 }

  assert_equal [:line], events
end

Thanks!!


Related issues

Related to Backport21 - Backport #11651: Please backport r48609ClosedActions

Associated revisions

Revision ea290804
Added by ko1 (Koichi Sasada) almost 5 years ago

  • 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/trunk@48609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 48609
Added by ko1 (Koichi Sasada) almost 5 years ago

  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Revision 48609
Added by ko1 (Koichi Sasada) almost 5 years ago

  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Revision 48609
Added by ko1 (Koichi Sasada) almost 5 years ago

  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Revision 48609
Added by ko1 (Koichi Sasada) almost 5 years ago

  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Revision 48609
Added by ko1 (Koichi Sasada) almost 5 years ago

  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Revision 48609
Added by ko1 (Koichi Sasada) almost 5 years ago

  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Revision 9f8d00ff
Added by usa (Usaku NAKAMURA) almost 4 years ago

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

Revision 52640
Added by usa (Usaku NAKAMURA) almost 4 years ago

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.

History

Updated by ko1 (Koichi Sasada) almost 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r48609.


  • compile.c (iseq_compile_each): remove duplicated line event. [Bug #10449]
  • test/ruby/test_settracefunc.rb: add and fix tests.

Updated by deivid (David Rodríguez) almost 5 years ago

Hi Koichi, I've looked at the patch and it seems to me that every duplicated event has been removed. So if I do something like

object.method1.method2.method3

only one line event will be generated. Is this the case?

If that's the case I actually preferred the previous behaviour so it is possible to inspect intermediate results. byebug is aware of this duplication and even provides an option that ignores duplicated events in case the user wants to always change line when stepping through the code.

I just reported this specific case cause I couldn't recognize the "separate line events" but in general I think the behaviour was fine.

Updated by deivid (David Rodríguez) almost 5 years ago

Confirmed, this commit breaks some tests in Byebug, I think it should be reverted.

Updated by deivid (David Rodríguez) almost 5 years ago

Actually I've given this a second thought and I'm fine with the change. The funcionality loss is minimal (and easy to do it in other ways), the patch corrects issues like this one and the code using the API will be simpler as it will not need to handle the duplication.

So basically, I'm fine with anything. :)

Updated by ko1 (Koichi Sasada) almost 5 years ago

Hi Koichi, I've looked at the patch and it seems to me that every duplicated event has been removed. So if I do something like

object.method1.method2.method3

only one line event will be generated. Is this the case?

Before this fix, only 1 line event (for the method chain line) is generated, isn't?

     1  obj = Object.new
     2  def obj.method_missing *args
     3    p args
     4    self
     5  end
     6
     7  TracePoint.new(:line){|tp|
     8    p [tp.event, tp.lineno]
     9  }.enable{
    10    obj.method1.method2.method3 # method chain line
    11  }

#=>
ruby 2.1.4p261 (2014-10-19 revision 48004) [x86_64-linux]
[:line, 10] #<-- this line
[:line, 3]
[:method1]
[:line, 4]
[:line, 3]
[:method2]
[:line, 4]
[:line, 3]
[:method3]
[:line, 4]

Updated by deivid (David Rodríguez) almost 5 years ago

Oops, I need to start thinking before talking... :) The change in the behaviour actually happened in this example so something like the following used to generate 2 line events before the change.

TracePoint.new(:line){|tp|
  p [tp.event, tp.lineno]
}.enable{
  num = 1 ; num += 1
}

Using semicolon is the only case I found when this happened (other that this issue), and it's not a very popular style anyways.

So definitely up for keeping this fix. Could we get this backported to 2.0 and 2.1?

THANKS!

Updated by usa (Usaku NAKAMURA) almost 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: DONTNEED
#8

Updated by usa (Usaku NAKAMURA) almost 4 years ago

Updated by usa (Usaku NAKAMURA) almost 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: DONTNEED to 2.0.0: UNKNOWN, 2.1: DONE, 2.2: DONTNEED

ruby_2_1 r52640 merged revision(s) 48609.

Also available in: Atom PDF