Search in sources :

Example 1 with JvmtiLineNumberEntry

use of com.oracle.svm.jvmtiagentbase.jvmti.JvmtiLineNumberEntry in project graal by oracle.

the class JavaStackTraceCreator method getFrameSourceLineNumber.

private static int getFrameSourceLineNumber(JvmtiEnv jvmti, JvmtiFrameInfo frameInfo) {
    CIntPointer entryCountPointer = StackValue.get(CIntPointer.class);
    WordPointer lineEntryTablePointer = StackValue.get(WordPointer.class);
    JvmtiError errorCode = jvmti.getFunctions().GetLineNumberTable().invoke(jvmti, frameInfo.getMethod(), entryCountPointer, lineEntryTablePointer);
    if (errorCode == JvmtiError.JVMTI_ERROR_MUST_POSSESS_CAPABILITY || errorCode == JvmtiError.JVMTI_ERROR_ABSENT_INFORMATION) {
        return LINE_NUMBER_UNAVAILABLE;
    }
    check(errorCode);
    int entryCount = entryCountPointer.read();
    Pointer lineEntryTable = lineEntryTablePointer.read();
    VMError.guarantee(lineEntryTable.isNonNull());
    int previousLineNumber = LINE_NUMBER_UNAVAILABLE;
    for (int i = 0; i < entryCount; ++i) {
        JvmtiLineNumberEntry entry = (JvmtiLineNumberEntry) lineEntryTable.add(i * SizeOf.get(JvmtiLineNumberEntry.class));
        if (entry.getStartLocation() > frameInfo.getLocation()) {
            break;
        }
        previousLineNumber = entry.getLineNumber();
    }
    jvmti.getFunctions().Deallocate().invoke(jvmti, lineEntryTable);
    return previousLineNumber;
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) JvmtiLineNumberEntry(com.oracle.svm.jvmtiagentbase.jvmti.JvmtiLineNumberEntry) WordPointer(org.graalvm.nativeimage.c.type.WordPointer) JvmtiError(com.oracle.svm.jvmtiagentbase.jvmti.JvmtiError) CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) WordPointer(org.graalvm.nativeimage.c.type.WordPointer) Pointer(org.graalvm.word.Pointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer)

Aggregations

JvmtiError (com.oracle.svm.jvmtiagentbase.jvmti.JvmtiError)1 JvmtiLineNumberEntry (com.oracle.svm.jvmtiagentbase.jvmti.JvmtiLineNumberEntry)1 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)1 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)1 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)1 WordPointer (org.graalvm.nativeimage.c.type.WordPointer)1 Pointer (org.graalvm.word.Pointer)1