jdk.jfr.consumer.RecordedFrame Java Examples

The following examples show how to use jdk.jfr.consumer.RecordedFrame. 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: OldObjects.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.contains(expectedFrame)) {
            return false;
        }
    }
    return true;
}
 
Example #2
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 #3
Source File: TestRecordedMethodDescriptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording();
    recording.enable(MyEvent.class).withStackTrace();
    recording.start();

    MyEvent event = new MyEvent();
    event.begin();
    event.end();
    event.commit();
    recording.stop();

    List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
    assertEquals(1, recordedEvents.size(), "Expected one event");
    RecordedEvent recordedEvent = recordedEvents.get(0);

    RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
    List<RecordedFrame> frames = stacktrace.getFrames();
    assertFalse(frames.isEmpty(), "Stacktrace frames was empty");
    for (RecordedFrame frame : frames) {
        analyzeRecordedMethodDescriptor(frame.getMethod());
    }

    assertTrue(isMainMethodDescriptorRecorded, "main() method descriptor has never been recorded");
}
 
Example #4
Source File: AllocationStackTrace.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.equals(expectedFrame)) {
            return false;
        }
    }

    return true;
}
 
Example #5
Source File: AllocationStackTrace.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.equals(expectedFrame)) {
            return false;
        }
    }

    return true;
}
 
Example #6
Source File: OldObjects.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.contains(expectedFrame)) {
            return false;
        }
    }
    return true;
}
 
Example #7
Source File: AllocationStackTrace.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.equals(expectedFrame)) {
            return false;
        }
    }

    return true;
}
 
Example #8
Source File: PrettyWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void printStackTrace(RecordedStackTrace stackTrace) {
    println("[");
    List<RecordedFrame> frames = stackTrace.getFrames();
    indent();
    int i = 0;
    while (i < frames.size() && i < getStackDepth()) {
        RecordedFrame frame = frames.get(i);
        if (frame.isJavaFrame()) {
            printIndent();
            printValue(frame, null, "");
            println();
            i++;
        }
    }
    if (stackTrace.isTruncated() || i == getStackDepth()) {
        printIndent();
        println("...");
    }
    retract();
    printIndent();
    println("]");
}
 
Example #9
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 #10
Source File: TestRecordedMethodDescriptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording();
    recording.enable(MyEvent.class).withStackTrace();
    recording.start();

    MyEvent event = new MyEvent();
    event.begin();
    event.end();
    event.commit();
    recording.stop();

    List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
    assertEquals(1, recordedEvents.size(), "Expected one event");
    RecordedEvent recordedEvent = recordedEvents.get(0);

    RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
    List<RecordedFrame> frames = stacktrace.getFrames();
    assertFalse(frames.isEmpty(), "Stacktrace frames was empty");
    for (RecordedFrame frame : frames) {
        analyzeRecordedMethodDescriptor(frame.getMethod());
    }

    assertTrue(isMainMethodDescriptorRecorded, "main() method descriptor has never been recorded");
}
 
Example #11
Source File: OldObjects.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.contains(expectedFrame)) {
            return false;
        }
    }
    return true;
}
 
Example #12
Source File: PrettyWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void printStackTrace(RecordedStackTrace stackTrace) {
    println("[");
    List<RecordedFrame> frames = stackTrace.getFrames();
    indent();
    int i = 0;
    while (i < frames.size() && i < getStackDepth()) {
        RecordedFrame frame = frames.get(i);
        if (frame.isJavaFrame()) {
            printIndent();
            printValue(frame, null, "");
            println();
            i++;
        }
    }
    if (stackTrace.isTruncated() || i == getStackDepth()) {
        printIndent();
        println("...");
    }
    retract();
    printIndent();
    println("]");
}
 
Example #13
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 #14
Source File: TestRecordedMethodDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording();
    recording.enable(MyEvent.class).withStackTrace();
    recording.start();

    MyEvent event = new MyEvent();
    event.begin();
    event.end();
    event.commit();
    recording.stop();

    List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
    assertEquals(1, recordedEvents.size(), "Expected one event");
    RecordedEvent recordedEvent = recordedEvents.get(0);

    RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
    List<RecordedFrame> frames = stacktrace.getFrames();
    assertFalse(frames.isEmpty(), "Stacktrace frames was empty");
    for (RecordedFrame frame : frames) {
        analyzeRecordedMethodDescriptor(frame.getMethod());
    }

    assertTrue(isMainMethodDescriptorRecorded, "main() method descriptor has never been recorded");
}
 
Example #15
Source File: AllocationStackTrace.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.equals(expectedFrame)) {
            return false;
        }
    }

    return true;
}
 
Example #16
Source File: OldObjects.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) {
    if (stack == null) {
        return false;
    }

    List<RecordedFrame> frames = stack.getFrames();
    int pos = findFramePos(frames, expectedStack[0]);

    if (pos == -1) {
        return false;
    }

    for (String expectedFrame : expectedStack) {
        RecordedFrame f = frames.get(pos++);
        String frame = frameToString(f);

        if (!frame.contains(expectedFrame)) {
            return false;
        }
    }
    return true;
}
 
Example #17
Source File: ProfileResults.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Formats a frame to a formatted line. This is deduplicated on!
 */
static String frameToString(RecordedFrame frame, boolean lineNumbers) {
  StringBuilder builder = new StringBuilder();
  RecordedMethod method = frame.getMethod();
  RecordedClass clazz = method.getType();
  if (clazz == null) {
    builder.append("<<");
    builder.append(frame.getType());
    builder.append(">>");
  } else {
    builder.append(clazz.getName());
  }
  builder.append("#");
  builder.append(method.getName());
  builder.append("()");
  if (lineNumbers) {
    builder.append(":");
    if (frame.getLineNumber() == -1) {
      builder.append("(" + frame.getType() + " code)");
    } else {
      builder.append(frame.getLineNumber());
    }
  }
  return builder.toString();
}
 
Example #18
Source File: TestRecordedFullStackTrace.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable {
    RecordedStackTrace stacktrace = null;
    try {
        stacktrace = event.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        Asserts.assertEquals(Math.min(MAX_DEPTH, expectedDepth), frames.size(), "Wrong stacktrace depth. Expected:" + expectedDepth);
        List<String> expectedMethods = getExpectedMethods(expectedDepth);
        Asserts.assertEquals(expectedMethods.size(), frames.size(), "Wrong expectedMethods depth. Test error.");

        for (int i = 0; i < frames.size(); ++i) {
            String name = frames.get(i).getMethod().getName();
            String expectedName = expectedMethods.get(i);
            System.out.printf("method[%d]=%s, expected=%s%n", i, name, expectedName);
            Asserts.assertEquals(name, expectedName, "Wrong method name");
        }

        boolean isTruncated = stacktrace.isTruncated();
        boolean isTruncateExpected = expectedDepth > MAX_DEPTH;
        Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected);

        String firstMethod = frames.get(frames.size() - 1).getMethod().getName();
        boolean isFullTrace = "run".equals(firstMethod);
        String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace);
        Asserts.assertTrue(isTruncated != isFullTrace, msg);
    } catch (Throwable t) {
        System.out.println(String.format("stacktrace:%n%s", stacktrace));
        throw t;
    }
}
 
Example #19
Source File: TestFullStackTrace.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable {
    RecordedStackTrace stacktrace = null;
    try {
        stacktrace = event.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        Asserts.assertEquals(Math.min(MAX_DEPTH, expectedDepth), frames.size(), "Wrong stacktrace depth. Expected:" + expectedDepth);
        List<String> expectedMethods = getExpectedMethods(expectedDepth);
        Asserts.assertEquals(expectedMethods.size(), frames.size(), "Wrong expectedMethods depth. Test error.");

        for (int i = 0; i < frames.size(); ++i) {
            String name = frames.get(i).getMethod().getName();
            String expectedName = expectedMethods.get(i);
            System.out.printf("method[%d]=%s, expected=%s%n", i, name, expectedName);
            Asserts.assertEquals(name, expectedName, "Wrong method name");
        }

        boolean isTruncated = stacktrace.isTruncated();
        boolean isTruncateExpected = expectedDepth > MAX_DEPTH;
        Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected);

        String firstMethod = frames.get(frames.size() - 1).getMethod().getName();
        boolean isFullTrace = "run".equals(firstMethod);
        String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace);
        Asserts.assertTrue(isTruncated != isFullTrace, msg);
    } catch (Throwable t) {
        System.out.println(String.format("stacktrace:%n%s", stacktrace));
        throw t;
    }
}
 
