internal JvmThreadGroupReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jthreadGroup handle, bool freeLocalReference)
     : base(environment, nativeEnvironment, handle, freeLocalReference)
 {
     Contract.Requires(environment != null);
     Contract.Requires(nativeEnvironment != null);
     Contract.Requires(handle != jthreadGroup.Null);
 }
Exemple #2
0
        internal JvmObjectReference(JvmEnvironment environment, SafeJvmWeakGlobalReferenceHandle handle)
        {
            Contract.Requires <ArgumentNullException>(environment != null, "environment");
            Contract.Requires <ArgumentNullException>(handle != null, "handle");

            _environment = environment;
            _handle      = handle;
        }
        public SafeJvmAllocHandle(JvmEnvironment environment, IntPtr handle, bool ownsHandle)
            : base(ownsHandle)
        {
            Contract.Requires <ArgumentNullException>(environment != null, "environment");

            _environment = environment;
            SetHandle(handle);
        }
 internal JvmThreadInfo(JvmEnvironment environment, JNIEnvHandle jniEnv, jvmtiThreadInfo threadInfo, bool freeLocalReference)
 {
     this.Name               = threadInfo.Name;
     this.Priority           = threadInfo._priority;
     this.IsDaemon           = threadInfo._isDaemon != 0;
     this.ThreadGroup        = JvmThreadGroupReference.FromHandle(environment, jniEnv, threadInfo._threadGroup, freeLocalReference);
     this.ContextClassLoader = JvmObjectReference.FromHandle(environment, jniEnv, threadInfo._contextClassLoader, freeLocalReference);
 }
        private void HandleVMStart(jvmtiEnvHandle env, JNIEnvHandle jniEnv)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleVMStart(environment);
            }
        }
        internal JvmNativeEnvironment(JvmEnvironment environment, JNIEnvHandle nativeEnvironmentHandle, jniNativeInterface nativeInterface)
        {
            Contract.Requires <ArgumentNullException>(environment != null, "environment");
            Contract.Requires <ArgumentException>(nativeEnvironmentHandle != JNIEnvHandle.Null);

            _environment             = environment;
            _nativeEnvironmentHandle = nativeEnvironmentHandle;
            _nativeInterface         = nativeInterface;
        }
Exemple #7
0
        internal JvmObjectReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jobject handle, bool freeLocalReference)
        {
            Contract.Requires <ArgumentNullException>(environment != null, "environment");
            Contract.Requires <ArgumentNullException>(nativeEnvironment != null, "nativeEnvironment");
            Contract.Requires <ArgumentException>(handle != jobject.Null);

            _environment = environment;
            _handle      = nativeEnvironment.NewWeakGlobalReference(handle);
        }
        private void HandleGarbageCollectionFinish(jvmtiEnvHandle env)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleGarbageCollectionFinish(environment);
            }
        }
        private void HandleObjectFree(jvmtiEnvHandle env, long tag)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleObjectFree(environment, tag);
            }
        }
        private void HandleDataDumpRequest(jvmtiEnvHandle env)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleDataDumpRequest(environment);
            }
        }
        private void HandleResourceExhausted(jvmtiEnvHandle env, JNIEnvHandle jniEnv, JvmResourceExhaustedFlags flags, IntPtr reserved, ModifiedUTF8StringData description)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleResourceExhausted(environment, flags, reserved, description.GetString());
            }
        }
        private void HandleDynamicCodeGenerated(jvmtiEnvHandle env, ModifiedUTF8StringData name, IntPtr address, int length)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleDynamicCodeGenerated(environment, name.GetString(), address, length);
            }
        }
        private void HandleCompiledMethodUnload(jvmtiEnvHandle env, jmethodID methodId, IntPtr codeAddress)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);
            JvmMethod      method      = new JvmMethod(environment, methodId);

            foreach (var processor in _processors)
            {
                processor.HandleCompiledMethodUnload(environment, method, codeAddress);
            }
        }
        private void HandleThreadEnd(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleThreadEnd(environment, thread);
            }
        }
        internal JvmThreadReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jthread handle, bool freeLocalReference)
            : base(environment, nativeEnvironment, handle, freeLocalReference)
        {
            Contract.Requires(environment != null);
            Contract.Requires(nativeEnvironment != null);
            Contract.Requires(handle != jthread.Null);

            // quick experiment to see if the lifetime of thread references is killing the process.
            pinnedReferences.Add(base.Handle);
        }
        private void HandleCompiledMethodLoad(jvmtiEnvHandle env, jmethodID method, int codeSize, IntPtr codeAddress, int mapLength, jvmtiAddressLocationMap[] map, IntPtr compileInfo)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                throw new NotImplementedException();
                //processor.HandleCompiledMethodLoad(environment, method, codeSize, codeAddress, map2, compileInfo);
            }
        }
        public static JvmClassReference FromHandle(JvmEnvironment environment, JNIEnvHandle jniEnv, jclass classHandle, bool freeLocalReference)
        {
            if (classHandle == jclass.Null)
            {
                return(null);
            }

            JvmNativeEnvironment nativeEnvironment = environment.GetNativeFunctionTable(jniEnv);

            return(new JvmClassReference(environment, nativeEnvironment, classHandle, freeLocalReference));
        }
        private void HandleMonitorWait(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jobject objectHandle, long millisecondsTimeout)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmObjectReference @object     = JvmObjectReference.FromHandle(environment, jniEnv, objectHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleMonitorWait(environment, thread, @object, millisecondsTimeout);
            }
        }
        private void HandleClassLoad(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jclass classHandle)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmClassReference  @class      = JvmClassReference.FromHandle(environment, jniEnv, classHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleClassLoad(environment, thread, @class);
            }
        }
        private void HandleMethodExit(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID methodId, bool wasPoppedByException, jvalue returnValue)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmMethod          method      = new JvmMethod(environment, methodId);

            foreach (var processor in _processors)
            {
                processor.HandleMethodExit(environment, thread, method, wasPoppedByException, returnValue);
            }
        }
        private void HandleMethodEntry(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID methodId)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmMethod          method      = new JvmMethod(environment, methodId);

            foreach (var processor in _processors)
            {
                processor.HandleMethodEntry(environment, thread, method);
            }
        }
        private void HandleBreakpoint(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID method, jlocation jlocation)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmLocation        location    = new JvmLocation(environment, method, jlocation);

            foreach (var processor in _processors)
            {
                processor.HandleBreakpoint(environment, thread, location);
            }
        }
        private void HandleMonitorContendedEntered(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jobject objectHandle)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmObjectReference @object     = JvmObjectReference.FromHandle(environment, jniEnv, objectHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleMonitorContendedEntered(environment, thread, @object);
            }
        }
        public static JvmThreadReference FromHandle(JvmEnvironment environment, JNIEnvHandle jniEnv, jthread threadHandle, bool freeLocalReference)
        {
            if (threadHandle == jthread.Null)
            {
                return(null);
            }

            JvmNativeEnvironment nativeEnvironment = environment.GetNativeFunctionTable(jniEnv);

            return(new JvmThreadReference(environment, nativeEnvironment, threadHandle, freeLocalReference));
        }
        private void HandleVMDeath(jvmtiEnvHandle env, JNIEnvHandle jniEnv)
        {
            JvmEnvironment environment = JvmEnvironment.GetEnvironment(env);

            foreach (var processor in _processors)
            {
                processor.HandleVMDeath(environment);
            }

            environment.VirtualMachine.ShutdownAgentDispatchers();
        }
Exemple #26
0
        public static JvmObjectReference FromHandle(JvmEnvironment environment, JNIEnvHandle jniEnv, jobject objectHandle, bool freeLocalReference)
        {
            if (objectHandle == jobject.Null)
            {
                return(null);
            }

            JvmNativeEnvironment nativeEnvironment = environment.GetNativeFunctionTable(jniEnv);

            return(new JvmObjectReference(environment, nativeEnvironment, objectHandle, freeLocalReference));
        }
        private void HandleClassFileLoadHook(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jclass classBeingRedefinedHandle, jobject loaderHandle, ModifiedUTF8StringData name, jobject protectionDomainHandle, int classDataLength, IntPtr classData, ref int newClassDataLength, ref IntPtr newClassData)
        {
            JvmEnvironment     environment         = JvmEnvironment.GetEnvironment(env);
            JvmClassReference  classBeingRedefined = JvmClassReference.FromHandle(environment, jniEnv, classBeingRedefinedHandle, true);
            JvmObjectReference loader           = JvmObjectReference.FromHandle(environment, jniEnv, loaderHandle, true);
            JvmObjectReference protectionDomain = JvmObjectReference.FromHandle(environment, jniEnv, protectionDomainHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleClassFileLoadHook(environment, classBeingRedefined, loader, name.GetString(), protectionDomain);
            }
        }
        private void HandleExceptionCatch(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID method, jlocation jlocation, jobject exceptionHandle)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmLocation        location    = new JvmLocation(environment, method, jlocation);
            JvmObjectReference exception   = JvmObjectReference.FromHandle(environment, jniEnv, exceptionHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleExceptionCatch(environment, thread, location, exception);
            }
        }
        private void HandleNativeMethodBind(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID methodId, IntPtr address, ref IntPtr newAddressPtr)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmMethod          method      = new JvmMethod(environment, methodId);

            foreach (var processor in _processors)
            {
                IntPtr?newAddress = null;
                processor.HandleNativeMethodBind(environment, thread, method, address, ref newAddress);
            }
        }
        private void HandleVMObjectAlloc(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jobject objectHandle, jclass objectClassHandle, long size)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmObjectReference @object     = JvmObjectReference.FromHandle(environment, jniEnv, objectHandle, true);
            JvmClassReference  objectClass = JvmClassReference.FromHandle(environment, jniEnv, objectClassHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleVMObjectAllocation(environment, thread, @object, objectClass, size);
            }
        }