internal MethodDebugInformation(MetadataReader reader, MethodDebugInformationHandle handle) { Debug.Assert(reader != null); Debug.Assert(!handle.IsNil); _reader = reader; _rowId = handle.RowId; }
private SourceInformation GetSourceInformation(MethodDebugInformationHandle handle) { SourceInformation sourceInformation = null; try { var methodDebugDefinition = _reader.GetMethodDebugInformation(handle); var fileName = GetMethodFileName(methodDebugDefinition); var lineNumber = GetMethodStartLineNumber(methodDebugDefinition); sourceInformation = new SourceInformation(fileName, lineNumber); } catch (BadImageFormatException) { } return sourceInformation; }
public LocalScopeHandleCollection GetLocalScopes(MethodDebugInformationHandle handle) { return new LocalScopeHandleCollection(this, handle.RowId); }
public MethodDebugInformation GetMethodDebugInformation(MethodDebugInformationHandle handle) { return new MethodDebugInformation(this, handle); }
internal DocumentHandle GetDocument(MethodDebugInformationHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return DocumentHandle.FromRowId(Block.PeekReference(rowOffset + DocumentOffset, _isDocumentRefSmall)); }
internal BlobHandle GetSequencePoints(MethodDebugInformationHandle handle) { int rowOffset = (handle.RowId - 1) * RowSize; return BlobHandle.FromOffset(Block.PeekHeapReference(rowOffset + _sequencePointsOffset, _isBlobHeapRefSizeSmall)); }
/// <summary> /// Maps <see cref="MethodDebugInformationHandle"/> relative to this reader to the corresponding global <see cref="MethodId"/>. /// Null if handles correspond to ids 1:1 (baseline). /// </summary> internal MethodId GetMethodId(MethodDebugInformationHandle handle) { int rowId = MetadataTokens.GetRowNumber(handle); return(_methodHandleToIdMapOpt.IsDefault ? new MethodId(rowId) : _methodHandleToIdMapOpt[rowId - 1]); }
internal bool HasDebugInfo(MethodDebugInformationHandle handle) => !MetadataReader.GetMethodDebugInformation(handle).SequencePointsBlob.IsNil;
// TODO: Copied from PortablePdb. Share. public static AsyncMethodData ReadAsyncMethodData(MetadataReader metadataReader, MethodDebugInformationHandle debugHandle) { var reader = metadataReader; var body = reader.GetMethodDebugInformation(debugHandle); var kickoffMethod = body.GetStateMachineKickoffMethod(); if (kickoffMethod.IsNil) { return(AsyncMethodData.None); } var value = reader.GetCustomDebugInformation(debugHandle.ToDefinitionHandle(), MethodSteppingInformationBlobId); if (value.IsNil) { return(AsyncMethodData.None); } var blobReader = reader.GetBlobReader(value); long catchHandlerOffset = blobReader.ReadUInt32(); if (catchHandlerOffset > (uint)int.MaxValue + 1) { throw new BadImageFormatException(); } var yieldOffsets = ImmutableArray.CreateBuilder <int>(); var resultOffsets = ImmutableArray.CreateBuilder <int>(); var resumeMethods = ImmutableArray.CreateBuilder <int>(); while (blobReader.RemainingBytes > 0) { uint yieldOffset = blobReader.ReadUInt32(); if (yieldOffset > int.MaxValue) { throw new BadImageFormatException(); } uint resultOffset = blobReader.ReadUInt32(); if (resultOffset > int.MaxValue) { throw new BadImageFormatException(); } yieldOffsets.Add((int)yieldOffset); resultOffsets.Add((int)resultOffset); resumeMethods.Add(MethodDefToken(blobReader.ReadCompressedInteger())); } return(new AsyncMethodData( kickoffMethod, (int)(catchHandlerOffset - 1), yieldOffsets.ToImmutable(), resultOffsets.ToImmutable(), resumeMethods.ToImmutable())); }
private bool TryGetDebuggableMethod(int methodToken, out PortablePdbReader pdbReader, out MethodDebugInformationHandle handle) { if (!MetadataUtilities.IsMethodToken(methodToken)) { pdbReader = null; handle = default(MethodDebugInformationHandle); return(false); } var methodId = MethodId.FromToken(methodToken); if (Version == 1) { pdbReader = GetReader(version: 1); if (pdbReader.TryGetMethodHandle(methodId, out handle)) { return(pdbReader.HasDebugInfo(handle)); } } else { var methodMap = GetMethodMap(); if (methodMap.IsValidMethodRowId(methodId.Value)) { var info = methodMap.GetInfo(methodId); pdbReader = GetReader(info.Version); handle = info.Handle; return(pdbReader.HasDebugInfo(handle)); } } pdbReader = null; handle = default(MethodDebugInformationHandle); return(false); }