Example #20
Source File: OldObjects.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static int findFramePos(List<RecordedFrame> frames, String frame) {
    int pos = 0;
    for (RecordedFrame f : frames) {
        if (frameToString(f).contains(frame)) {
            return pos;
        }
        pos++;
    }
    return -1;
}
 
Example #21
Source File: TestMethodGetModifiers.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording();
    recording.start();

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

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

    System.out.println("recorded event:" + recordedEvent);

    RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
    List<RecordedFrame> frames = stacktrace.getFrames();
    for (RecordedFrame frame : frames) {
        RecordedMethod method = frame.getMethod();
        if (method.getName().equals("main")) {
            System.out.println("'main' method: " + method);
            int modifiers = TestMethodGetModifiers.class.getDeclaredMethod("main", (Class<?>)String[].class).getModifiers();
            System.out.println("modifiers: " + modifiers);
            Asserts.assertEquals(method.getModifiers(), modifiers, "Incorrect method modifier reported");
            RecordedClass type = method.getType();
            assertNotNull(type, "Recorded class can not be null");
        }

    }
}
 
Example #22
Source File: XMLWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void printArray(ValueDescriptor v, Object[] array) {
    println();
    indent();
    int depth = 0;
    for (int index = 0; index < array.length; index++) {
        Object arrayElement = array[index];
        if (!(arrayElement instanceof RecordedFrame) || depth < getStackDepth()) {
            printValueDescriptor(v, array[index], index);
        }
        depth++;
    }
    retract();
}
 
Example #23
Source File: PrettyWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void printJavaFrame(RecordedFrame f, String postFix) {
    print(formatMethod(f.getMethod()));
    int line = f.getLineNumber();
    if (line >= 0) {
        print(" line: " + line);
    }
    print(postFix);
}
 
Example #24
Source File: JSONWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void printArray(ValueDescriptor v, Object[] array) {
    printArrayBegin();
    boolean first = true;
    int depth = 0;
    for (Object arrayElement : array) {
        if (!(arrayElement instanceof RecordedFrame) || depth < getStackDepth()) {
            printValueDescriptor(first, true, v, arrayElement);
        }
        depth++;
        first = false;
    }
    printArrayEnd();
}
 
Example #25
Source File: TestMetadataRetention.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void assertStackTrace(RecordedStackTrace stacktrace, final String methodName) {
    for (RecordedFrame f : stacktrace.getFrames()) {
        if (f.getMethod().getName().equals(methodName)) {
            return;
        }
    }
    Asserts.fail("Could not find class " + methodName + " in stack trace " + stacktrace);
}
 
Example #26
Source File: OldObjects.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static int findFramePos(List<RecordedFrame> frames, String frame) {
    int pos = 0;
    for (RecordedFrame f : frames) {
        if (frameToString(f).contains(frame)) {
            return pos;
        }
        pos++;
    }
    return -1;
}
 
