Skip to content
jac3km4Public

About

Rust library for reading and writing PDB files

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

pdb-sdk

A pure Rust library for reading and writing Microsoft PDB (Program Database) files, with per-stream access.

Alpha-quality. Requires Rust 1.93+.

Quick start

For a checkout of this repository, add a path dependency to your application's Cargo.toml (adjust the path to your checkout):

[dependencies]
pdb-sdk = { path = "../pdb-sdk" }
use std::fs::File;
use pdb_sdk::PdbFile;

fn main() -> pdb_sdk::result::Result<()> {
    let mut pdb = PdbFile::open(File::open("application.pdb")?)?;
    let info = pdb.get_info()?;
    println!("Features: {:?}", info.features());

    let dbi = pdb.get_dbi()?;
    for module in dbi.modules() {
        println!("Module: {:?}", module.module_name);
    }
    println!("First type: {:?}", pdb.get_tpi()?.records().first());
    Ok(())
}

For a fixture-free builder/readback example, see the executable example in the crate documentation.

Examples

Run cargo run --locked --example <name> from the repository root:

  • read: inspect tests/corpus/clang-lld-x64.pdb.
  • write: create or overwrite custom.pdb.
  • fake_pdb: run with -- <exe_path>. Copies a PE's PDB identity and section headers, but uses hard-coded demonstration symbols and addresses; it does not recover real symbols. Creates or overwrites the .pdb beside the executable with the same base name.

Development

CI tests stable Rust on Linux and Windows, plus Rust 1.93.0 on Linux.

cargo +stable test --locked --all-targets --all-features
cargo +stable test --locked --doc --all-features
cargo +stable clippy --locked --all-targets --all-features -- -D warnings
cargo +stable check --locked --manifest-path fuzz/Cargo.toml
RUSTDOCFLAGS="-D warnings" cargo +stable doc --locked --no-deps --all-features

Doctests run separately. Repeat both test commands with +1.93.0 for MSRV checks.

Use Conventional Commits with concise, imperative descriptions and ! for breaking changes.

Tests and LLVM

Default tests are offline. The corpus guide describes five frozen MSVC/Clang and Microsoft-linker/LLD fixtures, LLVM-derived reference facts, and regeneration. The fuzzing guide covers bounded campaigns and regression retention.

LLVM writer-interoperability tests are ignored by default and run separately in Linux stable CI with LLVM 18:

# Ubuntu 24.04
sudo apt-get update && sudo apt-get install --no-install-recommends -y llvm-18
cargo +stable test --locked --test roundtrip --test writer_interop -- --ignored

Discovery uses llvm-pdbutil or llvm-pdbutil-18 on PATH. LLVM_PDBUTIL overrides it with an executable path; relative paths use the working directory, and spaces are supported. An invalid override or failing --version is an error, not a fallback. Inspection failures report status, stdout, and stderr.

In PowerShell, set $env:LLVM_PDBUTIL to the executable path when needed and $env:RUSTDOCFLAGS = '-D warnings' before cargo doc. Remove session overrides with Remove-Item Env:LLVM_PDBUTIL and Remove-Item Env:RUSTDOCFLAGS afterward.

Formatting

Use the CI-pinned nightly for unstable rustfmt options and LF line endings:

rustup toolchain install nightly-2026-10-15 --profile minimal --component rustfmt --no-self-update
cargo +nightly-2026-10-15 fmt --all -- --check
cargo +nightly-2026-10-15 fmt --manifest-path fuzz/Cargo.toml --all -- --check

About

Rust library for reading and writing PDB files

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages