public jvmtiError GetSourceFileName(JvmVirtualMachineRemoteHandle virtualMachine, JvmClassRemoteHandle @class, out string sourceName) { JavaVM machine = JavaVM.GetInstance(virtualMachine); string sourceNameResult = null; jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; IntPtr sourceNamePtr = IntPtr.Zero; try { result = rawInterface.GetSourceFileName(environment.Handle, @class, out sourceNamePtr); unsafe { if (sourceNamePtr != IntPtr.Zero) { sourceNameResult = ModifiedUTF8Encoding.GetString((byte *)sourceNamePtr); } } } finally { rawInterface.Deallocate(environment.Handle, sourceNamePtr); } }); sourceName = sourceNameResult; return(result); }
public jvmtiError GetThreadInfo(JvmVirtualMachineRemoteHandle virtualMachine, JvmThreadRemoteHandle thread, out JvmThreadRemoteInfo info) { JavaVM machine = JavaVM.GetInstance(virtualMachine); jvmtiThreadInfo threadInfo = default(jvmtiThreadInfo); jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.GetThreadInfo(environment.Handle, thread, out threadInfo); }); info = new JvmThreadRemoteInfo() { Name = threadInfo.Name, Priority = threadInfo._priority, IsDaemon = threadInfo._isDaemon != 0, ContextClassLoader = new JvmObjectRemoteHandle(threadInfo._contextClassLoader), ThreadGroup = new JvmThreadGroupRemoteHandle(threadInfo._threadGroup) }; return(result); }
public jvmtiError Deallocate(JvmVirtualMachineRemoteHandle virtualMachine, long address) { JavaVM machine = JavaVM.GetInstance(virtualMachine); jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.Deallocate(environment.Handle, (IntPtr)address); }); return(result); }
public jvmtiError SetTag(JvmVirtualMachineRemoteHandle virtualMachine, JvmObjectRemoteHandle @object, long tag) { JavaVM machine = JavaVM.GetInstance(virtualMachine); jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.SetTag(environment.Handle, @object, tag); }); return(result); }
public jvmtiError GetCurrentThread(JvmVirtualMachineRemoteHandle virtualMachine, out JvmThreadRemoteHandle threadHandle) { JavaVM machine = JavaVM.GetInstance(virtualMachine); jthread thread = jthread.Null; jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.GetCurrentThread(environment.Handle, out thread); }); threadHandle = new JvmThreadRemoteHandle(thread); return(result); }
public jvmtiError GetObjectHashCode(JvmVirtualMachineRemoteHandle virtualMachine, JvmObjectRemoteHandle @object, out int hashCode) { JavaVM machine = JavaVM.GetInstance(virtualMachine); int hashCodeResult = 0; jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.GetObjectHashCode(environment.Handle, @object, out hashCodeResult); }); hashCode = hashCodeResult; return(result); }
public jvmtiError GetThreadState(JvmVirtualMachineRemoteHandle virtualMachine, JvmThreadRemoteHandle thread, out jvmtiThreadState threadState) { JavaVM machine = JavaVM.GetInstance(virtualMachine); jvmtiThreadState threadStateResult = jvmtiThreadState.None; jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.GetThreadState(environment.Handle, thread, out threadStateResult); }); threadState = threadStateResult; return(result); }
public jvmtiError Allocate(JvmVirtualMachineRemoteHandle virtualMachine, long size, out long address) { JavaVM machine = JavaVM.GetInstance(virtualMachine); jvmtiError result = jvmtiError.Internal; IntPtr memory = IntPtr.Zero; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.Allocate(environment.Handle, size, out memory); }); address = memory.ToInt64(); return(result); }
public jvmtiError GetClassSignature(JvmVirtualMachineRemoteHandle virtualMachine, JvmClassRemoteHandle @class, out string signature, out string generic) { JavaVM machine = JavaVM.GetInstance(virtualMachine); string signatureResult = null; string genericResult = null; jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; IntPtr signaturePtr = IntPtr.Zero; IntPtr genericPtr = IntPtr.Zero; try { result = rawInterface.GetClassSignature(environment.Handle, @class, out signaturePtr, out genericPtr); unsafe { if (signaturePtr != IntPtr.Zero) { signatureResult = ModifiedUTF8Encoding.GetString((byte *)signaturePtr); } if (genericPtr != IntPtr.Zero) { genericResult = ModifiedUTF8Encoding.GetString((byte *)genericPtr); } } } finally { rawInterface.Deallocate(environment.Handle, signaturePtr); rawInterface.Deallocate(environment.Handle, genericPtr); } }); signature = signatureResult; generic = genericResult; return(result); }
public jvmtiError GetLineNumberTable(JvmVirtualMachineRemoteHandle virtualMachine, JvmMethodRemoteHandle method, out JvmLineNumberEntry[] lineNumbers) { JavaVM machine = JavaVM.GetInstance(virtualMachine); List <JvmLineNumberEntry> lineNumbersList = new List <JvmLineNumberEntry>(); jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; IntPtr lineNumbersPtr = IntPtr.Zero; try { int entryCount; result = rawInterface.GetLineNumberTable(environment.Handle, (jmethodID)method, out entryCount, out lineNumbersPtr); unsafe { jvmtiLineNumberEntry *rawLineNumbers = (jvmtiLineNumberEntry *)lineNumbersPtr; for (int i = 0; i < entryCount; i++) { lineNumbersList.Add(new JvmLineNumberEntry(method, rawLineNumbers[i])); } } } finally { rawInterface.Deallocate(environment.Handle, lineNumbersPtr); } }); lineNumbers = lineNumbersList.ToArray(); return(result); }
public jvmtiError GetClassMethods(JvmVirtualMachineRemoteHandle virtualMachine, JvmClassRemoteHandle @class, out JvmMethodRemoteHandle[] methods) { JavaVM machine = JavaVM.GetInstance(virtualMachine); List <JvmMethodRemoteHandle> methodsList = new List <JvmMethodRemoteHandle>(); jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; IntPtr methodsPtr = IntPtr.Zero; try { int methodCount; result = rawInterface.GetClassMethods(environment.Handle, @class, out methodCount, out methodsPtr); unsafe { jmethodID *rawMethods = (jmethodID *)methodsPtr; for (int i = 0; i < methodCount; i++) { methodsList.Add(new JvmMethodRemoteHandle(rawMethods[i])); } } } finally { rawInterface.Deallocate(environment.Handle, methodsPtr); } }); methods = methodsList.ToArray(); return(result); }