GithubHelp home page GithubHelp logo

cnguoyj / pdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from getsentry/pdb

0.0 1.0 0.0 1.69 MB

A parser for Microsoft PDB (Program Database) debugging information

Home Page: https://docs.rs/pdb/

License: Apache License 2.0

Makefile 0.12% C++ 0.18% Rust 99.70%

pdb's Introduction

pdb

Build Status

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. pdb does not understand everything about the PDB format, but it does cover enough to be useful for typical programs compiled today.

Design

pdb's design objectives are similar to gimli:

  • pdb works with the original data as it's formatted on-disk as long as possible.

  • pdb parses only what you ask.

  • pdb can read PDBs anywhere. There's no dependency on Windows, on the DIA SDK, or on the target's native byte ordering.

Usage Example

use pdb::FallibleIterator;
use std::fs::File;

fn main() -> pdb::Result<()> {
    let file = File::open("fixtures/self/foo.pdb")?;
    let mut pdb = pdb::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(pdb::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(())
}

Example Programs

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.

License

Licensed under either of

at your option.

Contribution

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.

pdb's People

Contributors

jan-auer avatar willglynn avatar calixteman avatar mitsuhiko avatar rlabrecque avatar luser avatar philipc avatar jrmuizel avatar landaire avatar mcnulty avatar razrfalcon avatar mahkoh avatar qnighy avatar schultetwin1 avatar nbaksalyar avatar ko1n avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.