static void handleOutput(TruffleInstrument.Env env, MemoryTracer tracer) { PrintStream out = new PrintStream(env.out()); if (tracer.hasStackOverflowed()) { out.println("-------------------------------------------------------------------------------- "); out.println("ERROR: Shadow stack has overflowed its capacity of " + env.getOptions().get(STACK_LIMIT) + " during execution!"); out.println("The gathered data is incomplete and incorrect!"); out.println("Use --" + MemoryTracerInstrument.ID + ".StackLimit=<" + STACK_LIMIT.getType().getName() + "> to set stack capacity."); out.println("-------------------------------------------------------------------------------- "); return; } switch (env.getOptions().get(OUTPUT)) { case TYPE_HISTOGRAM: printMetaObjectHistogram(out, tracer); break; case LOCATION_HISTOGRAM: printLocationHistogram(out, tracer); break; case CALLTREE: printCallTree(out, tracer); break; } }
static void handleOutput(TruffleInstrument.Env env, CPUSampler sampler) { PrintStream out = new PrintStream(env.out()); if (sampler.hasStackOverflowed()) { out.println("-------------------------------------------------------------------------------- "); out.println("ERROR: Shadow stack has overflowed its capacity of " + env.getOptions().get(STACK_LIMIT) + " during execution!"); out.println("The gathered data is incomplete and incorrect!"); out.println("Use --" + CPUSamplerInstrument.ID + ".StackLimit=<" + STACK_LIMIT.getType().getName() + "> to set stack capacity."); out.println("-------------------------------------------------------------------------------- "); return; } Boolean summariseThreads = env.getOptions().get(SUMMARISE_THREADS); switch (env.getOptions().get(OUTPUT)) { case HISTOGRAM: printSamplingHistogram(out, sampler, summariseThreads); break; case CALLTREE: printSamplingCallTree(out, sampler, summariseThreads); break; case JSON: printSamplingJson(out, sampler); } }
public static void handleOutput(TruffleInstrument.Env env, CPUTracer tracer) { PrintStream out = new PrintStream(env.out()); switch (env.getOptions().get(OUTPUT)) { case HISTOGRAM: printTracerHistogram(out, tracer); break; case JSON: printTracerJson(out, tracer); break; } }
/** * 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); }
/** * Called to create the Instrument. * * @param env environment information for the instrument * @since 0.30 */ @Override protected void onCreate(Env env) { sampler = factory.create(env); if (env.getOptions().get(CPUSamplerCLI.ENABLED)) { sampler.setPeriod(env.getOptions().get(CPUSamplerCLI.SAMPLE_PERIOD)); sampler.setDelay(env.getOptions().get(CPUSamplerCLI.DELAY_PERIOD)); sampler.setStackLimit(env.getOptions().get(CPUSamplerCLI.STACK_LIMIT)); sampler.setFilter(getSourceSectionFilter(env)); sampler.setGatherSelfHitTimes(env.getOptions().get(GATHER_HIT_TIMES)); sampler.setMode(env.getOptions().get(CPUSamplerCLI.MODE)); sampler.setCollecting(true); } env.registerService(sampler); }
/** * 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(MemoryTracerCLI.ENABLED)) { tracer.setFilter(getSourceSectionFilter(env)); tracer.setStackLimit(env.getOptions().get(MemoryTracerCLI.STACK_LIMIT)); tracer.setCollecting(true); } env.registerService(tracer); }
/** * Called when the Instrument is to be disposed. * * @param env environment information for the instrument * @since 0.30 */ @Override protected void onDispose(Env env) { if (env.getOptions().get(MemoryTracerCLI.ENABLED)) { MemoryTracerCLI.handleOutput(env, tracer); } tracer.close(); } }
/** * Called to create the Instrument. * * @param env environment information for the instrument * @since 1.0 */ @Override protected void onCreate(TruffleInstrument.Env env) { monitor = factory.create(env); if (env.getOptions().get(HeapMonitorInstrument.ENABLED)) { monitor.setCollecting(true); } env.registerService(monitor); }
/** * Called when the Instrument is to be disposed. * * @param env environment information for the instrument * @since 0.30 */ @Override protected void onDispose(Env env) { if (env.getOptions().get(CPUSamplerCLI.ENABLED)) { CPUSamplerCLI.handleOutput(env, sampler); } sampler.close(); } }
/** * Called when the Instrument is to be disposed. * * @param env environment information for the instrument * @since 0.30 */ @Override protected void onDispose(Env env) { if (env.getOptions().get(CPUTracerCLI.ENABLED)) { CPUTracerCLI.handleOutput(env, tracer); tracer.close(); } } }
private static SourceSectionFilter getSourceSectionFilter(Env env) { final boolean roots = env.getOptions().get(CPUTracerCLI.TRACE_ROOTS); final boolean statements = env.getOptions().get(CPUTracerCLI.TRACE_STATEMENTS); final boolean calls = env.getOptions().get(CPUTracerCLI.TRACE_CALLS); final boolean internals = env.getOptions().get(CPUTracerCLI.TRACE_INTERNAL); final Object[] filterRootName = env.getOptions().get(CPUTracerCLI.FILTER_ROOT); final Object[] filterFile = env.getOptions().get(CPUTracerCLI.FILTER_FILE); final String filterLanguage = env.getOptions().get(CPUTracerCLI.FILTER_LANGUAGE); return CPUTracerCLI.buildFilter(roots, statements, calls, internals, filterRootName, filterFile, filterLanguage); }
private static SourceSectionFilter getSourceSectionFilter(Env env) { final CPUSampler.Mode mode = env.getOptions().get(CPUSamplerCLI.MODE); final boolean statements = mode == CPUSampler.Mode.STATEMENTS; final boolean internals = env.getOptions().get(CPUSamplerCLI.SAMPLE_INTERNAL); final Object[] filterRootName = env.getOptions().get(CPUSamplerCLI.FILTER_ROOT); final Object[] filterFile = env.getOptions().get(CPUSamplerCLI.FILTER_FILE); final String filterLanguage = env.getOptions().get(CPUSamplerCLI.FILTER_LANGUAGE); return CPUSamplerCLI.buildFilter(true, statements, false, internals, filterRootName, filterFile, filterLanguage); }
private static SourceSectionFilter getSourceSectionFilter(Env env) { final boolean roots = env.getOptions().get(MemoryTracerCLI.TRACE_ROOTS); final boolean statements = env.getOptions().get(MemoryTracerCLI.TRACE_STATEMENTS); final boolean calls = env.getOptions().get(MemoryTracerCLI.TRACE_CALLS); final boolean internals = env.getOptions().get(MemoryTracerCLI.TRACE_INTERNAL); final Object[] filterRootName = env.getOptions().get(MemoryTracerCLI.FILTER_ROOT); final Object[] filterFile = env.getOptions().get(MemoryTracerCLI.FILTER_FILE); final String filterLanguage = env.getOptions().get(MemoryTracerCLI.FILTER_LANGUAGE); return MemoryTracerCLI.buildFilter(roots, statements, calls, internals, filterRootName, filterFile, filterLanguage); }