1 =====================================
3 =====================================
14 This document describes the usage and serialization format of the various
15 CodeView type records that LLVM understands. This document does not describe
16 every single CodeView type record that is defined. In some cases, this is
17 because the records are clearly deprecated and can only appear in very old
18 software (e.g. the 16-bit types). On other cases, it is because the records
19 have never been observed in practice. This could be because they are only
20 generated for non-C++ code (e.g. Visual Basic, C#), or because they have been
21 made obsolete by newer records, or any number of other reasons. However, the
22 records we describe here should cover 99% of type records that one can expect
23 to encounter when dealing with modern C++ toolchains.
28 We can think of a sequence of CodeView type records as an array of variable length
29 `leaf records`. Each such record describes its own length as part of a fixed-size
30 header, as well as the kind of record it is. Leaf records are either padded to 4
31 bytes (if this type stream appears in a TPI/IPI stream of a PDB) or not padded at
32 all (if this type stream appears in the ``.debug$T`` section of an object file).
33 Padding is implemented by inserting a decreasing sequence of `<_padding_records>`
34 that terminates with ``LF_PAD0``.
36 The final category of record is a ``member record``. One particular leaf type --
37 ``LF_FIELDLIST`` -- contains a series of embedded records. While the outer
38 ``LF_FIELDLIST`` describes its length (like any other leaf record), the embedded
39 records -- called ``member records`` do not.
46 All leaf records begin with the following 4 byte prefix:
51 uint16_t RecordLen; // Record length, not including this 2 byte field.
52 uint16_t RecordKind; // Record kind enum.
58 **Usage:** Describes a pointer to another type.
64 .--------------------.-- +0
66 .--------------------.-- +4
68 .--------------------.-- +8
69 | Member Ptr Info | Only present if |Attributes| indicates this is a member pointer.
70 .--------------------.-- +E
72 Attributes is a bitfield with the following layout:
76 .-----------------------------------------------------------------------------------------------------.
77 | Unused | Flags | Size | Modifiers | Mode | Kind |
78 .-----------------------------------------------------------------------------------------------------.
80 0x100 +0x16 +0x13 +0xD +0x8 +0x5 +0x0
82 where the various fields are defined by the following enums:
86 enum class PointerKind : uint8_t {
87 Near16 = 0x00, // 16 bit pointer
88 Far16 = 0x01, // 16:16 far pointer
89 Huge16 = 0x02, // 16:16 huge pointer
90 BasedOnSegment = 0x03, // based on segment
91 BasedOnValue = 0x04, // based on value of base
92 BasedOnSegmentValue = 0x05, // based on segment value of base
93 BasedOnAddress = 0x06, // based on address of base
94 BasedOnSegmentAddress = 0x07, // based on segment address of base
95 BasedOnType = 0x08, // based on type
96 BasedOnSelf = 0x09, // based on self
97 Near32 = 0x0a, // 32 bit pointer
98 Far32 = 0x0b, // 16:32 pointer
99 Near64 = 0x0c // 64 bit pointer
101 enum class PointerMode : uint8_t {
102 Pointer = 0x00, // "normal" pointer
103 LValueReference = 0x01, // "old" reference
104 PointerToDataMember = 0x02, // pointer to data member
105 PointerToMemberFunction = 0x03, // pointer to member function
106 RValueReference = 0x04 // r-value reference
108 enum class PointerModifiers : uint8_t {
109 None = 0x00, // "normal" pointer
110 Flat32 = 0x01, // "flat" pointer
111 Volatile = 0x02, // pointer is marked volatile
112 Const = 0x04, // pointer is marked const
113 Unaligned = 0x08, // pointer is marked unaligned
114 Restrict = 0x10, // pointer is marked restrict
116 enum class PointerFlags : uint8_t {
117 WinRTSmartPointer = 0x01, // pointer is a WinRT smart pointer
118 LValueRefThisPointer = 0x02, // pointer is a 'this' pointer of a member function with ref qualifier (e.g. void X::foo() &)
119 RValueRefThisPointer = 0x04 // pointer is a 'this' pointer of a member function with ref qualifier (e.g. void X::foo() &&)
122 The ``Size`` field of the Attributes bitmask is a 1-byte value indicating the
123 pointer size. For example, a `void*` would have a size of either 4 or 8 depending
124 on the target architecture. On the other hand, if ``Mode`` indicates that this is
125 a pointer to member function or pointer to data member, then the size can be any
126 implementation defined number.
128 The ``Member Ptr Info`` field of the ``LF_POINTER`` record is only present if the
129 attributes indicate that this is a pointer to member.
131 Note that "plain" pointers to primitive types are not represented by ``LF_POINTER``
132 records, they are indicated by special reserved :ref:`TypeIndex values <type_indices>`.
139 LF_PROCEDURE (0x1008)
140 ^^^^^^^^^^^^^^^^^^^^^
142 LF_MFUNCTION (0x1009)
143 ^^^^^^^^^^^^^^^^^^^^^
151 LF_FIELDLIST (0x1203)
152 ^^^^^^^^^^^^^^^^^^^^^
160 LF_STRUCTURE (0x1505)
161 ^^^^^^^^^^^^^^^^^^^^^
163 LF_INTERFACE (0x1519)
164 ^^^^^^^^^^^^^^^^^^^^^
172 LF_TYPESERVER2 (0x1515)
173 ^^^^^^^^^^^^^^^^^^^^^^^
190 LF_BUILDINFO (0x1603)
191 ^^^^^^^^^^^^^^^^^^^^^
193 LF_SUBSTR_LIST (0x1604)
194 ^^^^^^^^^^^^^^^^^^^^^^^
196 LF_STRING_ID (0x1605)
197 ^^^^^^^^^^^^^^^^^^^^^
199 LF_UDT_SRC_LINE (0x1606)
200 ^^^^^^^^^^^^^^^^^^^^^^^^
202 LF_UDT_MOD_SRC_LINE (0x1607)
203 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205 LF_METHODLIST (0x1206)
206 ^^^^^^^^^^^^^^^^^^^^^^
211 LF_ENDPRECOMP (0x0014)
212 ^^^^^^^^^^^^^^^^^^^^^^
222 LF_BINTERFACE (0x151a)
223 ^^^^^^^^^^^^^^^^^^^^^^
246 LF_ONEMETHOD (0x1511)
247 ^^^^^^^^^^^^^^^^^^^^^
249 LF_ENUMERATE (0x1502)
250 ^^^^^^^^^^^^^^^^^^^^^