Format:CodeView
| Developer | Microsoft |
|---|---|
| Platforms | Platform:Microsoft Visual C++ ABI |
| Versions | C11 (signature 2, VC 5.x), C13 (signature 4, VC 7.0 and later) |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
Microsoft's debug record format, used inside PDB files (module, symbol record, TPI and IPI streams) and in the .debug$S and .debug$T sections of COFF object files: symbol records (uint16 length, uint16 S_* kind), type records (uint16 length, uint16 LF_* leaf) indexed from 0x1000, and in C13 (signature 4) a .debug$S section of subsections (symbols 0xF1, lines 0xF2, string table 0xF3, file checksums 0xF4, ...).
Overview
CodeView started as the debug format of Microsoft's CodeView debugger and lives on as the record format of every MSVC, clang-cl and lld-link build: the compiler writes it into COFF objects, the linker merges it into a Format:PDB (Program Database). The reference definitions are include/cvinfo.h and include/cvconst.h of microsoft/microsoft-pdb.
Records
Every record is uint16 length (bytes after this field) + uint16 kind + data, so a reader can skip unknown kinds. Symbol kinds are S_* (0x1101 S_OBJNAME, 0x1110 S_GPROC32, 0x110E S_PUB32, 0x113C S_COMPILE3, 0x1147 S_GPROC32_ID, 0x114D S_INLINESITE ...), type leaves LF_* (0x1002 LF_POINTER, 0x1008 LF_PROCEDURE, 0x1009 LF_MFUNCTION, 0x1201 LF_ARGLIST, 0x1203 LF_FIELDLIST, 0x1505 LF_STRUCTURE, 0x1601 LF_FUNC_ID ...). Type indexes below 0x1000 are built-in primitive types; record n of a type stream has index 0x1000 + n. Since VC 7.0 names are NUL-terminated (earlier _ST kinds used length-prefixed names). Fact:CodeView/enum/Symbol record kinds, Fact:CodeView/enum/Type leaf kinds
In the full PDBs checked, the most frequent symbols in module streams were S_INLINESITE / S_INLINESITE_END (0x114D/0x114E), S_LOCAL (0x113E), S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE (0x1144) and S_DEFRANGE_REGISTER (0x1141), S_CALLSITEINFO (0x1139), S_END (0x0006) and S_FRAMEPROC (0x1012); procedures are S_GPROC32_ID/S_LPROC32_ID (0x1147/0x1146) in objects and become S_GPROC32/S_LPROC32 in the PDB, with ids resolved to types.
Object files (.debug$S, .debug$T)
.debug$Sstarts with the uint32 signature 4 (CV_SIGNATURE_C13), then subsectionsuint32 type; uint32 length; data, each padded to 4 bytes. Types: 0xF1 symbols, 0xF2 lines, 0xF3 string table, 0xF4 file checksums, 0xF5 frame data, 0xF6 inlinee lines, 0xF7/0xF8 cross-scope imports/exports, 0xF9 IL lines, 0xFA/0xFB metadata token maps, 0xFC merged assembly input, 0xFD COFF symbol RVA; bit 31 set (DEBUG_S_IGNORE) means skip. Fact:CodeView/enum/Debug subsection types.debug$Tstarts with the same signature followed by type records; with/Ziit holds only an LF_TYPESERVER2 (0x1515) record naming the compiler PDB (vc140.pdb), with/Z7the types themselves..debug$Pholds precompiled-header types.- Every MSVC object checked (about 1,000 /bigobj objects from MSVC 19.44) had a
.debug$Swith signature 4 and a symbols subsection holding S_OBJNAME (uint32 signature, object path) and S_COMPILE3 even though they were built without debug information, so the compiler version survives in objects and static libraries. Fact:CodeView/struct/S COMPILE3
PDB module streams use the same layout: signature 4, the module's symbols, then C13 subsections (lines 0xF2, file checksums 0xF4, inlinee lines 0xF6 and cross-scope 0xF7/0xF8 in the PDBs checked).
S_COMPILE3
uint32 flags (bits 0-7 language: 0 C, 1 C++, 3 MASM, 7 linker, 8 CVTRES, 0x0A C#; then EC, no-debug-info, LTCG, /GS, /hotpatch, /sdl, PGO flags), uint16 machine (CV_CFL_*: 0x03 80386, 0xD0 x64, 0xF6 ARM64), four uint16 front-end version numbers, four back-end version numbers, NUL-terminated compiler name (Microsoft (R) Optimizing Compiler). The objects checked had language 1, machine 0xD0 and versions 19.44.35229.0.
Code & repositories
- pdbinfo (Python) — Reads a native Microsoft PDB (MSF 7.00) with the standard library only: superblock, stream directory, PDB info stream (version, GUID, age, named streams, feature codes, symbol-server key), DBI…
- cvobj (Python) — Lists the CodeView content of COFF object files (normal and /bigobj): .debug$S signature and subsection types, S_OBJNAME and S_COMPILE3 (language, machine, front/back-end versions, compiler name)…
- https://github.com/microsoft/microsoft-pdb @
805655a28bd8198004be2ac27e6e0290121a5e89· license: MIT (declared by the contributor; GitHub's detector did not recognize LICENSE)
Microsoft's published source of the PDB writer/reader (mspdb: MSF container in PDB/msf, PDB/DBI/TPI streams in PDB/dbi), the CodeView record definitions include/cvinfo.h and cvconst.h, and cvdump. Archived 2023; it does not build on its own, but it is the primary reference for every on-disk structure.
Tested on: Read at the pinned commit; its MSF, PDB info, DBI, TPI and CodeView layouts were checked with a Python reader against 58 native PDBs (MSVC toolsets 14.00-14.51) and about 1,000 MSVC 19.44 object files. · checked 2026-10-17; archived; last activity 2023-04-27
Evidence & references
- microsoft/microsoft-pdb (MIT) at commit 805655a28bd8198004be2ac27e6e0290121a5e89: include/cvinfo.h 85-86 (signatures), 784-931 (leaf kinds), 2741-2981 (symbol kinds), 3341-3370 (COMPILESYM3), 3696-3703 (PUBSYM32), 4577-4593 (subsection types); include/cvconst.h 301-311 (languages) and 328-388 (machines).
- Runtime tests: the PDB survey on Format:PDB (Program Database); an object-file scan of about 1,000 MSVC objects (signature, subsection and symbol kinds, S_COMPILE3 fields).