Search in sources :

Example 1 with InstrumentClientInstrumenter

use of com.oracle.truffle.api.instrumentation.InstrumentationHandler.InstrumentClientInstrumenter in project graal by oracle.

the class ProbeNode method exceptionEventForClientInstrument.

/**
 * Handles exceptions from non-language instrumentation code that must not be allowed to alter
 * guest language execution semantics. Normal response is to log and continue.
 */
@TruffleBoundary
static void exceptionEventForClientInstrument(EventBinding.Source<?> b, String eventName, Throwable t) {
    assert !b.isLanguageBinding();
    if (t instanceof ThreadDeath) {
        // Terminates guest language execution immediately
        throw (ThreadDeath) t;
    }
    // Exception is a failure in (non-language) instrumentation code; log and continue
    InstrumentClientInstrumenter instrumenter = (InstrumentClientInstrumenter) b.getInstrumenter();
    Class<?> instrumentClass = instrumenter.getInstrumentClass();
    String message = // 
    String.format(// 
    "Event %s failed for instrument class %s and listener/factory %s.", eventName, instrumentClass.getName(), b.getElement());
    Exception exception = new Exception(message, t);
    PrintStream stream = new PrintStream(instrumenter.getEnv().err());
    exception.printStackTrace(stream);
}
Also used : PrintStream(java.io.PrintStream) InstrumentClientInstrumenter(com.oracle.truffle.api.instrumentation.InstrumentationHandler.InstrumentClientInstrumenter) NoSuchElementException(java.util.NoSuchElementException) FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Aggregations

TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)1 InstrumentClientInstrumenter (com.oracle.truffle.api.instrumentation.InstrumentationHandler.InstrumentClientInstrumenter)1 PrintStream (java.io.PrintStream)1 NoSuchElementException (java.util.NoSuchElementException)1