Crate pdb_addr2line[−][src]
Expand description
Resolve addresses to function names, and to file name and line number information, with the help of a PDB file. Inline stacks are supported.
The API of this crate is intended to be similar to the API of the
addr2line
crate; the two Context
APIs
have comparable functionality. This crate is for PDB files whereas addr2line
is for DWARF data (which is used in ELF and mach-o binaries, for example).
This crate also has a TypeFormatter
API which can be used to get function signature
strings independently from a Context
.
To create a Context
, use ContextPdbData
.
Example
use pdb_addr2line::pdb;
fn look_up_addresses<'s, S: pdb::Source<'s> + 's>(stream: S, addresses: &[u32]) -> std::result::Result<(), pdb_addr2line::Error> {
let pdb = pdb::PDB::open(stream)?;
let context_data = pdb_addr2line::ContextPdbData::try_from_pdb(pdb)?;
let context = context_data.make_context()?;
for address in addresses {
if let Some(procedure_frames) = context.find_frames(*address)? {
eprintln!("0x{:x} - {} frames:", address, procedure_frames.frames.len());
for frame in procedure_frames.frames {
let line_str = frame.line.map(|l| format!("{}", l));
eprintln!(
" {} at {}:{}",
frame.function.as_deref().unwrap_or("<unknown>"),
frame.file.as_deref().unwrap_or("??"),
line_str.as_deref().unwrap_or("??"),
)
}
} else {
eprintln!("{:x} - no frames found", address);
}
}
Ok(())
}
Re-exports
pub use maybe_owned;
pub use pdb;
Structs
The main API of this crate. Resolves addresses to function information.
One frame of the inline stack at the looked-up address.
Basic information about a function.
The result of an address lookup from Context::find_frames
.
An iterator over all functions in a Context
.
The order of the fields matters for the lexicographical sort.
Allows printing function signatures, for example for use in stack traces.
Flags for TypeFormatter
.
Enums
Traits
This trait is only needed for consumers who want to call Context::new_from_parts manually, instead of using ContextPdbData. If you use ContextPdbData you do not need to worry about thsi. This trait allows Context to request parsing of module info on-demand. It also does some lifetime acrobatics so that Context can cache objects which have a lifetime dependency on the module info.