Ejemplo n.º 1
0
        public int GetMethodsInDocument(
            ISymUnmanagedDocument document,
            int bufferLength,
            out int count,
            [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] ISymUnmanagedMethod[] methods)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                count = 0;
                return(HResult.E_INVALIDARG);
            }

            var extentsByMethod = GetMethodMap().GetMethodExtents(symDocument.Handle);

            if (bufferLength > 0)
            {
                int actualCount = Math.Min(extentsByMethod.Length, bufferLength);
                for (int i = 0; i < actualCount; i++)
                {
                    methods[i] = new SymMethod(this, extentsByMethod[i].Method);
                }

                count = actualCount;
            }
            else
            {
                count = extentsByMethod.Length;
            }

            count = 0;
            return(HResult.S_OK);
        }
Ejemplo n.º 2
0
        public int GetMethodByVersion(
            int methodToken,
            int version,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod method)
        {
            if (version != _version)
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            var handle = MetadataTokens.Handle(methodToken);

            if (handle.Kind != HandleKind.MethodDefinition)
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            var methodDefHandle = (MethodDefinitionHandle)handle;

            var methodBody = MetadataReader.GetMethodBody(methodDefHandle);

            if (methodBody.SequencePoints.IsNil)
            {
                // no debug info for the method
                method = null;
                return(HResult.E_FAIL);
            }

            method = new SymMethod(this, methodDefHandle);
            return(HResult.S_OK);
        }
Ejemplo n.º 3
0
        internal ChildScopeData(SymMethod symMethod, ScopeData parent, LocalScopeHandle handle)
            : base(symMethod)
        {
            Debug.Assert(parent != null);
            Debug.Assert(!handle.IsNil);

            _handle = handle;
            _parent = parent;
        }
Ejemplo n.º 4
0
        public int GetMethodsFromDocumentPosition(
            ISymUnmanagedDocument document,
            int line,
            int column,
            int bufferLength,
            out int count,
            [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3), Out] ISymUnmanagedMethod[] methods)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                count = 0;
                return(HResult.E_INVALIDARG);
            }

            var methodExtents      = GetMethodExtents();
            var methodVersionedIds = methodExtents.GetMethodsContainingLine(symDocument.GetId(), line);

            if (methodVersionedIds == null)
            {
                count = 0;
                return(HResult.E_FAIL);
            }

            if (bufferLength > 0)
            {
                int i = 0;

                // diasymreader doesn't order by version, only by token

                foreach (var(methodId, version) in methodVersionedIds.OrderBy(entry => entry.Id))
                {
                    if (i == bufferLength)
                    {
                        break;
                    }

                    var pdbReader = GetReader(version);
                    if (!pdbReader.TryGetMethodHandle(methodId, out var handle))
                    {
                        // Method extents only refer to existing method versions.
                        throw ExceptionUtilities.Unreachable;
                    }

                    methods[i++] = new SymMethod(pdbReader, handle);
                }

                count = i;
            }
            else
            {
                count = methodVersionedIds.Count();
            }

            return(HResult.S_OK);
        }
Ejemplo n.º 5
0
        private int GetMethodImpl(int methodToken, out SymMethod method)
        {
            if (TryGetDebuggableMethod(methodToken, out var pdbReader, out var handle))
            {
                method = new SymMethod(pdbReader, handle);
                return(HResult.S_OK);
            }

            method = null;
            return(HResult.E_FAIL);
        }
Ejemplo n.º 6
0
        public int GetMethodsFromDocumentPosition(
            ISymUnmanagedDocument document,
            int line,
            int column,
            int bufferLength,
            out int count,
            [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3), Out] ISymUnmanagedMethod[] methods)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                count = 0;
                return(HResult.E_INVALIDARG);
            }

            var methodBodyHandles = GetMethodMap().GetMethodsContainingLine(symDocument.Handle, line);

            if (methodBodyHandles == null)
            {
                count = 0;
                return(HResult.E_FAIL);
            }

            if (bufferLength > 0)
            {
                int i = 0;
                foreach (var methodDebugHandle in methodBodyHandles)
                {
                    if (i == bufferLength)
                    {
                        break;
                    }

                    methods[i++] = new SymMethod(this, methodDebugHandle);
                }

                count = i;

                if (i > 1)
                {
                    Array.Sort(methods, 0, i, SymMethod.ByHandleComparer.Default);
                }
            }
            else
            {
                count = methodBodyHandles.Count();
            }

            return(HResult.S_OK);
        }
Ejemplo n.º 7
0
        public int GetMethodFromDocumentPosition(
            ISymUnmanagedDocument document,
            int line,
            int column,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod method)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            var methodExtents = GetMethodExtents();
            var methods       = methodExtents.GetMethodsContainingLine(symDocument.GetId(), line);

            if (methods == null)
            {
                method = null;
                return(HResult.E_FAIL);
            }

            var candidate = default((MethodId Id, int Version));

            foreach (var(methodId, version) in methods)
            {
                if (candidate.Id.IsDefault || methodId < candidate.Id)
                {
                    candidate = (methodId, version);
                }
            }

            if (candidate.Id.IsDefault)
            {
                method = null;
                return(HResult.E_FAIL);
            }

            var pdbReader = GetReader(candidate.Version);

            if (!pdbReader.TryGetMethodHandle(candidate.Id, out var handle))
            {
                method = null;
                return(HResult.E_FAIL);
            }

            method = new SymMethod(pdbReader, handle);
            return(HResult.S_OK);
        }
