Skip to content

Only localize TracePoint to thread if specified#9283

Merged
headius merged 1 commit intojruby:jruby-10.0from
headius:tracepoint_starts_global
Mar 3, 2026
Merged

Only localize TracePoint to thread if specified#9283
headius merged 1 commit intojruby:jruby-10.0from
headius:tracepoint_starts_global

Conversation

@headius
Copy link
Copy Markdown
Member

@headius headius commented Mar 3, 2026

TracePoint#enable takes three arguments:

  • target: a target scope in which to enable tracing. In CRuby, this must be convertable to an instruction sequence, presumably so the instructions can be modified to trigger the event hooks.
  • target_line: a specific line number within the target scope to trace, I presume. The documentation does not specifically discuss this parameter.
  • target_thread: the sole thread on which this TracePoint should be enabled. By default, it is enabled globally.

Our original code always initialized the TracePoint as being associated with the current thread at construction time, which caused it to only be triggered for events in that thread. This patch defers setting the trace thread until TracePoint#enable is called with a non-nil target_thread argument.

Note that this patch also allows passing the target and target_line arguments, but they are ignored and will warn if non-nil.

Fixes #8697

TracePoint#enable takes three arguments:

* target: a target scope in which to enable tracing. In CRuby, this
  must be convertable to an instruction sequence, presumably so
  the instructions can be modified to trigger the event hooks.
* target_line: a specific line number within the target scope to
  trace, I presume. The documentation does not specifically discuss
  this parameter.
* target_thread: the sole thread on which this TracePoint should
  be enabled. By default, it is enabled globally.

Our original code always initialized the TracePoint as being
associated with the current thread at construction time, which
caused it to only be triggered for events in that thread. This
patch defers setting the trace thread until TracePoint#enable is
called with a non-nil target_thread argument.

Note that this patch also allows passing the target and target_line
arguments, but they are ignored and will warn if non-nil.

Fixes jruby#8697
@headius headius added this to the JRuby 10.0.4.0 milestone Mar 3, 2026
@headius headius merged commit 68c52f9 into jruby:jruby-10.0 Mar 3, 2026
79 checks passed
@headius headius deleted the tracepoint_starts_global branch March 3, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant