示例#1
0
        public Error GetMethodVariableTable(ReferenceTypeId referenceType, MethodId method, out VariableData[] slots)
        {
            slots = null;

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            error = environment.GetLocalVariableTable(method, out slots);
            return GetStandardError(error);
        }
        public Error GetMethodVariableTable(out VariableData[] slots, ReferenceTypeId referenceType, MethodId method)
        {
            byte[] packet = new byte[HeaderSize + ReferenceTypeIdSize + MethodIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, MethodCommand.VariableTableWithGeneric);
            WriteReferenceTypeId(packet, HeaderSize, referenceType);
            WriteMethodId(packet, HeaderSize + ReferenceTypeIdSize, method);

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                slots = null;
                return errorCode;
            }

            int offset = HeaderSize;
            int argumentCount = ReadInt32(response, ref offset);
            int slotCount = ReadInt32(response, ref offset);
            slots = new VariableData[slotCount];
            for (int i = 0; i < slotCount; i++)
            {
                ulong codeIndex = ReadUInt64(response, ref offset);
                string name = ReadString(response, ref offset);
                string signature = ReadString(response, ref offset);
                string genericSignature = ReadString(response, ref offset);
                uint length = ReadUInt32(response, ref offset);
                int slot = ReadInt32(response, ref offset);
                slots[i] = new VariableData(slot, codeIndex, length, name, signature, genericSignature);
            }

            return Error.None;
        }
示例#3
0
        public jvmtiError GetLocalVariableTable(MethodId methodId, out VariableData[] variables)
        {
            variables = null;

            int entryCountPtr;
            IntPtr tablePtr;
            jvmtiError error = RawInterface.GetLocalVariableTable(this, methodId, out entryCountPtr, out tablePtr);
            if (error != jvmtiError.None)
                return error;

            try
            {
                List<VariableData> variableData = new List<VariableData>();
                unsafe
                {
                    jvmtiLocalVariableEntry* entryTable = (jvmtiLocalVariableEntry*)tablePtr;
                    for (int i = 0; i < entryCountPtr; i++)
                    {
                        VariableData data = new VariableData(entryTable[i].Slot, (ulong)entryTable[i].StartLocation.Value, (uint)entryTable[i].Length, entryTable[i].Name, entryTable[i].Signature, entryTable[i].GenericSignature);
                        variableData.Add(data);

                        Deallocate(entryTable[i]._name);
                        Deallocate(entryTable[i]._signature);
                        Deallocate(entryTable[i]._genericSignature);
                    }
                }

                variables = variableData.ToArray();
                return jvmtiError.None;
            }
            finally
            {
                Deallocate(tablePtr);
            }
        }