Search in sources :

Example 11 with InterceptedState

use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.

the class JniCallInterceptor method fromReflectedMethod.

@CEntryPoint(name = "FromReflectedMethod")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIMethodId fromReflectedMethod(JNIEnvironment env, JNIObjectHandle method) {
    InterceptedState state = initInterceptedState();
    JNIObjectHandle callerClass = getCallerClass(state, env);
    JNIMethodId result = jniFunctions().getFromReflectedMethod().invoke(env, method);
    JNIObjectHandle declaring = nullHandle();
    String name = null;
    String signature = null;
    if (result.isNonNull()) {
        declaring = getMethodDeclaringClass(result);
        CCharPointerPointer namePtr = StackValue.get(CCharPointerPointer.class);
        CCharPointerPointer signaturePtr = StackValue.get(CCharPointerPointer.class);
        if (jvmtiFunctions().GetMethodName().invoke(jvmtiEnv(), result, namePtr, signaturePtr, nullPointer()) == JvmtiError.JVMTI_ERROR_NONE) {
            name = fromCString(namePtr.read());
            signature = fromCString(signaturePtr.read());
            jvmtiFunctions().Deallocate().invoke(jvmtiEnv(), namePtr.read());
            jvmtiFunctions().Deallocate().invoke(jvmtiEnv(), signaturePtr.read());
        }
    }
    if (shouldTrace()) {
        traceCall(env, "FromReflectedMethod", declaring, nullHandle(), callerClass, result.isNonNull(), state, name, signature);
    }
    return result;
}
Also used : InterceptedState(com.oracle.svm.agent.stackaccess.InterceptedState) Support.fromCString(com.oracle.svm.jvmtiagentbase.Support.fromCString) JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) JNIMethodId(com.oracle.svm.jni.nativeapi.JNIMethodId) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 12 with InterceptedState

use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.

the class JniCallInterceptor method fromReflectedField.

@CEntryPoint(name = "FromReflectedField")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIFieldId fromReflectedField(JNIEnvironment env, JNIObjectHandle field) {
    InterceptedState state = initInterceptedState();
    JNIObjectHandle callerClass = getCallerClass(state, env);
    JNIFieldId result = jniFunctions().getFromReflectedField().invoke(env, field);
    JNIObjectHandle declaring = nullHandle();
    String name = Tracer.EXPLICIT_NULL;
    if (result.isNonNull()) {
        declaring = Support.callObjectMethod(env, field, agent.handles().javaLangReflectMemberGetDeclaringClass);
        name = getFieldName(declaring, result);
    }
    if (shouldTrace()) {
        traceCall(env, "FromReflectedField", declaring, nullHandle(), callerClass, result.isNonNull(), state, name);
    }
    return result;
}
Also used : InterceptedState(com.oracle.svm.agent.stackaccess.InterceptedState) Support.fromCString(com.oracle.svm.jvmtiagentbase.Support.fromCString) JNIFieldId(com.oracle.svm.jni.nativeapi.JNIFieldId) JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 13 with InterceptedState

use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.

the class JniCallInterceptor method toReflectedField.

@CEntryPoint(name = "ToReflectedField")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIObjectHandle toReflectedField(JNIEnvironment env, JNIObjectHandle clazz, JNIFieldId field, boolean isStatic) {
    InterceptedState state = initInterceptedState();
    JNIObjectHandle callerClass = getCallerClass(state, env);
    JNIObjectHandle declaring = getFieldDeclaringClass(clazz, field);
    String name = getFieldName(clazz, field);
    JNIObjectHandle result = jniFunctions().getToReflectedField().invoke(env, clazz, field, isStatic);
    if (shouldTrace()) {
        traceCall(env, "ToReflectedField", clazz, declaring, callerClass, result.notEqual(nullHandle()), state, name);
    }
    return result;
}
Also used : InterceptedState(com.oracle.svm.agent.stackaccess.InterceptedState) Support.fromCString(com.oracle.svm.jvmtiagentbase.Support.fromCString) JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 14 with InterceptedState

use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.

