示例#1
0
        public Error GetMethodLineTable(ReferenceTypeId referenceType, MethodId methodId, out long start, out long end, out LineNumberData[] lines)
        {
            start = 0;
            end = 0;
            lines = null;

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

            error = environment.GetLineNumberTable(methodId, out lines);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            jlocation startLocation;
            jlocation endLocation;
            error = environment.GetMethodLocation(methodId, out startLocation, out endLocation);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            start = startLocation.Value;
            end = endLocation.Value;
            return Error.None;
        }
        public Error GetMethodLineTable(out long start, out long end, out LineNumberData[] lines, ReferenceTypeId referenceType, MethodId method)
        {
            byte[] packet = new byte[HeaderSize + ReferenceTypeIdSize + MethodIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, MethodCommand.LineTable);
            WriteReferenceTypeId(packet, HeaderSize, referenceType);
            WriteMethodId(packet, HeaderSize + ReferenceTypeIdSize, method);

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

            int offset = HeaderSize;
            start = ReadInt64(response, ref offset);
            end = ReadInt64(response, ref offset);
            int lineCount = ReadInt32(response, ref offset);
            lines = new LineNumberData[lineCount];
            for (int i = 0; i < lineCount; i++)
            {
                long lineCodeIndex = ReadInt64(response, ref offset);
                int lineNumber = ReadInt32(response, ref offset);
                lines[i] = new LineNumberData(lineCodeIndex, lineNumber);
            }

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

            int entryCount;
            IntPtr table;
            jvmtiError error = RawInterface.GetLineNumberTable(this, (jmethodID)methodId, out entryCount, out table);
            if (error != jvmtiError.None)
                return error;

            try
            {
                List<LineNumberData> lineData = new List<LineNumberData>();
                unsafe
                {
                    jvmtiLineNumberEntry* entryTable = (jvmtiLineNumberEntry*)table;
                    for (int i = 0; i < entryCount; i++)
                    {
                        long lineCodeIndex = entryTable[i].StartLocation.Value;
                        LineNumberData line = new LineNumberData(lineCodeIndex, entryTable[i].LineNumber);
                        lineData.Add(line);
                    }
                }

                lines = lineData.ToArray();
                return jvmtiError.None;
            }
            finally
            {
                Deallocate(table);
            }
        }