#debug-information #dwarf #debugging #file-parser #binaries #elf-file

tasru

A method to map and understand dwarf symbol information

6 releases

0.3.1 Mar 13, 2025
0.3.0 Mar 13, 2025
0.2.2 Mar 6, 2025
0.2.0 Feb 7, 2025
0.1.0 Dec 13, 2024

#3 in #debug-info

Download history 125/week @ 2024-12-08 23/week @ 2024-12-15 1/week @ 2025-01-05 116/week @ 2025-02-02 257/week @ 2025-02-09 229/week @ 2025-02-16 48/week @ 2025-02-23 293/week @ 2025-03-02 300/week @ 2025-03-09 101/week @ 2025-03-16

751 downloads per month

Apache-2.0

150KB
3.5K SLoC

Tasru: Map out dwarf binaries

Tasru allows for easy inspection of Elf binaries using Dwarf debug information.

Example usage

let debug_info = tasru::DebugInfo::new("file.elf")?;
let var_value = debug_info.variable_from_demangled_name("package::GLOBAL_VAR")?.base_type().to_u32()?;
println!("Var value: {}", var_value);

lib.rs:

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.

Dependencies

~2–2.9MB
~59K SLoC