Introduction
A .pdb file holds the debug information for a Windows program or library:
the names and types of its functions and variables and the source line for each piece of
code. The linker in Microsoft
Visual Studio writes it beside the PE32 or PE32+
file, and the program records the PDB’s name and a matching GUID, so a debugger can find
the right one, even on a symbol server.
The extension has other uses. Chemistry software uses .pdb for Protein
Data Bank structures, which are text files, and Palm OS used it for its databases.
Structure
A modern PDB file is a small file system called MSF (multi-stream format). The file is
divided into fixed-size blocks, usually 4096 bytes. The first block is the superblock:
the 32-byte magic Microsoft C/C++ MSF 7.00\r\n\x1ADS\0\0\0, then the block
size, the number of blocks and the location of the stream directory. The directory lists
the streams in the file and which blocks each one occupies, so a stream’s blocks need
not be next to each other.
The streams are numbered. Stream 1 holds the PDB’s version, age and GUID; stream 2 the type information; stream 3 the debug information about each compiled module and its source lines; stream 4 the IDs of functions and other items. Further streams are found by name or through the debug information stream.
The reference pages give the MSF container (superblock, free block maps, stream directory), every stream and its headers, the CodeView type records and the CodeView symbol records with the line-number subsections.
0superblock: magic, block size, block counts, directory locationblock 0…free block mapsblocks 1 and 2…stream directory: stream sizes and their block numbersvaries…streams: PDB info, types, debug info, IDs, symbols, namesvaries
Not described
Known, not yet covered
- Reference: the layouts of the
S_DEFRANGE*symbols and thread-data symbols, the/LinkInfostream, the type-server map, the EC substream, the global-refs substream and thunk ordinals, which Microsoft’smicrosoft-pdbheaders define; they would go on the symbols and streams pages. - Viewer: there is no viewer for PDB files yet, so the MSF blocks and streams are not decoded or shown.
Also used for
- Portable PDB (.NET) – .NET debug information stored as metadata tables with a #Pdb stream.
Other formats that use .pdb
- Portable PDB (.NET) – a different format that also uses
.pdb: .NET debug information as metadata tables, startingBSJB; the explorer reads it
Links
Software
- Visual Studio – Microsoft’s development environment, whose linker writes PDB files and whose debugger reads them (Windows)
- WinDbg – Microsoft’s debugger for programs, drivers and crash dumps (Windows)
- LLVM – compiler toolkit whose
llvm-pdbutildumps PDB files (Windows, macOS, Linux) - Ghidra – the NSA’s free reverse engineering suite, which loads PDB symbols (Windows, macOS, Linux)
- IDA Pro – commercial disassembler and decompiler (Windows, macOS, Linux)
- x64dbg – free debugger for Windows programs (Windows)
Developers
- Debug Interface Access SDK – Microsoft’s COM library for reading PDB files (C++)
- pdb – crate that reads PDB files (Rust)
Reference
- The PDB File Format – LLVM’s description of the MSF container and its streams
- microsoft-pdb – source code Microsoft published to help other compilers write PDB files