This is more backwards compatible, and should fix issues with
power_assert.
Unfortunately, it requires using a sentinel value as the default
value of target_thread, instead of the more natural expression
used in the original approach.
If TracePoint#enable is passed a block, it previously started
the trace on all threads. This changes it to trace only the
current thread by default. To limit the scope of the change,
the current thread is only used by default if target and
target_line are both nil. You can pass target_thread: nil
to enable tracing on all threads, to get the previous
default behavior.
Fixes [Bug #16889]
In general, while TracePoint callback is running,
other registerred callbacks are not called to avoid
confusion by reentrace.
This method allow the reentrace. This method should be
used carefully, otherwize the callback can be easily called
infinitely.
[Feature #15912]
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
"code" here is too ambiguous. TracePoint events only occur if there
is a new statement or expression on that line, not if the line
is a continuation of a previous statement or expression and there
is no new statement or expression on the line.
For example:
```
[
foo, # start of expression, line event
bar # continuation of expression, no line event
]
[
foo, # start of expression, line event
(bar) # new expression, line event
]
foo( # start of expression, line event
bar # continuation of expression, no line event
)
foo( # start of expression, line event
(bar) # new expression, line event
)
```
Fixes [Bug #15634]
* Fix debug documents to match Thread#to_s change (Feature #16412 ticket)
* TracePoint#inspect returns "... file:line" (Feature #16513)
* Guard older version of Ruby in Tracepoint inspection tests
* Focus on current thread only when running TracePoint inspection test