PDB

Struct PDB 

Source
pub struct PDB<'s, S> { /* private fields */ }
Expand description

PDB provides access to the data within a PDB file.

A PDB file is internally a Multi-Stream File (MSF), composed of multiple independent (and usually discontiguous) data streams on-disk. PDB provides lazy access to these data structures, which means the PDB accessor methods usually cause disk accesses.

Implementations§

Source§

impl<'s, S: Source<'s> + 's> PDB<'s, S>

Source

pub fn open(source: S) -> Result<PDB<'s, S>>

Create a new PDB for a Source.

open() accesses enough of the source file to find the MSF stream table. This usually involves reading the header, a block near the end of the file, and finally the stream table itself. It does not access or validate any of the contents of the rest of the PDB.

§Errors
  • Error::UnimplementedFeature if the PDB file predates ~2002
  • Error::UnrecognizedFileFormat if the Source does not appear to be a PDB file
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange, Error::InvalidPageSize if the PDB file seems corrupt
Source

pub fn pdb_information(&mut self) -> Result<PDBInformation<'s>>

Retrieve the PDBInformation for this PDB.

The PDBInformation object contains the GUID and age fields that can be used to verify that a PDB file matches a binary, as well as the stream indicies of named PDB streams.

§Errors
  • Error::StreamNotFound if the PDB somehow does not contain the PDB information stream
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange if the PDB file seems corrupt
Source

pub fn type_information(&mut self) -> Result<TypeInformation<'s>>

Retrieve the TypeInformation for this PDB.

The TypeInformation object owns a SourceView for the type information (“TPI”) stream. This is usually the single largest stream of the PDB file.

§Errors
  • Error::StreamNotFound if the PDB somehow does not contain the type information stream
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange if the PDB file seems corrupt
  • Error::InvalidTypeInformationHeader if the type information stream header was not understood
Source

pub fn debug_information(&mut self) -> Result<DebugInformation<'s>>

Retrieve the DebugInformation for this PDB.

The DebugInformation object owns a SourceView for the debug information (“DBI”) stream.

§Errors
  • Error::StreamNotFound if the PDB somehow does not contain a symbol records stream
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange if the PDB file seems corrupt
  • Error::UnimplementedFeature if the debug information header predates ~1995
Source

pub fn global_symbols(&mut self) -> Result<SymbolTable<'s>>

Retrieve the global symbol table for this PDB.

The SymbolTable object owns a SourceView for the symbol records stream. This is usually the second-largest stream of the PDB file.

The debug information stream indicates which stream is the symbol records stream, so global_symbols() accesses the debug information stream to read the header unless debug_information() was called first.

§Errors
  • Error::StreamNotFound if the PDB somehow does not contain a symbol records stream
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange if the PDB file seems corrupt

If debug_information() was not already called, global_symbols() will additionally read the debug information header, in which case it can also return:

  • Error::StreamNotFound if the PDB somehow does not contain a debug information stream
  • Error::UnimplementedFeature if the debug information header predates ~1995
Source

pub fn module_info<'m>(&mut self, module: &Module<'m>) -> Result<ModuleInfo<'s>>

Retrieve the module info stream for a specific Module.

Some information for each module is stored in a separate stream per-module. Modules can be retrieved from the PDB by first calling debug_information to get the debug information stream, and then calling modules on that.

§Errors
  • Error::StreamNotFound if the PDB does not contain this module info stream
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange if the PDB file seems corrupt
  • Error::UnimplementedFeature if the module information stream is an unsupported version
§Example
let file = std::fs::File::open("fixtures/self/foo.pdb")?;
let mut pdb = pdb::PDB::open(file)?;
let dbi = pdb.debug_information()?;
let mut modules = dbi.modules()?;
if let Some(module) = modules.next()? {
    println!("module name: {}, object file name: {}",
             module.module_name(), module.object_file_name());
    let info = pdb.module_info(&module)?;
    println!("contains {} symbols", info.symbols()?.count()?);
}
Source

pub fn raw_stream(&mut self, stream: u32) -> Result<Stream<'s>>

Retrieve a stream by its index to read its contents as bytes.

§Errors
  • Error::StreamNotFound if the PDB does not contain this module info stream
  • Error::IoError if returned by the Source
  • Error::PageReferenceOutOfRange if the PDB file seems corrupt
§Example
let file = std::fs::File::open("fixtures/self/foo.pdb")?;
let mut pdb = pdb::PDB::open(file)?;
// This is the index of the "mystream" stream that was added using pdbstr.exe.
let s = pdb.raw_stream(208)?;
let mut buf = s.parse_buffer();
let len = buf.len();
let bytes = buf.take(len)?;
assert_eq!(bytes, b"hello world\n");
Source

pub fn named_stream(&mut self, name: &[u8]) -> Result<Stream<'s>>

Trait Implementations§

Source§

impl<'s, S: Debug> Debug for PDB<'s, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s, S> Freeze for PDB<'s, S>

§

impl<'s, S> !RefUnwindSafe for PDB<'s, S>

§

impl<'s, S> !Send for PDB<'s, S>

§

impl<'s, S> !Sync for PDB<'s, S>

§

impl<'s, S> Unpin for PDB<'s, S>

§

impl<'s, S> !UnwindSafe for PDB<'s, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.