static void failInstrumentInitialization(Env env, String message, Throwable t) { Exception exception = new Exception(message, t); PrintStream stream = new PrintStream(env.err()); exception.printStackTrace(stream); }
static void failInstrumentInitialization(Env env, String message, Throwable t) { Exception exception = new Exception(message, t); PrintStream stream = new PrintStream(env.err()); exception.printStackTrace(stream); }
public SourceSection getInstrumentedSourceSection() { SourceSection ss = eventContext.getInstrumentedSourceSection(); if (ss == null) { Node node = eventContext.getInstrumentedNode(); // Nodes tagged with standard tags should have a source section attached. PrintStream err = new PrintStream(env.err()); err.print("WARNING: Instrumented node " + node + " of class " + node.getClass() + " has null SourceSection."); ss = node.getEncapsulatingSourceSection(); if (ss == null) { RootNode root = node.getRootNode(); err.print("WARNING: and null encapsulating SourceSection under " + root + " of class = " + root.getClass()); } err.flush(); } return ss; }
/** * Called to create the Instrument. * * @param env environment information for the instrument * @since 0.30 */ @Override protected void onCreate(Env env) { tracer = factory.create(env); if (env.getOptions().get(CPUTracerCLI.ENABLED)) { try { tracer.setFilter(getSourceSectionFilter(env)); } catch (IllegalArgumentException e) { new PrintStream(env.err()).println(ID + " error: " + e.getMessage()); env.getOptions().set(CPUTracerCLI.ENABLED, false); tracer.setCollecting(false); env.registerService(tracer); return; } tracer.setCollecting(true); } env.registerService(tracer); }
/** * 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; } final Object currentVm = AccessorInstrumentHandler.engineAccess().getCurrentVM(); if (b.getInstrumenter() instanceof EngineInstrumenter || (currentVm != null && AccessorInstrumentHandler.engineAccess().isInstrumentExceptionsAreThrown(currentVm))) { throw sthrow(RuntimeException.class, 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); }
/** * 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); }
/** * {@inheritDoc} * * @since 1.0 */ @Override public void printStackTrace() { printStackTrace(new PrintStream(session.getDebugger().getEnv().err())); }