Java Code Examples for jdk.jfr.consumer.RecordedFrame#getBytecodeIndex()

The following examples show how to use jdk.jfr.consumer.RecordedFrame#getBytecodeIndex() . 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: TestGetStackTrace.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void assertFrame(RecordedFrame frame) {
    int bci = frame.getBytecodeIndex();
    int line = frame.getLineNumber();
    boolean javaFrame = frame.isJavaFrame();
    RecordedMethod method = frame.getMethod();
    String type = frame.getType();
    System.out.println("*** Frame Info ***");
    System.out.println("bci=" + bci);
    System.out.println("line=" + line);
    System.out.println("type=" + type);
    System.out.println("method=" + method);
    System.out.println("***");
    Asserts.assertTrue(javaFrame, "Only Java frame are currently supported");
    Asserts.assertGreaterThanOrEqual(bci, -1);
    Asserts.assertNotNull(method, "Method should not be null");
}
 
Example 2
Source File: TestGetStackTrace.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void assertFrame(RecordedFrame frame) {
    int bci = frame.getBytecodeIndex();
    int line = frame.getLineNumber();
    boolean javaFrame = frame.isJavaFrame();
    RecordedMethod method = frame.getMethod();
    String type = frame.getType();
    System.out.println("*** Frame Info ***");
    System.out.println("bci=" + bci);
    System.out.println("line=" + line);
    System.out.println("type=" + type);
    System.out.println("method=" + method);
    System.out.println("***");
    Asserts.assertTrue(javaFrame, "Only Java frame are currently supported");
    Asserts.assertGreaterThanOrEqual(bci, -1);
    Asserts.assertNotNull(method, "Method should not be null");
}
 
Example 3
Source File: TestGetStackTrace.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void assertFrame(RecordedFrame frame) {
    int bci = frame.getBytecodeIndex();
    int line = frame.getLineNumber();
    boolean javaFrame = frame.isJavaFrame();
    RecordedMethod method = frame.getMethod();
    String type = frame.getType();
    System.out.println("*** Frame Info ***");
    System.out.println("bci=" + bci);
    System.out.println("line=" + line);
    System.out.println("type=" + type);
    System.out.println("method=" + method);
    System.out.println("***");
    Asserts.assertTrue(javaFrame, "Only Java frame are currently supported");
    Asserts.assertGreaterThanOrEqual(bci, -1);
    Asserts.assertNotNull(method, "Method should not be null");
}
 
Example 4
Source File: TestRecordedFrame.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void doTest(int lineNumber) throws IOException {

        System.out.println("Enetring method");

        Recording recording = new Recording();
        recording.start();

        SimpleEvent ev = new SimpleEvent();
        commitEvent(ev);
        recording.stop();

        List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
        Events.hasEvents(recordedEvents);
        RecordedEvent recordedEvent = recordedEvents.get(0);

        RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        for (RecordedFrame frame : frames) {

            // All frames are java frames
            Asserts.assertTrue(frame.isJavaFrame());
            // Verify the main() method frame
            RecordedMethod method = frame.getMethod();
            if (method.getName().equals("main")) {

                // Frame type
                String type = frame.getType();
                System.out.println("type: " + type);
                Asserts.assertTrue(
                        type.equals("Interpreted")
                        || type.equals("JIT compiled")
                        || type.equals("Inlined"));

                Asserts.assertEquals(lineNumber, frame.getLineNumber());

                boolean isInterpreted = "Interpreted".equals(type);
                boolean expectedInterpreted = "true".equals(System.getProperty("interpreted"));
                Asserts.assertEquals(isInterpreted, expectedInterpreted);

                int bci = frame.getBytecodeIndex();

                System.out.println("bci: " + bci);
                Asserts.assertTrue(bci > 0);
            }

        }

    }
 
Example 5
Source File: TestRecordedFrame.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void doTest(int lineNumber) throws IOException {

        System.out.println("Enetring method");

        Recording recording = new Recording();
        recording.start();

        SimpleEvent ev = new SimpleEvent();
        commitEvent(ev);
        recording.stop();

        List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
        Events.hasEvents(recordedEvents);
        RecordedEvent recordedEvent = recordedEvents.get(0);

        RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        for (RecordedFrame frame : frames) {

            // All frames are java frames
            Asserts.assertTrue(frame.isJavaFrame());
            // Verify the main() method frame
            RecordedMethod method = frame.getMethod();
            if (method.getName().equals("main")) {

                // Frame type
                String type = frame.getType();
                System.out.println("type: " + type);
                Asserts.assertTrue(
                        type.equals("Interpreted")
                        || type.equals("JIT compiled")
                        || type.equals("Inlined"));

                Asserts.assertEquals(lineNumber, frame.getLineNumber());

                boolean isInterpreted = "Interpreted".equals(type);
                boolean expectedInterpreted = "true".equals(System.getProperty("interpreted"));
                Asserts.assertEquals(isInterpreted, expectedInterpreted);

                int bci = frame.getBytecodeIndex();

                System.out.println("bci: " + bci);
                Asserts.assertTrue(bci > 0);
            }

        }

    }
 
Example 6
Source File: TestRecordedFrame.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void doTest(int lineNumber) throws IOException {

        System.out.println("Enetring method");

        Recording recording = new Recording();
        recording.start();

        SimpleEvent ev = new SimpleEvent();
        commitEvent(ev);
        recording.stop();

        List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
        Events.hasEvents(recordedEvents);
        RecordedEvent recordedEvent = recordedEvents.get(0);

        RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        for (RecordedFrame frame : frames) {

            // All frames are java frames
            Asserts.assertTrue(frame.isJavaFrame());
            // Verify the main() method frame
            RecordedMethod method = frame.getMethod();
            if (method.getName().equals("main")) {

                // Frame type
                String type = frame.getType();
                System.out.println("type: " + type);
                Asserts.assertTrue(
                        type.equals("Interpreted")
                        || type.equals("JIT compiled")
                        || type.equals("Inlined"));

                Asserts.assertEquals(lineNumber, frame.getLineNumber());

                boolean isInterpreted = "Interpreted".equals(type);
                boolean expectedInterpreted = "true".equals(System.getProperty("interpreted"));
                Asserts.assertEquals(isInterpreted, expectedInterpreted);

                int bci = frame.getBytecodeIndex();

                System.out.println("bci: " + bci);
                Asserts.assertTrue(bci > 0);
            }

        }

    }