Skip to content

Commit

Permalink
Primitive support for a rescue trace event
Browse files Browse the repository at this point in the history
Discussed in CRuby core developer meeting May 10, 2023 at
RubyKaigi.

Experimental, do not merge until semantics are worked out in CRuby
(and until we actually populate the rest of TracePoint with file
and line etc).
  • Loading branch information
headius committed Jan 17, 2024
1 parent b96df9a commit 20d81eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ public static IRubyObject isExceptionHandled(ThreadContext context, IRubyObject
boolean ret = IRRuntimeHelpers.isRubyExceptionHandled(context, excType, excObj)
|| IRRuntimeHelpers.isJavaExceptionHandled(context, excType, excObj, false);

if (ret) {
context.runtime.getTraceEvents().callEventHooks(context, RubyEvent.RESCUE, "dummy", -1, "dummy", (IRubyObject) excObj);
}

return RubyBoolean.newBoolean(context, ret);
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/runtime/RubyEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public enum RubyEvent {
// A_CALL is CALL + B_CALL + C_CALL
A_CALL ("a_call"),
// A_RETURN is RETURN + B_RETURN + C_RETURN
A_RETURN ("a_return");
A_RETURN ("a_return"),
RESCUE ("rescue", false);

public static final Set<RubyEvent> ALL_EVENTS = Collections.synchronizedSet(EnumSet.allOf(RubyEvent.class));
public static final EnumSet ALL_EVENTS_ENUMSET = EnumSet.copyOf(RubyEvent.ALL_EVENTS);
Expand Down

0 comments on commit 20d81eb

Please sign in to comment.