Crates.io | pdb2 |
lib.rs | pdb2 |
version | 0.9.1 |
source | src |
created_at | 2023-08-01 20:37:17.034198 |
updated_at | 2024-06-05 15:19:20.486385 |
description | A parser for Microsoft PDB (Program Database) debugging information |
homepage | |
repository | https://github.com/afranchuk/pdb |
max_upload_size | |
id | 932197 |
size | 537,308 |
pdb2
This repository is forked from willglynn/pdb and published to
as the pdb2
crate.
This is a Rust library that parses Microsoft PDB (Program Database) files. These files contain debugging information produced by most compilers that target Windows, including information about symbols, types, modules, and so on.
The PDB format is not documented per sé, but Microsoft has published
information in the form of C++
code relating to its use. The PDB format is full of... history, including
support for debugging 16-bit executables, COBOL user-defined types, and myriad
other features. pdb2
does not understand everything about the PDB format,
but it does cover enough to be useful for typical programs compiled today.
pdb2
's design objectives are similar to
gimli
:
pdb2
works with the original data as it's formatted on-disk as long as
possible.
pdb2
parses only what you ask.
pdb2
can read PDBs anywhere. There's no dependency on Windows, on the
DIA SDK, or on
the target's native byte ordering.
use pdb2::FallibleIterator;
use std::fs::File;
fn main() -> pdb2::Result<()> {
let file = File::open("fixtures/self/foo.pdb")?;
let mut pdb = pdb2::PDB::open(file)?;
let symbol_table = pdb.global_symbols()?;
let address_map = pdb.address_map()?;
let mut symbols = symbol_table.iter();
while let Some(symbol) = symbols.next()? {
match symbol.parse() {
Ok(pdb2::SymbolData::Public(data)) if data.function => {
// we found the location of a function!
let rva = data.offset.to_rva(&address_map).unwrap_or_default
println!("{} is {}", rva, data.name);
}
_ => {}
}
}
Ok(())
}
Run with cargo run --release --example <name>
:
pdb_symbols
is a toy program that prints the name and location of every function and
data value defined in the symbol table.
pdb2hpp
is a somewhat larger program that prints an approximation of a C++ header file for
a requested type given only a PDB.
pdb_lines
outputs line number information for every symbol in every module contained in
a PDB.
Real-world examples:
mstange/pdb-addr2line
resolves addresses to function names, and to file name and line number information, with the help of a PDB file. Inline stacks are supported.
getsentry/symbolic
is a high-level symbolication library supporting most common debug file formats, demangling, and more.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.