LLVM  5.0.0
RawTypes.h
Go to the documentation of this file.
1 //===- RawTypes.h -----------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H
11 #define LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H
12 
15 #include "llvm/Support/Endian.h"
16 
17 namespace llvm {
18 namespace pdb {
19 // This struct is defined as "SO" in langapi/include/pdb.h.
20 struct SectionOffset {
23  char Padding[2];
24 };
25 
26 // This is HRFile.
27 struct PSHashRecord {
28  support::ulittle32_t Off; // Offset in the symbol record stream
30 };
31 
32 // This struct is defined as `SC` in include/dbicommon.h
35  char Padding[2];
40  char Padding2[2];
43 };
44 
45 // This struct is defined as `SC2` in include/dbicommon.h
47  // To guarantee SectionContrib2 is standard layout, we cannot use inheritance.
50 };
51 
52 // This corresponds to the `OMFSegMap` structure.
53 struct SecMapHeader {
54  support::ulittle16_t SecCount; // Number of segment descriptors in table
55  support::ulittle16_t SecCountLog; // Number of logical segment descriptors
56 };
57 
58 // This corresponds to the `OMFSegMapDesc` structure. The definition is not
59 // present in the reference implementation, but the layout is derived from
60 // code that accesses the fields.
61 struct SecMapEntry {
62  support::ulittle16_t Flags; // Descriptor flags. See OMFSegDescFlags
63  support::ulittle16_t Ovl; // Logical overlay number.
64  support::ulittle16_t Group; // Group index into descriptor array.
66  support::ulittle16_t SecName; // Byte index of the segment or group name
67  // in the sstSegName table, or 0xFFFF.
68  support::ulittle16_t ClassName; // Byte index of the class name in the
69  // sstSegName table, or 0xFFFF.
70  support::ulittle32_t Offset; // Byte offset of the logical segment
71  // within the specified physical segment.
72  // If group is set in flags, offset is the
73  // offset of the group.
74  support::ulittle32_t SecByteLength; // Byte count of the segment or group.
75 };
76 
77 /// Some of the values are stored in bitfields. Since this needs to be portable
78 /// across compilers and architectures (big / little endian in particular) we
79 /// can't use the actual structures below, but must instead do the shifting
80 /// and masking ourselves. The struct definitions are provided for reference.
81 struct DbiFlags {
82  /// uint16_t IncrementalLinking : 1; // True if linked incrementally
83  /// uint16_t IsStripped : 1; // True if private symbols were
84  /// stripped.
85  /// uint16_t HasCTypes : 1; // True if linked with /debug:ctypes.
86  /// uint16_t Reserved : 13;
87  static const uint16_t FlagIncrementalMask = 0x0001;
88  static const uint16_t FlagStrippedMask = 0x0002;
89  static const uint16_t FlagHasCTypesMask = 0x0004;
90 };
91 
92 struct DbiBuildNo {
93  /// uint16_t MinorVersion : 8;
94  /// uint16_t MajorVersion : 7;
95  /// uint16_t NewVersionFormat : 1;
96  static const uint16_t BuildMinorMask = 0x00FF;
97  static const uint16_t BuildMinorShift = 0;
98 
99  static const uint16_t BuildMajorMask = 0x7F00;
100  static const uint16_t BuildMajorShift = 8;
101 };
102 
103 /// The fixed size header that appears at the beginning of the DBI Stream.
107 
108  /// How "old" is this DBI Stream. Should match the age of the PDB InfoStream.
110 
111  /// Global symbol stream #
113 
114  /// See DbiBuildNo structure.
116 
117  /// Public symbols stream #
119 
120  /// version of mspdbNNN.dll
122 
123  /// Symbol records stream #
125 
126  /// rbld number of mspdbNNN.dll
128 
129  /// Size of module info stream
131 
132  /// Size of sec. contrib stream
134 
135  /// Size of sec. map substream
137 
138  /// Size of file info substream
140 
141  /// Size of type server map
143 
144  /// Index of MFC Type Server
146 
147  /// Size of DbgHeader info
149 
150  /// Size of EC stream (what is EC?)
152 
153  /// See DbiFlags enum.
155 
156  /// See PDB_MachineType enum.
158 
159  /// Pad to 64 bytes
161 };
162 static_assert(sizeof(DbiStreamHeader) == 64, "Invalid DbiStreamHeader size!");
163 
166  char Padding1[2];
171  char Padding2[2];
174 };
175 
176 /// The header preceeding the File Info Substream of the DBI stream.
178  /// Total # of modules, should match number of records in the ModuleInfo
179  /// substream.
181 
182  /// Total # of source files. This value is not accurate because PDB actually
183  /// supports more than 64k source files, so we ignore it and compute the value
184  /// from other stream fields.
186 
187  /// Following this header the File Info Substream is laid out as follows:
188  /// ulittle16_t ModIndices[NumModules];
189  /// ulittle16_t ModFileCounts[NumModules];
190  /// ulittle32_t FileNameOffsets[NumSourceFiles];
191  /// char Names[][NumSourceFiles];
192  /// with the caveat that `NumSourceFiles` cannot be trusted, so
193  /// it is computed by summing the `ModFileCounts` array.
194 };
195 
196 struct ModInfoFlags {
197  /// uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty
198  /// uint16_t fECEnabled : 1; // Is EC symbolic info present? (What is EC?)
199  /// uint16_t unused : 6; // Reserved
200  /// uint16_t iTSM : 8; // Type Server Index for this module
201  static const uint16_t HasECFlagMask = 0x2;
202 
203  static const uint16_t TypeServerIndexMask = 0xFF00;
204  static const uint16_t TypeServerIndexShift = 8;
205 };
206 
207 /// The header preceeding each entry in the Module Info substream of the DBI
208 /// stream. Corresponds to the type MODI in the reference implementation.
210  /// Currently opened module. This field is a pointer in the reference
211  /// implementation, but that won't work on 64-bit systems, and anyway it
212  /// doesn't make sense to read a pointer from a file. For now it is unused,
213  /// so just ignore it.
215 
216  /// First section contribution of this module.
218 
219  /// See ModInfoFlags definition.
221 
222  /// Stream Number of module debug info
224 
225  /// Size of local symbol debug info in above stream
227 
228  /// Size of C11 line number info in above stream
230 
231  /// Size of C13 line number info in above stream
233 
234  /// Number of files contributing to this module
236 
237  /// Padding so the next field is 4-byte aligned.
238  char Padding1[2];
239 
240  /// Array of [0..NumFiles) DBI name buffer offsets. In the reference
241  /// implementation this field is a pointer. But since you can't portably
242  /// serialize a pointer, on 64-bit platforms they copy all the values except
243  /// this one into the 32-bit version of the struct and use that for
244  /// serialization. Regardless, this field is unused, it is only there to
245  /// store a pointer that can be accessed at runtime.
247 
248  /// Name Index for src file name
250 
251  /// Name Index for path to compiler PDB
253 
254  /// Following this header are two zero terminated strings.
255  /// char ModuleName[];
256  /// char ObjFileName[];
257 };
258 
259 // This is PSGSIHDR struct defined in
260 // https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
267  char Padding[2];
270 };
271 
272 // The header preceeding the global TPI stream.
273 // This corresponds to `HDR` in PDB/dbi/tpi.h.
275  struct EmbeddedBuf {
278  };
279 
285 
286  // The following members correspond to `TpiHash` in PDB/dbi/tpi.h.
291 
295 };
296 
298 const uint32_t MaxTpiHashBuckets = 0x40000;
299 
300 /// The header preceeding the global PDB Stream (Stream 1)
306 };
307 
308 /// The header preceeding the /names stream.
310  support::ulittle32_t Signature; // PDBStringTableSignature
312  support::ulittle32_t ByteSize; // Number of bytes of names buffer.
313 };
314 
316 
317 } // namespace pdb
318 } // namespace llvm
319 
320 #endif
support::little32_t FileInfoSize
Size of file info substream.
Definition: RawTypes.h:139
support::ulittle32_t ByteSize
Definition: RawTypes.h:312
support::ulittle32_t Offset
Definition: RawTypes.h:70
static const uint16_t FlagHasCTypesMask
Definition: RawTypes.h:89
support::ulittle16_t Ovl
Definition: RawTypes.h:63
support::ulittle16_t NumFiles
Number of files contributing to this module.
Definition: RawTypes.h:235
support::ulittle32_t SrcFileNameNI
Name Index for src file name.
Definition: RawTypes.h:249
support::ulittle32_t HashVersion
Definition: RawTypes.h:311
static const uint16_t HasECFlagMask
uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty uint16_t fECEnabled : 1; // Is EC symb...
Definition: RawTypes.h:201
support::little32_t VersionSignature
Definition: RawTypes.h:105
support::ulittle16_t HashStreamIndex
Definition: RawTypes.h:287
EmbeddedBuf IndexOffsetBuffer
Definition: RawTypes.h:293
support::ulittle32_t NumHashBuckets
Definition: RawTypes.h:290
static const uint16_t BuildMinorMask
uint16_t MinorVersion : 8; uint16_t MajorVersion : 7; uint16_t NewVersionFormat : 1; ...
Definition: RawTypes.h:96
support::ulittle32_t Off
Definition: RawTypes.h:21
support::ulittle32_t Version
Definition: RawTypes.h:302
support::ulittle16_t GlobalSymbolStreamIndex
Global symbol stream #.
Definition: RawTypes.h:112
support::ulittle32_t MFCTypeServerIndex
Index of MFC Type Server.
Definition: RawTypes.h:145
support::ulittle32_t SymBytes
Size of local symbol debug info in above stream.
Definition: RawTypes.h:226
support::ulittle16_t Frame
Definition: RawTypes.h:65
support::ulittle32_t DataCrc
Definition: RawTypes.h:172
support::ulittle32_t NumThunks
Definition: RawTypes.h:264
support::ulittle32_t ISectCoff
Definition: RawTypes.h:49
support::ulittle32_t TypeRecordBytes
Definition: RawTypes.h:284
support::ulittle16_t BuildNumber
See DbiBuildNo structure.
Definition: RawTypes.h:115
support::ulittle32_t Characteristics
Definition: RawTypes.h:169
support::little32_t Offset
Definition: RawTypes.h:167
char Padding1[2]
Padding so the next field is 4-byte aligned.
Definition: RawTypes.h:238
support::little32_t TypeServerSize
Size of type server map.
Definition: RawTypes.h:142
support::ulittle32_t Signature
Definition: RawTypes.h:303
support::ulittle32_t SecByteLength
Definition: RawTypes.h:74
support::ulittle16_t ISectThunkTable
Definition: RawTypes.h:266
support::ulittle16_t Group
Definition: RawTypes.h:64
SectionContribEntry SC
First section contribution of this module.
Definition: RawTypes.h:217
support::ulittle32_t CRef
Definition: RawTypes.h:29
support::little32_t SectionMapSize
Size of sec. map substream.
Definition: RawTypes.h:136
support::ulittle16_t Isect
Definition: RawTypes.h:22
support::ulittle32_t PdbFilePathNI
Name Index for path to compiler PDB.
Definition: RawTypes.h:252
This represents the 'GUID' type from windows.h.
Definition: GUID.h:22
support::ulittle16_t ModuleIndex
Definition: RawTypes.h:170
The fixed size header that appears at the beginning of the DBI Stream.
Definition: RawTypes.h:104
support::ulittle32_t Off
Definition: RawTypes.h:28
support::little32_t ECSubstreamSize
Size of EC stream (what is EC?)
Definition: RawTypes.h:151
support::ulittle16_t Flags
See ModInfoFlags definition.
Definition: RawTypes.h:220
The header preceeding the /names stream.
Definition: RawTypes.h:309
support::ulittle32_t SymHash
Definition: RawTypes.h:262
Some of the values are stored in bitfields.
Definition: RawTypes.h:81
support::ulittle32_t C13Bytes
Size of C13 line number info in above stream.
Definition: RawTypes.h:232
support::ulittle32_t RelocCrc
Definition: RawTypes.h:173
support::ulittle16_t PdbDllRbld
rbld number of mspdbNNN.dll
Definition: RawTypes.h:127
support::ulittle32_t Age
Definition: RawTypes.h:304
support::ulittle32_t RelocCrc
Definition: RawTypes.h:42
support::little32_t Size
Definition: RawTypes.h:37
static const uint16_t BuildMajorShift
Definition: RawTypes.h:100
support::ulittle16_t Imod
Definition: RawTypes.h:39
support::ulittle32_t TypeIndexEnd
Definition: RawTypes.h:283
The header preceeding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:209
support::ulittle32_t FileNameOffs
Array of [0..NumFiles) DBI name buffer offsets.
Definition: RawTypes.h:246
support::ulittle32_t Signature
Definition: RawTypes.h:310
static const uint16_t TypeServerIndexShift
Definition: RawTypes.h:204
The header preceeding the File Info Substream of the DBI stream.
Definition: RawTypes.h:177
support::ulittle32_t TypeIndexBegin
Definition: RawTypes.h:282
support::little32_t Off
Definition: RawTypes.h:36
support::ulittle16_t PdbDllVersion
version of mspdbNNN.dll
Definition: RawTypes.h:121
support::ulittle32_t Reserved
Pad to 64 bytes.
Definition: RawTypes.h:160
const uint32_t MinTpiHashBuckets
Definition: RawTypes.h:297
static const uint16_t FlagIncrementalMask
uint16_t IncrementalLinking : 1; // True if linked incrementally uint16_t IsStripped : 1; // True if ...
Definition: RawTypes.h:87
support::little32_t OptionalDbgHdrSize
Size of DbgHeader info.
Definition: RawTypes.h:148
support::ulittle16_t ClassName
Definition: RawTypes.h:68
support::ulittle32_t AddrMap
Definition: RawTypes.h:263
support::ulittle16_t Flags
See DbiFlags enum.
Definition: RawTypes.h:154
support::ulittle16_t Flags
Definition: RawTypes.h:62
support::ulittle16_t ISect
Definition: RawTypes.h:34
support::ulittle32_t Characteristics
Definition: RawTypes.h:38
support::ulittle16_t NumSourceFiles
Total # of source files.
Definition: RawTypes.h:185
support::ulittle32_t Mod
Currently opened module.
Definition: RawTypes.h:214
support::ulittle32_t SizeOfThunk
Definition: RawTypes.h:265
The header preceeding the global PDB Stream (Stream 1)
Definition: RawTypes.h:301
support::ulittle16_t NumModules
Total # of modules, should match number of records in the ModuleInfo substream.
Definition: RawTypes.h:180
EmbeddedBuf HashValueBuffer
Definition: RawTypes.h:292
support::ulittle16_t SecCount
Definition: RawTypes.h:54
static const uint16_t FlagStrippedMask
Definition: RawTypes.h:88
support::ulittle16_t HashAuxStreamIndex
Definition: RawTypes.h:288
support::little32_t ModiSubstreamSize
Size of module info stream.
Definition: RawTypes.h:130
support::little32_t Size
Definition: RawTypes.h:168
support::ulittle32_t OffThunkTable
Definition: RawTypes.h:268
support::ulittle16_t Section
Definition: RawTypes.h:165
support::ulittle16_t ModDiStream
Stream Number of module debug info.
Definition: RawTypes.h:223
SectionContrib Base
Definition: RawTypes.h:48
support::ulittle32_t C11Bytes
Size of C11 line number info in above stream.
Definition: RawTypes.h:229
support::little32_t SecContrSubstreamSize
Size of sec. contrib stream.
Definition: RawTypes.h:133
static const uint16_t BuildMajorMask
Definition: RawTypes.h:99
support::ulittle32_t Age
How "old" is this DBI Stream. Should match the age of the PDB InfoStream.
Definition: RawTypes.h:109
support::ulittle16_t SymRecordStreamIndex
Symbol records stream #.
Definition: RawTypes.h:124
support::ulittle32_t VersionHeader
Definition: RawTypes.h:106
support::ulittle32_t HashKeySize
Definition: RawTypes.h:289
static const uint16_t BuildMinorShift
Definition: RawTypes.h:97
const uint32_t PDBStringTableSignature
Definition: RawTypes.h:315
static const uint16_t TypeServerIndexMask
Definition: RawTypes.h:203
support::ulittle32_t HeaderSize
Definition: RawTypes.h:281
support::ulittle32_t DataCrc
Definition: RawTypes.h:41
support::ulittle32_t Version
Definition: RawTypes.h:280
support::ulittle16_t SecName
Definition: RawTypes.h:66
support::ulittle16_t PublicSymbolStreamIndex
Public symbols stream #.
Definition: RawTypes.h:118
support::ulittle32_t NumSections
Definition: RawTypes.h:269
support::ulittle16_t MachineType
See PDB_MachineType enum.
Definition: RawTypes.h:157
const uint32_t MaxTpiHashBuckets
Definition: RawTypes.h:298
EmbeddedBuf HashAdjBuffer
Definition: RawTypes.h:294
support::ulittle16_t SecCountLog
Definition: RawTypes.h:55