jdk.jfr.internal.Logger Java Examples

The following examples show how to use jdk.jfr.internal.Logger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JIInliner.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);

    if (isInstrumentationMethod(name, desc)) {
        MethodNode methodToInline = findTargetMethodNode(name, desc);
        if (methodToInline == null) {
            throw new IllegalArgumentException("Could not find the method to instrument in the target class");
        }
        if (Modifier.isNative(methodToInline.access)) {
            throw new IllegalArgumentException("Cannot instrument native methods: " + targetClassNode.name + "." + methodToInline.name + methodToInline.desc);
        }

        Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inliner processing method " + name + desc);

        JIMethodCallInliner mci = new JIMethodCallInliner(access,
                desc,
                mv,
                methodToInline,
                targetClassName,
                instrumentationClassName);
        return mci;
    }

    return mv;
}
 
Example #2
Source File: JIMethodCallInliner.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitMethodInsn(int opcode, String owner, String name,
        String desc, boolean itf) {
    // Now we are looking at method call in the source method
    if (!shouldBeInlined(owner, name, desc)) {
        // If this method call should not be inlined, just keep it
        mv.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    // If the call should be inlined, we create a MethodInliningAdapter
    // The MIA will walk the instructions in the inlineTarget and add them
    // to the current method, doing the necessary name remappings.
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inlining call to " + name + desc);
    Remapper remapper = new SimpleRemapper(oldClass, newClass);
    Label end = new Label();
    inlining = true;
    inlineTarget.instructions.resetLabels();
    JIMethodInliningAdapter mia = new JIMethodInliningAdapter(this, end,
            opcode == Opcodes.INVOKESTATIC ? Opcodes.ACC_STATIC : 0, desc,
            remapper);
    inlineTarget.accept(mia);
    inlining = false;
    super.visitLabel(end);
}
 
Example #3
Source File: JDKEvents.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public static byte[] retransformCallback(Class<?> klass, byte[] oldBytes) throws Throwable {
    if (java.lang.Throwable.class == klass) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Throwable");
        return ConstructorTracerWriter.generateBytes(java.lang.Throwable.class, oldBytes);
    }

    if (java.lang.Error.class == klass) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Error");
        return ConstructorTracerWriter.generateBytes(java.lang.Error.class, oldBytes);
    }

    for (int i = 0; i < targetClasses.length; i++) {
        if (targetClasses[i].equals(klass)) {
            Class<?> c = instrumentationClasses[i];
            Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, () -> "Processing instrumentation class: " + c);
            return new JIClassInstrumentation(instrumentationClasses[i], klass, oldBytes).getNewBytes();
        }
    }
    return oldBytes;
}
 
Example #4
Source File: JDKEvents.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void addInstrumentation() {
    try {
        List<Class<?>> list = new ArrayList<>();
        for (int i = 0; i < instrumentationClasses.length; i++) {
            JIInstrumentationTarget tgt = instrumentationClasses[i].getAnnotation(JIInstrumentationTarget.class);
            Class<?> clazz = Class.forName(tgt.value());
            targetClasses[i] = clazz;
            list.add(clazz);
        }
        list.add(java.lang.Throwable.class);
        list.add(java.lang.Error.class);
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Retransformed JDK classes");
        jvm.retransformClasses(list.toArray(new Class<?>[list.size()]));
    } catch (Exception e) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not add instrumentation for JDK events. " + e.getMessage());
    }
}
 
Example #5
Source File: JIMethodMergeAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    SimpleRemapper remapper = new SimpleRemapper(typeMap);
    for (MethodNode mn : cn.methods) {
        // Check if the method is in the list of methods to copy
        if (methodInFilter(mn.name, mn.desc)) {
            Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Copying method: " + mn.name + mn.desc);
            Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG,  "   with mapper: " + typeMap);

            String[] exceptions = new String[mn.exceptions.size()];
            mn.exceptions.toArray(exceptions);
            MethodVisitor mv = cv.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions);
            mn.instructions.resetLabels();
            mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, remapper));
        }
    }
    super.visitEnd();
}
 
Example #6
Source File: JIMethodMergeAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    SimpleRemapper remapper = new SimpleRemapper(typeMap);
    for (MethodNode mn : cn.methods) {
        // Check if the method is in the list of methods to copy
        if (methodInFilter(mn.name, mn.desc)) {
            Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Copying method: " + mn.name + mn.desc);
            Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG,  "   with mapper: " + typeMap);

            String[] exceptions = new String[mn.exceptions.size()];
            mn.exceptions.toArray(exceptions);
            MethodVisitor mv = cv.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions);
            mn.instructions.resetLabels();
            mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, remapper));
        }
    }
    super.visitEnd();
}
 
Example #7
Source File: JIInliner.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);

    if (isInstrumentationMethod(name, desc)) {
        MethodNode methodToInline = findTargetMethodNode(name, desc);
        if (methodToInline == null) {
            throw new IllegalArgumentException("Could not find the method to instrument in the target class");
        }
        if (Modifier.isNative(methodToInline.access)) {
            throw new IllegalArgumentException("Cannot instrument native methods: " + targetClassNode.name + "." + methodToInline.name + methodToInline.desc);
        }

        Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inliner processing method " + name + desc);

        JIMethodCallInliner mci = new JIMethodCallInliner(access,
                desc,
                mv,
                methodToInline,
                targetClassName,
                instrumentationClassName);
        return mci;
    }

    return mv;
}
 
Example #8
Source File: JDKEvents.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void addInstrumentation() {
    try {
        List<Class<?>> list = new ArrayList<>();
        for (int i = 0; i < instrumentationClasses.length; i++) {
            JIInstrumentationTarget tgt = instrumentationClasses[i].getAnnotation(JIInstrumentationTarget.class);
            Class<?> clazz = Class.forName(tgt.value());
            targetClasses[i] = clazz;
            list.add(clazz);
        }
        list.add(java.lang.Throwable.class);
        list.add(java.lang.Error.class);
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Retransformed JDK classes");
        jvm.retransformClasses(list.toArray(new Class<?>[list.size()]));
    } catch (Exception e) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not add instrumentation for JDK events. " + e.getMessage());
    }
}
 
Example #9
Source File: JDKEvents.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public static byte[] retransformCallback(Class<?> klass, byte[] oldBytes) throws Throwable {
    if (java.lang.Throwable.class == klass) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Throwable");
        return ConstructorTracerWriter.generateBytes(java.lang.Throwable.class, oldBytes);
    }

    if (java.lang.Error.class == klass) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Error");
        return ConstructorTracerWriter.generateBytes(java.lang.Error.class, oldBytes);
    }

    for (int i = 0; i < targetClasses.length; i++) {
        if (targetClasses[i].equals(klass)) {
            Class<?> c = instrumentationClasses[i];
            Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, () -> "Processing instrumentation class: " + c);
            return new JIClassInstrumentation(instrumentationClasses[i], klass, oldBytes).getNewBytes();
        }
    }
    return oldBytes;
}
 
Example #10
Source File: JIMethodCallInliner.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitMethodInsn(int opcode, String owner, String name,
        String desc, boolean itf) {
    // Now we are looking at method call in the source method
    if (!shouldBeInlined(owner, name, desc)) {
        // If this method call should not be inlined, just keep it
        mv.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    // If the call should be inlined, we create a MethodInliningAdapter
    // The MIA will walk the instructions in the inlineTarget and add them
    // to the current method, doing the necessary name remappings.
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inlining call to " + name + desc);
    Remapper remapper = new SimpleRemapper(oldClass, newClass);
    Label end = new Label();
    inlining = true;
    inlineTarget.instructions.resetLabels();
    JIMethodInliningAdapter mia = new JIMethodInliningAdapter(this, end,
            opcode == Opcodes.INVOKESTATIC ? Opcodes.ACC_STATIC : 0, desc,
            remapper);
    inlineTarget.accept(mia);
    inlining = false;
    super.visitLabel(end);
}
 
Example #11
Source File: JIInliner.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);

    if (isInstrumentationMethod(name, desc)) {
        MethodNode methodToInline = findTargetMethodNode(name, desc);
        if (methodToInline == null) {
            throw new IllegalArgumentException("Could not find the method to instrument in the target class");
        }
        if (Modifier.isNative(methodToInline.access)) {
            throw new IllegalArgumentException("Cannot instrument native methods: " + targetClassNode.name + "." + methodToInline.name + methodToInline.desc);
        }

        Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inliner processing method " + name + desc);

        JIMethodCallInliner mci = new JIMethodCallInliner(access,
                desc,
                mv,
                methodToInline,
                targetClassName,
                instrumentationClassName);
        return mci;
    }

    return mv;
}
 
Example #12
Source File: JIMethodCallInliner.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitMethodInsn(int opcode, String owner, String name,
        String desc, boolean itf) {
    // Now we are looking at method call in the source method
    if (!shouldBeInlined(owner, name, desc)) {
        // If this method call should not be inlined, just keep it
        mv.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    // If the call should be inlined, we create a MethodInliningAdapter
    // The MIA will walk the instructions in the inlineTarget and add them
    // to the current method, doing the necessary name remappings.
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inlining call to " + name + desc);
    Remapper remapper = new SimpleRemapper(oldClass, newClass);
    Label end = new Label();
    inlining = true;
    inlineTarget.instructions.resetLabels();
    JIMethodInliningAdapter mia = new JIMethodInliningAdapter(this, end,
            opcode == Opcodes.INVOKESTATIC ? Opcodes.ACC_STATIC : 0, desc,
            remapper);
    inlineTarget.accept(mia);
    inlining = false;
    super.visitLabel(end);
}
 
Example #13
Source File: JDKEvents.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public static byte[] retransformCallback(Class<?> klass, byte[] oldBytes) throws Throwable {
    if (java.lang.Throwable.class == klass) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Throwable");
        return ConstructorTracerWriter.generateBytes(java.lang.Throwable.class, oldBytes);
    }

    if (java.lang.Error.class == klass) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Error");
        return ConstructorTracerWriter.generateBytes(java.lang.Error.class, oldBytes);
    }

    for (int i = 0; i < targetClasses.length; i++) {
        if (targetClasses[i].equals(klass)) {
            Class<?> c = instrumentationClasses[i];
            Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, () -> "Processing instrumentation class: " + c);
            return new JIClassInstrumentation(instrumentationClasses[i], klass, oldBytes).getNewBytes();
        }
    }
    return oldBytes;
}
 
Example #14
Source File: JDKEvents.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void addInstrumentation() {
    try {
        List<Class<?>> list = new ArrayList<>();
        for (int i = 0; i < instrumentationClasses.length; i++) {
            JIInstrumentationTarget tgt = instrumentationClasses[i].getAnnotation(JIInstrumentationTarget.class);
            Class<?> clazz = Class.forName(tgt.value());
            targetClasses[i] = clazz;
            list.add(clazz);
        }
        list.add(java.lang.Throwable.class);
        list.add(java.lang.Error.class);
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Retransformed JDK classes");
        jvm.retransformClasses(list.toArray(new Class<?>[list.size()]));
    } catch (Exception e) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not add instrumentation for JDK events. " + e.getMessage());
    }
}
 
Example #15
Source File: JIMethodMergeAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitEnd() {
    SimpleRemapper remapper = new SimpleRemapper(typeMap);
    for (MethodNode mn : cn.methods) {
        // Check if the method is in the list of methods to copy
        if (methodInFilter(mn.name, mn.desc)) {
            Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Copying method: " + mn.name + mn.desc);
            Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG,  "   with mapper: " + typeMap);

            String[] exceptions = new String[mn.exceptions.size()];
            mn.exceptions.toArray(exceptions);
            MethodVisitor mv = cv.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions);
            mn.instructions.resetLabels();
            mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, remapper));
        }
    }
    super.visitEnd();
}
 
Example #16
Source File: TestLogImplementation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void assertLargeMessageOK() {
    StringBuilder large = new StringBuilder();
    for (int i = 0; i < 1000 * 1000; i++) {
        large.append('o');
    }
    Logger.log(JFR_LOG_TAG, DEFAULT_TEST_LOG_LEVEL, large.toString());
}
 
Example #17
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Flight Recorder for the platform.
 *
 * @return a Flight Recorder instance, not {@code null}
 *
 * @throws IllegalStateException if Flight Recorder can't be created (for
 *         example, if the Java Virtual Machine (JVM) lacks Flight Recorder
 *         support, or if the file repository can't be created or accessed)
 *
 * @throws SecurityException if a security manager exists and the caller does
 *         not have {@code FlightRecorderPermission("accessFlightRecorder")}
 */
public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException {
    synchronized (PlatformRecorder.class) {
        Utils.checkAccessFlightRecorder();
        JVMSupport.ensureWithIllegalStateException();
        if (platformRecorder == null) {
            try {
                platformRecorder = new FlightRecorder(new PlatformRecorder());
            } catch (IllegalStateException ise) {
                throw ise;
            } catch (Exception e) {
                throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e);
            }
            // Must be in synchronized block to prevent instance leaking out
            // before initialization is done
            initialized = true;
            Logger.log(JFR, INFO, "Flight Recorder initialized");
            Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes");
            Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount());
            Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath());
            Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads());
            Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth());
            Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize());
            Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString());
            PlatformRecorder.notifyRecorderInitialized(platformRecorder);
        }
    }
    return platformRecorder;
}
 
Example #18
Source File: TimeConverter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private ZoneOffset zoneOfSet(int rawOffset) {
    try {
        return ZoneOffset.ofTotalSeconds(rawOffset / 1000);
    } catch (DateTimeException dte) {
        Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Could not create ZoneOffset from raw offset " + rawOffset);
    }
    return ZoneOffset.UTC;
}
 
Example #19
Source File: TestLogImplementation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void assertAllCharsOK() {
    char c = Character.MIN_VALUE;
    StringBuilder large = new StringBuilder();
    int logSize = 0;
    for(int i = Character.MIN_VALUE; i< (int)Character.MAX_VALUE; i++, c++) {
        large.append(c);
        logSize++;
        if (logSize == 80) {
            Logger.log(JFR_LOG_TAG, DEFAULT_TEST_LOG_LEVEL, large.toString());
            large = new StringBuilder();
        }
    }
}
 
Example #20
Source File: DCmdCheck.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void executeInternal(String name, Boolean verbose) throws DCmdException {
    if (LogTag.JFR_DCMD.shouldLog(LogLevel.DEBUG)) {
        Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdCheck: name=" + name + ", verbose=" + verbose);
    }

    if (verbose == null) {
        verbose = Boolean.FALSE;
    }

    if (name != null) {
        printRecording(findRecording(name), verbose);
        return;
    }

    List<Recording> recordings = getRecordings();
    if (!verbose && recordings.isEmpty()) {
        println("No available recordings.");
        println();
        println("Use jcmd " + getPid() + " JFR.start to start a recording.");
        return;
    }
    boolean first = true;
    for (Recording recording : recordings) {
        // Print separation between recordings,
        if (!first) {
            println();
            if (Boolean.TRUE.equals(verbose)) {
                println();
            }
        }
        first = false;
        printRecording(recording, verbose);
    }
}
 
Example #21
Source File: JIMethodMergeAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if(methodInFilter(name, desc)) {
        // If the method is one that we will be replacing, delete the method
        Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Deleting " + name + desc);
        return null;
    }
    return super.visitMethod(access, name, desc, signature, exceptions);
}
 
Example #22
Source File: JDKEvents.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public synchronized static void initialize() {
    try {
        if (initializationTriggered == false) {
            for (Class<?> eventClass : eventClasses) {
                SecuritySupport.registerEvent((Class<? extends Event>) eventClass);
            }
            initializationTriggered = true;
            RequestEngine.addTrustedJDKHook(ExceptionStatisticsEvent.class, emitExceptionStatistics);
        }
    } catch (Exception e) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not initialize JDK events. " + e.getMessage());
    }
}
 
Example #23
Source File: ChunkHeader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public MetadataDescriptor readMetadata() throws IOException {
    input.position(absoluteChunkStart + metadataPosition);
    input.readInt(); // size
    long id = input.readLong(); // event type id
    if (id != METADATA_TYPE_ID) {
        throw new IOException("Expected metadata event. Type id=" + id + ", should have been " + METADATA_TYPE_ID);
    }
    input.readLong(); // start time
    input.readLong(); // duration
    long metadataId = input.readLong();
    Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, "Metadata id=" + metadataId);
    // No need to read if metadataId == lastMetadataId, but we
    // do it for verification purposes.
    return MetadataDescriptor.read(input);
}
 
