Expand description
Tasru: Parse Dwarf information from Elf files
Tasru allows you to easily traverse Dwarf information stored within Elf files. This can be used within a debugger to read complex data structures in a live environment, or to perform forensics on a captured image.
Example:
/// Returns the address as a value, unless `resolve` is `false`
/// in which case it returns `0`. Useful for testing memory operations.
struct FakeReader {
resolve: bool,
}
impl tasru::memory::Read for FakeReader {
type Error = std::io::Error; // Unused in this example
fn read_u8(&mut self, address: u64) -> Result<u8, Self::Error> {
if self.resolve {
Ok(address as u8 + 8)
} else {
Ok(0)
}
}
}
// Read the elf file `example.elf`
let debug_info = tasru::DebugInfo::new(&"example.elf").expect("couldn't open example");
// Extract information on the static variable `example::ENUM`
let example_enum = debug_info.variable_from_demangled_name("example::ENUM").expect("couldn't find variable");
// Turn it into an enum (if it is one)
let example_enum = example_enum.enumeration().expect("variable isn't an enum");
// Get the current variant.
let variant = example_enum.variant(&mut FakeReader { resolve: true }).expect("couldn't determine variant");
println!("Variant is: {}", variant.name());Most of the functionality in this crate comes from DebugInfo.
Modules§
- debug_
types - extract
- memory
- Memory traits can be used to read or write data in a given target. This data may be live (for example communicating with a target via a debugger or an emulator), or may be at-rest (for example querying an .ihex image of a running device).
- unit_
info
Structs§
- Debug
Info - A collection of parsed Dwarf information for all compilation units within the specified Elf file. This structure can be queried and will automatically find links with all units.