Crate pdb

Source
Expand description

The pdb create parses Microsoft PDB (Program Database) files. PDB files contain debugging information produced by most compilers that target Windows, including information about symbols, types, modules, and so on.

§Usage

PDB files are accessed via the pdb::PDB object.

§Example

let file = std::fs::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);
        }
        _ => {}
    }
}

Re-exports§

pub use fallible_iterator::FallibleIterator;

Structs§

AddressMap
A mapping between addresses and offsets used in the PDB and PE file.
AnnotationReferenceSymbol
Reference to an annotation.
ArgumentList
The information parsed from a type record with kind LF_ARGLIST.
ArrayType
The information parsed from a type record with kind LF_ARRAY, LF_ARRAY_ST or LF_STRIDED_ARRAY.
BaseClassType
The information parsed from a type record with kind LF_BCLASS or LF_BINTERFACE.
BinaryAnnotations
Binary annotations of a symbol.
BinaryAnnotationsIter
An iterator over binary annotations used by S_INLINESITE.
BitfieldType
The information parsed from a type record with kind LF_BITFIELD.
BlockSymbol
A block symbol.
BuildInfoId
Tool, version and command line build information.
BuildInfoSymbol
Reference to build information.
ClassType
The information parsed from a type record with kind LF_CLASS, LF_CLASS_ST, LF_STRUCTURE, LF_STRUCTURE_ST or LF_INTERFACE.
CompileFlags
Compile flags declared in CompileFlagsSymbol.
CompileFlagsSymbol
Flags used to compile a module.
CompilerVersion
A version number refered to by CompileFlagsSymbol.
ConstantSymbol
A constant value.
CrossModuleExportIter
Iterator returned by CrossModuleExports::exports.
CrossModuleExports
A table of exports declared by this module.
CrossModuleImports
Provides efficient access to imported types and IDs from other modules.
CrossModuleRef
Reference to a local type or id in another module.
DBISectionContribution
Information about a module’s contribution to a section. struct SC in Microsoft’s code: https://github.com/Microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/PDB/include/dbicommon.h#L42
DBISectionContributionIter
A DBISectionContributionIter iterates over the section contributions in the DBI section, producing DBISectionContributions.
DataReferenceSymbol
Reference to an imported variable.
DataSymbol
Static data, such as a global variable.
DebugInformation
Provides access to the “DBI” stream inside the PDB.
EnumerateType
The information parsed from a type record with kind LF_ENUMERATE or LF_ENUMERATE_ST.
EnumerationType
The information parsed from a type record with kind LF_ENUM or LF_ENUM_ST.
ExportSymbol
An exported symbol.
ExportSymbolFlags
Flags of an ExportSymbol.
FieldAttributes
FieldList
The information parsed from a type record with kind LF_FIELDLIST.
FileIndex
Index of a file entry in the module.
FileInfo
Information record on a source file.
FileIterator
An iterator over file records in a module.
FrameData
Frame data for a code block.
FrameDataIter
Iterator over entries in a FrameTable.
FrameTable
Describes stack frame layout of functions.
FunctionAttributes
FunctionId
Global function, usually inlined.
IdIndex
Index of an Id in IdInformation stream.
ImageSectionHeader
A PE IMAGE_SECTION_HEADER, as described in the Microsoft documentation.
InlineSiteSymbol
The callsite of an inlined function.
Inlinee
An inlined function that can evaluate to line information.
InlineeIterator
An iterator over line information records in a module.
InlineeLineIterator
An iterator over line information records in a module.
Item
Represents an entry in the type or id stream.
ItemFinder
In-memory index for efficient random-access to Items by index.
ItemInformation
Zero-copy access to a PDB type or id stream.
ItemIter
An iterator over items in TypeInformation or IdInformation.
LabelSymbol
A label symbol.
LineInfo
Mapping of a source code offset to a source file location.
LineIterator
An iterator over line information records in a module.
LineProgram
The LineProgram provides access to source line information for a module and its procedures.
Local
An ItemIndex that is local to a module.
LocalSymbol
A local symbol in optimized code.
LocalVariableFlags
Flags for a LocalSymbol.
MemberFunctionId
Member function, usually inlined.
MemberFunctionType
The information parsed from a type record with kind LF_MFUNCTION.
MemberType
The information parsed from a type record with kind LF_MEMBER or LF_MEMBER_ST.
MethodList
The information parsed from a type record with kind LF_METHODLIST.
MethodListEntry
An entry in a MethodList.
MethodType
The information parsed from a type record with kind LF_ONEMETHOD or LF_ONEMETHOD_ST.
ModifierType
The information parsed from a type record with kind LF_MODIFIER.
Module
Represents a module from the DBI stream.
ModuleInfo
This struct contains data about a single module from its module info stream.
ModuleIter
A ModuleIter iterates over the modules in the DBI section, producing Modules.
ModuleRef
Named reference to a Module.
MultiRegisterVariableSymbol
A Register variable spanning multiple registers.
NestedType
The information parsed from a type record with kind LF_NESTTYPE, LF_NESTTYPE_ST, LF_NESTTYPEEX, or LF_NESTTYPEEX_ST.
ObjNameSymbol
Name of the object file of this module.
OverloadedMethodType
The information parsed from a type record with kind LF_METHOD or LF_METHOD_ST.
PDB
PDB provides access to the data within a PDB file.
PDBInformation
A PDB info stream header parsed from a stream.
PdbInternalRva
A Relative Virtual Address in an unoptimized PE file.
PdbInternalRvaRangeIter
Iterator over PdbInternalRva ranges returned by AddressMap::internal_rva_ranges.
PdbInternalSectionOffset
An offset relative to a PE section in the original unoptimized binary.
PointerAttributes
PointerType
The information parsed from a type record with kind LF_POINTER.
PrimitiveType
Represents a primitive type like void or char *.
ProcedureFlags
Flags of a ProcedureSymbol.
ProcedureReferenceSymbol
Reference to an imported procedure.
ProcedureSymbol
A procedure, such as a function or method.
ProcedureType
The information parsed from a type record with kind LF_PROCEDURE.
PublicSymbol
A public symbol with a mangled name.
RawString
RawString refers to a &[u8] that physically resides somewhere inside a PDB data structure.
Register
A register referred to by its number.
RegisterRelativeSymbol
A register relative symbol.
RegisterVariableSymbol
A Register variable.
Rva
A Relative Virtual Address as it appears in a PE file.
RvaRangeIter
Iterator over Rva ranges returned by AddressMap::rva_ranges.
SectionCharacteristics
Characteristic flags of an ImageSectionHeader.
SectionOffset
An offset relative to a PE section.
SeparatedCodeFlags
Flags for a SeparatedCodeSymbol.
SeparatedCodeSymbol
A separated code symbol.
SourceSlice
Represents an offset + size of the source file.
StaticMemberType
The information parsed from a type record with kind LF_STMEMBER or LF_STMEMBER_ST.
StreamIndex
Index of a PDB stream.
StreamName
A named stream contained within the PDB file.
StreamNames
A list of named streams contained within the PDB file.
StringId
A string.
StringListId
A list of substrings.
StringRef
A reference to a string in the string table.
StringTable
The global string table of a PDB.
Symbol
Represents a symbol from the symbol table.
SymbolIndex
A reference into the symbol table of a module.
SymbolIter
A SymbolIter iterates over a SymbolTable, producing Symbols.
SymbolTable
PDB symbol tables contain names, locations, and metadata about functions, global/static data, constants, data types, and more.
ThreadStorageSymbol
A thread local variable.
ThunkAdjustor
Thunk adjustor
ThunkSymbol
A thunk symbol.
TrampolineSymbol
Trampoline thunk.
TypeIndex
Index of TypeData in the TypeInformation stream.
TypeProperties
UnionType
The information parsed from a type record with kind LF_UNION or LF_UNION_ST.
UserDefinedTypeSourceId
Source and line of the definition of a User Defined Type (UDT).
UserDefinedTypeSymbol
A user defined type.
UsingNamespaceSymbol
A using namespace directive.
VirtualBaseClassType
The information parsed from a type record with kind LF_VBCLASS or LF_IVBCLASS.
VirtualFunctionTablePointerType
The information parsed from a type record with kind LF_VFUNCTAB.

Enums§

BinaryAnnotation
Represents a parsed BinaryAnnotation.
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented on MSDN.
ClassKind
Used by ClassType to distinguish class-like concepts.
CrossModuleExport
A cross module export that can either be a Type or an Id.
Error
An error that occurred while reading or parsing the PDB.
FileChecksum
Checksum of a source file’s contents.
FrameType
A compiler specific frame type.
HeaderVersion
The version of the PDB format.
IdData
Encapsulates parsed data about an Id.
Indirection
Pointer mode of primitive types.
LineInfoKind
The kind of source construct a line info is referring to.
MachineType
The target machine’s architecture. Reference: https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format#machine-types
PointerKind
The kind of a PointerType.
PointerMode
The mode of a PointerType.
PrimitiveKind
A simple type.
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration, and are documented on MSDN.
SymbolData
Information parsed from a Symbol record.
ThunkKind
A thunk kind
TrampolineType
Subtype of TrampolineSymbol.
TypeData
Encapsulates parsed data about a Type.
UserDefinedTypeSourceFileRef
A reference to the source file name of a UserDefinedTypeSourceId.
Variant
Value of an enumerate type.

Traits§

ItemIndex
An index into either the TypeInformation or IdInformation stream.
Source
The pdb crate accesses PDB files via the pdb::Source trait.
SourceView
An owned, droppable, read-only view of the source file which can be referenced as a byte slice.

Type Aliases§

Id
Information on an inline function, build infos or source references.
IdFinder
In-memory index for efficient random-access of Ids by index.
IdInformation
Zero-copy access to the PDB type stream (TPI).
IdIter
An iterator over Ids returned by IdInformation::iter.
NameIter
An iterator over StreamNames.
Result
The result type returned by this crate.
SymbolKind
The raw type discriminator for Symbols.
Type
Information on a primitive type, class, or procedure.
TypeFinder
In-memory index for efficient random-access of Types by index.
TypeInformation
Zero-copy access to the PDB type stream (TPI).
TypeIter
An iterator over Types returned by TypeInformation::iter.