Example #24
Source File: DCmdCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void executeInternal(String name, Boolean verbose) throws DCmdException {
    if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) {
        Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdCheck: name=" + name + ", verbose=" + verbose);
    }

    if (verbose == null) {
        verbose = Boolean.FALSE;
    }

    if (name != null) {
        printRecording(findRecording(name), verbose);
        return;
    }

    List<Recording> recordings = getRecordings();
    if (!verbose && recordings.isEmpty()) {
        println("No available recordings.");
        println();
        println("Use jcmd " + getPid() + " JFR.start to start a recording.");
        return;
    }
    boolean first = true;
    for (Recording recording : recordings) {
        // Print separation between recordings,
        if (!first) {
            println();
            if (Boolean.TRUE.equals(verbose)) {
                println();
            }
        }
        first = false;
        printRecording(recording, verbose);
    }
}
 
Example #25
Source File: TestLogImplementation.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void assertLargeMessageOK() {
    StringBuilder large = new StringBuilder();
    for (int i = 0; i < 1000 * 1000; i++) {
        large.append('o');
    }
    Logger.log(JFR_LOG_TAG, DEFAULT_TEST_LOG_LEVEL, large.toString());
}
 
Example #26
Source File: TestLogImplementation.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void assertAllCharsOK() {
    char c = Character.MIN_VALUE;
    StringBuilder large = new StringBuilder();
    int logSize = 0;
    for(int i = Character.MIN_VALUE; i< (int)Character.MAX_VALUE; i++, c++) {
        large.append(c);
        logSize++;
        if (logSize == 80) {
            Logger.log(JFR_LOG_TAG, DEFAULT_TEST_LOG_LEVEL, large.toString());
            large = new StringBuilder();
        }
    }
}
 
Example #27
Source File: JIMethodMergeAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if(methodInFilter(name, desc)) {
        // If the method is one that we will be replacing, delete the method
        Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Deleting " + name + desc);
        return null;
    }
    return super.visitMethod(access, name, desc, signature, exceptions);
}
 
Example #28
Source File: JDKEvents.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public synchronized static void initialize() {
    try {
        if (initializationTriggered == false) {
            for (Class<?> eventClass : eventClasses) {
                SecuritySupport.registerEvent((Class<? extends Event>) eventClass);
            }
            initializationTriggered = true;
            FlightRecorder.addPeriodicEvent(ExceptionStatisticsEvent.class, emitExceptionStatistics);
        }
    } catch (Exception e) {
        Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not initialize JDK events. " + e.getMessage());
    }
}
 
Example #29
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Flight Recorder for the platform.
 *
 * @return a Flight Recorder instance, not {@code null}
 *
 * @throws IllegalStateException if the platform Flight Recorder couldn't be
 *         created (for example, if the file repository can't be created or
 *         accessed)
 *
 * @throws SecurityException if a security manager exists and the caller does
 *         not have {@code FlightRecorderPermission("accessFlightRecorder")}
 */
public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException {
    synchronized (PlatformRecorder.class) {
        Utils.checkAccessFlightRecorder();
        JVMSupport.ensureWithIllegalStateException();
        if (platformRecorder == null) {
            try {
                platformRecorder = new FlightRecorder(new PlatformRecorder());
            } catch (IllegalStateException ise) {
                throw ise;
            } catch (Exception e) {
                throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e);
            }
            // Must be in synchronized block to prevent instance leaking out
            // before initialization is done
            initialized = true;
            Logger.log(JFR, INFO, "Flight Recorder initialized");
            Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes");
            Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount());
            Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath());
            Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads());
            Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth());
            Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize());
            Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString());
            PlatformRecorder.notifyRecorderInitialized(platformRecorder);
        }
    }
    return platformRecorder;
}
 
Example #30
Source File: ChunkHeader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public MetadataDescriptor readMetadata() throws IOException {
    input.position(absoluteChunkStart + metadataPosition);
    input.readInt(); // size
    long id = input.readLong(); // event type id
    if (id != METADATA_TYPE_ID) {
        throw new IOException("Expected metadata event. Type id=" + id + ", should have been " + METADATA_TYPE_ID);
    }
    input.readLong(); // start time
    input.readLong(); // duration
    long metadataId = input.readLong();
    Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, "Metadata id=" + metadataId);
    // No need to read if metadataId == lastMetadataId, but we
    // do it for verification purposes.
    return MetadataDescriptor.read(input);
}