-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPDB_Types.h
162 lines (140 loc) · 4.28 KB
/
PDB_Types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Copyright 2011-2022, Molecular Matters GmbH <[email protected]>
// See LICENSE.txt for licensing details (2-clause BSD License: https://opensource.org/licenses/BSD-2-Clause)
#pragma once
#include "Foundation/PDB_Macros.h"
#include "Foundation/PDB_DisableWarningsPush.h"
#include <cstdint>
#include "Foundation/PDB_DisableWarningsPop.h"
namespace PDB
{
// emulating std::byte from C++17 to make the intention clear that we're dealing with untyped data in certain cases, without actually requiring C++17
enum class Byte : unsigned char {};
// this matches the definition in guiddef.h, but we don't want to pull that in
struct GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
};
static_assert(sizeof(GUID) == 16u, "Size mismatch.");
// this matches the definition in winnt.h, but we don't want to pull that in
struct IMAGE_SECTION_HEADER
{
unsigned char Name[8];
union
{
unsigned long PhysicalAddress;
unsigned long VirtualSize;
} Misc;
unsigned long VirtualAddress;
unsigned long SizeOfRawData;
unsigned long PointerToRawData;
unsigned long PointerToRelocations;
unsigned long PointerToLinenumbers;
unsigned short NumberOfRelocations;
unsigned short NumberOfLinenumbers;
unsigned long Characteristics;
};
static_assert(sizeof(IMAGE_SECTION_HEADER) == 40u, "Size mismatch.");
// https://llvm.org/docs/PDB/MsfFile.html#msf-superblock
struct PDB_NO_DISCARD SuperBlock
{
static const char MAGIC[30u];
char fileMagic[30u];
char padding[2u];
uint32_t blockSize;
uint32_t freeBlockMapIndex; // index of the free block map
uint32_t blockCount; // number of blocks in the file
uint32_t directorySize; // size of the stream directory in bytes
uint32_t unknown;
PDB_FLEXIBLE_ARRAY_MEMBER(uint32_t, directoryBlockIndices); // indices of the blocks that make up the directory indices
};
// https://llvm.org/docs/PDB/PdbStream.html#stream-header
struct Header
{
enum class PDB_NO_DISCARD Version : uint32_t
{
VC2 = 19941610u,
VC4 = 19950623u,
VC41 = 19950814u,
VC50 = 19960307u,
VC98 = 19970604u,
VC70Dep = 19990604u,
VC70 = 20000404u,
VC80 = 20030901u,
VC110 = 20091201u,
VC140 = 20140508u
};
Version version;
uint32_t signature;
uint32_t age;
GUID guid;
};
// https://llvm.org/docs/PDB/PdbStream.html
struct NamedStreamMap
{
uint32_t length;
PDB_FLEXIBLE_ARRAY_MEMBER(char, stringTable);
struct HashTableEntry
{
uint32_t stringTableOffset;
uint32_t streamIndex;
};
};
// https://llvm.org/docs/PDB/HashTable.html
struct SerializedHashTable
{
struct Header
{
uint32_t size;
uint32_t capacity;
};
struct BitVector
{
uint32_t wordCount;
PDB_FLEXIBLE_ARRAY_MEMBER(uint32_t, words);
};
};
// https://llvm.org/docs/PDB/PdbStream.html#pdb-feature-codes
enum class PDB_NO_DISCARD FeatureCode : uint32_t
{
VC110 = 20091201,
VC140 = 20140508,
// https://github.com/microsoft/microsoft-pdb/blob/master/PDB/include/pdbcommon.h#L23
NoTypeMerge = 0x4D544F4E, // "NOTM"
MinimalDebugInfo = 0x494E494D // "MINI", i.e. executable was linked with /DEBUG:FASTLINK
};
// header of the public stream, based on PSGSIHDR defined here:
// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h#L240
struct PublicStreamHeader
{
uint32_t symHash;
uint32_t addrMap;
uint32_t thunkCount;
uint32_t sizeOfThunk;
uint16_t isectThunkTable;
uint16_t padding;
uint32_t offsetThunkTable;
uint16_t sectionCount;
uint16_t padding2;
};
// header of the hash tables used by the public and global symbol stream, based on GSIHashHdr defined here:
// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h#L62
struct HashTableHeader
{
static const uint32_t Signature;
static const uint32_t Version;
uint32_t signature;
uint32_t version;
uint32_t size;
uint32_t bucketCount;
};
// hash record, based on HRFile defined here:
// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h#L8
struct HashRecord
{
uint32_t offset; // offset into the symbol record stream
uint32_t cref;
};
}