the class JniCallInterceptor method getMethodID.

@CEntryPoint(name = "GetMethodID")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIMethodId getMethodID(JNIEnvironment env, JNIObjectHandle clazz, CCharPointer name, CCharPointer signature) {
    InterceptedState state = initInterceptedState();
    JNIObjectHandle callerClass = getCallerClass(state, env);
    JNIMethodId result = jniFunctions().getGetMethodID().invoke(env, clazz, name, signature);
    if (shouldTrace()) {
        traceCall(env, "GetMethodID", clazz, getMethodDeclaringClass(result), callerClass, result.isNonNull(), state, fromCString(name), fromCString(signature));
    }
    return result;
}
Also used : InterceptedState(com.oracle.svm.agent.stackaccess.InterceptedState) JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) JNIMethodId(com.oracle.svm.jni.nativeapi.JNIMethodId) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 15 with InterceptedState

use of com.oracle.svm.agent.stackaccess.InterceptedState in project graal by oracle.

the class JniCallInterceptor method newObjectArray.

@CEntryPoint(name = "NewObjectArray")
@CEntryPointOptions(prologue = AgentIsolate.Prologue.class)
private static JNIObjectHandle newObjectArray(JNIEnvironment env, int length, JNIObjectHandle elementClass, JNIObjectHandle initialElement) {
    InterceptedState state = initInterceptedState();
    JNIObjectHandle callerClass = getCallerClass(state, env);
    JNIObjectHandle result = jniFunctions().getNewObjectArray().invoke(env, length, elementClass, initialElement);
    JNIObjectHandle resultClass = nullHandle();
    if (result.notEqual(nullHandle()) && !testException(env)) {
        resultClass = jniFunctions().getGetObjectClass().invoke(env, result);
        if (clearException(env)) {
            resultClass = nullHandle();
        }
    }
    if (shouldTrace()) {
        traceCall(env, "NewObjectArray", resultClass, nullHandle(), callerClass, result.notEqual(nullHandle()), state);
    }
    return result;
}
Also used : InterceptedState(com.oracle.svm.agent.stackaccess.InterceptedState) JNIObjectHandle(com.oracle.svm.jni.nativeapi.JNIObjectHandle) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Aggregations

InterceptedState (com.oracle.svm.agent.stackaccess.InterceptedState)15 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)14 JNIObjectHandle (com.oracle.svm.jni.nativeapi.JNIObjectHandle)14 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)14 Support.fromCString (com.oracle.svm.jvmtiagentbase.Support.fromCString)5 JNIFieldId (com.oracle.svm.jni.nativeapi.JNIFieldId)3 JNIMethodId (com.oracle.svm.jni.nativeapi.JNIMethodId)3 AgentMetaInfProcessor (com.oracle.svm.agent.ignoredconfig.AgentMetaInfProcessor)1 ConfigurationWithOriginsResultWriter (com.oracle.svm.agent.predicatedconfig.ConfigurationWithOriginsResultWriter)1 MethodInfoRecordKeeper (com.oracle.svm.agent.predicatedconfig.MethodInfoRecordKeeper)1 EagerlyLoadedJavaStackAccess (com.oracle.svm.agent.stackaccess.EagerlyLoadedJavaStackAccess)1 OnDemandJavaStackAccess (com.oracle.svm.agent.stackaccess.OnDemandJavaStackAccess)1 ConfigurationResultWriter (com.oracle.svm.agent.tracing.ConfigurationResultWriter)1 TraceFileWriter (com.oracle.svm.agent.tracing.TraceFileWriter)1 Tracer (com.oracle.svm.agent.tracing.core.Tracer)1 TracingResultWriter (com.oracle.svm.agent.tracing.core.TracingResultWriter)1 ConfigurationSet (com.oracle.svm.configure.config.ConfigurationSet)1 FilterConfigurationParser (com.oracle.svm.configure.filters.FilterConfigurationParser)1 RuleNode (com.oracle.svm.configure.filters.RuleNode)1 AccessAdvisor (com.oracle.svm.configure.trace.AccessAdvisor)1