Bug #17302
closedThe TracePoint API does not allow setting multiple line traces within the same method (ISEQ)
Description
While setting a tracepoint for a line for the second time within a method, the first one turns off.
I believe this is because the encoded_iseq_trace_instrument
function resets the trace value of an instruction rather than just turning it on if needed: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3178
And it is unconditionally called, not limited to the correct line: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3219
Files
Updated by liran.last@gmail.com (Liran Haimovitch) over 3 years ago
- File my_test.rb my_test.rb added
liran.last@gmail.com (Liran Haimovitch) wrote:
When setting a second line tracepoint within a method the first one will be turned off.
I believe this is due to the fact that the encoded_iseq_trace_instrument function resets the trace value of an instruction rather then just turn it on if needed - https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3178
And it is unconditionally called, not limited to the correct line: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3219
Attaching a short file to reproduce the bug, based on the existing enable_spec.rb
in the Ruby repo.
Updated by liran.last@gmail.com (Liran Haimovitch) over 3 years ago
liran.last@gmail.com (Liran Haimovitch) wrote in #note-1:
liran.last@gmail.com (Liran Haimovitch) wrote:
When setting a second line tracepoint within a method the first one will be turned off.
I believe this is due to the fact that the encoded_iseq_trace_instrument function resets the trace value of an instruction rather then just turn it on if needed - https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3178
And it is unconditionally called, not limited to the correct line: https://github.com/ruby/ruby/blob/799253dc46e96518687dcd4fdca42582251ccffe/iseq.c#L3219
Attaching a short file to reproduce the bug, based on the existing
enable_spec.rb
in the Ruby repo.
After some additional investigation, it seems that when adding multiple breakpoints to the same method (ISEQ) only the last one will apply. BUT, if I disable even one of them, all the breakpoints that are left enabled will work simultaneously.
Updated by ko1 (Koichi Sasada) over 3 years ago
- Status changed from Open to Closed
Applied in changeset git|084e7e31b257f6ac859769553b4c1c6ca2930152.
remain enabled and line specified trace points
If two or more tracepoints enabled with the same target and with
different target lines, the only last line is activated.
This patch fixes this issue by remaining existing trace instructions.
[Bug #17302]
Updated by Eregon (Benoit Daloze) about 2 years ago
- Related to Bug #18646: Inconsistent behavior for the targeted TracePoints in ruby 2.6-2.7 and 3+ added
Updated by Eregon (Benoit Daloze) about 2 years ago
- Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN to 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONTNEED, 3.1: DONTNEED
Updated by Eregon (Benoit Daloze) about 2 years ago
Backport was requested in https://bugs.ruby-lang.org/issues/18646, and I adjusted the Backport field for it.