コード例 #1
0
        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);
        }