Ejemplo n.º 8
0
        public int GetMethodsInDocument(
            ISymUnmanagedDocument document,
            int bufferLength,
            out int count,
            [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] ISymUnmanagedMethod[] methods)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                count = 0;
                return(HResult.E_INVALIDARG);
            }

            if (bufferLength > 0 && (methods == null || methods.Length < bufferLength))
            {
                count = 0;
                return(HResult.E_INVALIDARG);
            }

            var methodExtents   = GetMethodExtents();
            var extentsByMethod = methodExtents.GetMethodExtents(symDocument.GetId());

            if (bufferLength > 0)
            {
                var methodMap = GetMethodMap();

                int actualCount = Math.Min(extentsByMethod.Length, bufferLength);
                for (int i = 0; i < actualCount; i++)
                {
                    var info = methodMap.GetInfo(extentsByMethod[i].Method);
                    methods[i] = new SymMethod(GetReader(info.Version), info.Handle);
                }

                count = actualCount;
            }
            else
            {
                count = extentsByMethod.Length;
            }

            return(HResult.S_OK);
        }
Ejemplo n.º 9
0
        public int GetMethodFromDocumentPosition(
            ISymUnmanagedDocument document,
            int line,
            int column,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod method)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            var methodBodyHandles = GetMethodMap().GetMethodsContainingLine(symDocument.Handle, line);

            if (methodBodyHandles == null)
            {
                method = null;
                return(HResult.E_FAIL);
            }

            var comparer  = HandleComparer.Default;
            var candidate = default(MethodDebugInformationHandle);

            foreach (var methodDebugHandle in methodBodyHandles)
            {
                if (candidate.IsNil || comparer.Compare(methodDebugHandle, candidate) < 0)
                {
                    candidate = methodDebugHandle;
                }
            }

            if (candidate.IsNil)
            {
                method = null;
                return(HResult.E_FAIL);
            }

            method = new SymMethod(this, candidate);
            return(HResult.S_OK);
        }
Ejemplo n.º 10
0
        internal int GetMethodSourceExtentInDocument(ISymUnmanagedDocument document, SymMethod method, out int startLine, out int endLine)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                startLine = endLine = 0;
                return(HResult.E_INVALIDARG);
            }

            var map = GetMethodMap();

            if (!map.TryGetMethodSourceExtent(symDocument.Handle, method.DebugHandle, out startLine, out endLine))
            {
                startLine = endLine = 0;
                return(HResult.E_FAIL);
            }

            return(HResult.S_OK);
        }
Ejemplo n.º 11
0
        internal int GetMethodSourceExtentInDocument(ISymUnmanagedDocument document, SymMethod method, out int startLine, out int endLine)
        {
            var symDocument = SymReader.AsSymDocument(document);

            if (symDocument == null)
            {
                startLine = endLine = 0;
                return(HResult.E_INVALIDARG);
            }

            var methodExtents = SymReader.GetMethodExtents();

            if (!methodExtents.TryGetMethodSourceExtent(symDocument.GetId(), method.GetId(), out startLine, out endLine))
            {
                startLine = endLine = 0;
                return(HResult.E_FAIL);
            }

            return(HResult.S_OK);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Get a particular version of a method with specified token.
        /// </summary>
        public int GetMethodByVersion(
            int methodToken,
            int version,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod method)
        {
            if (!IsValidVersion(version))
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            if (!MetadataUtilities.IsMethodToken(methodToken))
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            var pdbReader = GetReader(version);

            if (!pdbReader.TryGetMethodHandle(MethodId.FromToken(methodToken), out var methodDebugHandle))
            {
                method = null;
                return(HResult.E_FAIL);
            }

            var debugInfo = pdbReader.MetadataReader.GetMethodDebugInformation(methodDebugHandle);

            if (debugInfo.SequencePointsBlob.IsNil)
            {
                // no debug info for the method
                method = null;
                return(HResult.E_FAIL);
            }

            method = new SymMethod(pdbReader, methodDebugHandle);
            return(HResult.S_OK);
        }
Ejemplo n.º 13
0
 internal SymVariable(SymMethod symMethod, LocalVariableHandle handle)
 {
     Debug.Assert(symMethod != null);
     _symMethod = symMethod;
     _handle    = handle;
 }
Ejemplo n.º 14
0
 internal RootScopeData(SymMethod symMethod)
     : base(symMethod)
 {
 }
Ejemplo n.º 15
0
 internal ScopeData(SymMethod symMethod)
 {
     Debug.Assert(symMethod != null);
     SymMethod = symMethod;
 }