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