Search in sources :

Example 6 with JvmtiError

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

the class Support method getCallerMethod.

public static JNIMethodId getCallerMethod(int depth) {
    JvmtiFrameInfo frameInfo = StackValue.get(JvmtiFrameInfo.class);
    CIntPointer countPtr = StackValue.get(CIntPointer.class);
    JvmtiError result = jvmtiFunctions().GetStackTrace().invoke(jvmtiEnv(), nullHandle(), depth, 1, (WordPointer) frameInfo, countPtr);
    if (result == JvmtiError.JVMTI_ERROR_NONE && countPtr.read() == 1) {
        return frameInfo.getMethod();
    }
    return nullPointer();
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) JvmtiFrameInfo(com.oracle.svm.jvmtiagentbase.jvmti.JvmtiFrameInfo) JvmtiError(com.oracle.svm.jvmtiagentbase.jvmti.JvmtiError)

Example 7 with JvmtiError

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

the class JavaStackTraceCreator method constructStackTraceElement.

private StackTraceElement constructStackTraceElement(JvmtiFrameInfo frameInfo) {
    JNIObjectHandle declaringClass = Support.getMethodDeclaringClass(frameInfo.getMethod());
    String methodName = Support.getMethodNameOr(frameInfo.getMethod(), "");
    String declaringClassName = Support.getClassNameOr(jni, declaringClass, "", "");
    CCharPointer isNativePtr = StackValue.get(CCharPointer.class);
    String fileName = null;
    int lineNumber = LINE_NUMBER_UNAVAILABLE;
    JvmtiError errorCode = jvmti.getFunctions().IsMethodNative().invoke(jvmti, frameInfo.getMethod(), isNativePtr);
    if (errorCode == JvmtiError.JVMTI_ERROR_NONE && isNativePtr.read() == 0) {
        fileName = getSourceFileName(declaringClass);
        lineNumber = getFrameSourceLineNumber(jvmti, frameInfo);
    }
    return new StackTraceElement(declaringClassName, methodName, fileName, lineNumber);
}
Also used : JvmtiError(com.oracle.svm.jvmtiagentbase.jvmti.JvmtiError) JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer)

Aggregations

JvmtiError (com.oracle.svm.jvmtiagentbase.jvmti.JvmtiError)7 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)4 JNIMethodId (com.oracle.svm.jni.nativeapi.JNIMethodId)2 JNIObjectHandle (com.oracle.svm.jni.nativeapi.JNIObjectHandle)2 JvmtiFrameInfo (com.oracle.svm.jvmtiagentbase.jvmti.JvmtiFrameInfo)2 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)2 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)2 WordPointer (org.graalvm.nativeimage.c.type.WordPointer)2 Pointer (org.graalvm.word.Pointer)2 JvmtiEnv (com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEnv)1 JvmtiLineNumberEntry (com.oracle.svm.jvmtiagentbase.jvmti.JvmtiLineNumberEntry)1