display/
display.rs

1extern crate dwarf;
2
3use std::env;
4use std::path::Path;
5
6fn main() {
7    for file in env::args_os().skip(1) {
8        display(file.as_ref()).unwrap();
9    }
10}
11
12fn display(path: &Path) -> Result<(), dwarf::ReadError> {
13    let sections = try!(dwarf::elf::load(path));
14    let mut units = sections.compilation_units();
15    let mut stdout = std::io::stdout();
16    let mut f = dwarf::display::DefaultFormatter::new(&mut stdout, 4);
17    while let Some(unit) = try!(units.next()) {
18        let abbrev = try!(sections.abbrev(&unit));
19        try!(unit.entries(&abbrev).display_depth(&mut f, 3));
20    }
21    Ok(())
22}