Example #27
Source File: TestFullStackTrace.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable {
    RecordedStackTrace stacktrace = null;
    try {
        stacktrace = event.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        Asserts.assertEquals(Math.min(MAX_DEPTH, expectedDepth), frames.size(), "Wrong stacktrace depth. Expected:" + expectedDepth);
        List<String> expectedMethods = getExpectedMethods(expectedDepth);
        Asserts.assertEquals(expectedMethods.size(), frames.size(), "Wrong expectedMethods depth. Test error.");

        for (int i = 0; i < frames.size(); ++i) {
            String name = frames.get(i).getMethod().getName();
            String expectedName = expectedMethods.get(i);
            System.out.printf("method[%d]=%s, expected=%s%n", i, name, expectedName);
            Asserts.assertEquals(name, expectedName, "Wrong method name");
        }

        boolean isTruncated = stacktrace.isTruncated();
        boolean isTruncateExpected = expectedDepth > MAX_DEPTH;
        Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected);

        String firstMethod = frames.get(frames.size() - 1).getMethod().getName();
        boolean isFullTrace = "run".equals(firstMethod);
        String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace);
        Asserts.assertTrue(isTruncated != isFullTrace, msg);
    } catch (Throwable t) {
        System.out.println(String.format("stacktrace:%n%s", stacktrace));
        throw t;
    }
}
 
Example #28
Source File: StressAllocationGCEvents.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkEvent(RecordedEvent event) throws Exception {
    // skip check if allocation failure comes not from diver

    RecordedThread thread = event.getThread();
    String threadName = thread.getJavaName();

    if (!threadName.contains(THREAD_NAME)) {
        System.out.println("Skip event not from pool (from internals)");
        System.out.println(" Thread Id: " + thread.getJavaThreadId()
                + " Thread name: " + threadName);
        return;
    }

    RecordedStackTrace stackTrace = event.getStackTrace();

    List<RecordedFrame> frames = stackTrace.getFrames();
    //String[] stacktrace = StackTraceHelper.buildStackTraceFromFrames(frames);

    if (!(frames.get(0).getMethod().getName().equals(DIVER_FRAME_NAME))) {
        System.out.println("Skip stacktrace check for: \n"
                + String.join("\n", threadName));
        return;
    }

    assertTrue(frames.size() > RECURSION_DEPTH,
            "Stack trace should contain at least one more entry than the ones generated by the test recursion");
    for (int i = 0; i < RECURSION_DEPTH; i++) {
        assertEquals(frames.get(i).getMethod().getName(), DIVER_FRAME_NAME,
                "Frame " + i + " is wrong: \n"
                + String.join("\n", threadName));
    }
    assertNotEquals(frames.get(RECURSION_DEPTH).getMethod().getName(), DIVER_FRAME_NAME,
            "Too many diver frames: \n"
            + String.join("\n", threadName));
}
 
Example #29
Source File: AllocationStackTrace.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static int findFramePos(List<RecordedFrame> frames, String frame) {
    int pos = 0;

    for (RecordedFrame f : frames) {
        if (frame.equals(frameToString(f))) {
            return pos;
        }
        pos++;
    }

    return -1;
}
 
Example #30
Source File: TestRecordedFullStackTrace.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable {
    RecordedStackTrace stacktrace = null;
    try {
        stacktrace = event.getStackTrace();
        List<RecordedFrame> frames = stacktrace.getFrames();
        Asserts.assertEquals(Math.min(MAX_DEPTH, expectedDepth), frames.size(), "Wrong stacktrace depth. Expected:" + expectedDepth);
        List<String> expectedMethods = getExpectedMethods(expectedDepth);
        Asserts.assertEquals(expectedMethods.size(), frames.size(), "Wrong expectedMethods depth. Test error.");

        for (int i = 0; i < frames.size(); ++i) {
            String name = frames.get(i).getMethod().getName();
            String expectedName = expectedMethods.get(i);
            System.out.printf("method[%d]=%s, expected=%s%n", i, name, expectedName);
            Asserts.assertEquals(name, expectedName, "Wrong method name");
        }

        boolean isTruncated = stacktrace.isTruncated();
        boolean isTruncateExpected = expectedDepth > MAX_DEPTH;
        Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected);

        String firstMethod = frames.get(frames.size() - 1).getMethod().getName();
        boolean isFullTrace = "run".equals(firstMethod);
        String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace);
        Asserts.assertTrue(isTruncated != isFullTrace, msg);
    } catch (Throwable t) {
        System.out.println(String.format("stacktrace:%n%s", stacktrace));
        throw t;
    }
}