| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Reflection.Metadata; |
| | | 5 | | |
| | | 6 | | namespace System.Reflection.PortableExecutable |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Identifies the location, size and format of a block of debug information. |
| | | 10 | | /// </summary> |
| | | 11 | | public readonly struct DebugDirectoryEntry |
| | | 12 | | { |
| | | 13 | | internal const int Size = |
| | | 14 | | sizeof(uint) + // Characteristics |
| | | 15 | | sizeof(uint) + // TimeDataStamp |
| | | 16 | | sizeof(uint) + // Version |
| | | 17 | | sizeof(uint) + // Type |
| | | 18 | | sizeof(uint) + // SizeOfData |
| | | 19 | | sizeof(uint) + // AddressOfRawData |
| | | 20 | | sizeof(uint); // PointerToRawData |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// The time and date that the debug data was created if the PE/COFF file is not deterministic, |
| | | 24 | | /// otherwise a value based on the hash of the content. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <remarks> |
| | | 27 | | /// The algorithm used to calculate this value is an implementation |
| | | 28 | | /// detail of the tool that produced the file. |
| | | 29 | | /// </remarks> |
| | 0 | 30 | | public uint Stamp { get; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// The major version number of the debug data format. |
| | | 34 | | /// </summary> |
| | 0 | 35 | | public ushort MajorVersion { get; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// The minor version number of the debug data format. |
| | | 39 | | /// </summary> |
| | 0 | 40 | | public ushort MinorVersion { get; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// The format of debugging information. |
| | | 44 | | /// </summary> |
| | 0 | 45 | | public DebugDirectoryEntryType Type { get; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// The size of the debug data (not including the debug directory itself). |
| | | 49 | | /// </summary> |
| | 0 | 50 | | public int DataSize { get; } |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// The address of the debug data when loaded, relative to the image base. |
| | | 54 | | /// </summary> |
| | 0 | 55 | | public int DataRelativeVirtualAddress { get; } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// The file pointer to the debug data. |
| | | 59 | | /// </summary> |
| | 0 | 60 | | public int DataPointer { get; } |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// True if the entry is a <see cref="DebugDirectoryEntryType.CodeView"/> entry pointing to a Portable PDB. |
| | | 64 | | /// </summary> |
| | 0 | 65 | | public bool IsPortableCodeView => MinorVersion == PortablePdbVersions.PortableCodeViewVersionMagic; |
| | | 66 | | |
| | | 67 | | public DebugDirectoryEntry( |
| | | 68 | | uint stamp, |
| | | 69 | | ushort majorVersion, |
| | | 70 | | ushort minorVersion, |
| | | 71 | | DebugDirectoryEntryType type, |
| | | 72 | | int dataSize, |
| | | 73 | | int dataRelativeVirtualAddress, |
| | | 74 | | int dataPointer) |
| | 0 | 75 | | { |
| | 0 | 76 | | Stamp = stamp; |
| | 0 | 77 | | MajorVersion = majorVersion; |
| | 0 | 78 | | MinorVersion = minorVersion; |
| | 0 | 79 | | Type = type; |
| | 0 | 80 | | DataSize = dataSize; |
| | 0 | 81 | | DataRelativeVirtualAddress = dataRelativeVirtualAddress; |
| | 0 | 82 | | DataPointer = dataPointer; |
| | 0 | 83 | | } |
| | | 84 | | } |
| | | 85 | | } |
| | | 86 | | |