Skip to content

Commit

Permalink
Don't assume PDB's and Dwarf's are well formed.
Browse files Browse the repository at this point in the history
  • Loading branch information
WINSDK committed Apr 19, 2024
1 parent 219caae commit 1c3cca6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion binformat/src/macho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ fn parse_dynamic_table<'data>(
) -> Result<(), object::Error> {
log::complex!(
w "[macho::parse_dynamic_table] ",
y "TODO",
y "Missing an implementation",
w ".",
);
Ok(())
}
Expand Down
22 changes: 18 additions & 4 deletions debugvault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,29 @@ impl Index {

let dwarf = match obj {
#[cfg(target_os = "macos")]
object::File::MachO32(_) | object::File::MachO64(_) => macho_dwarf(obj, path)?,
_ => dwarf::Dwarf::parse(obj)?,
object::File::MachO32(_) | object::File::MachO64(_) => macho_dwarf(obj, path),
_ => dwarf::Dwarf::parse(obj),
};

this.file_attrs.extend(dwarf.file_attrs);
match dwarf {
Ok(dwarf) => this.file_attrs.extend(dwarf.file_attrs),
Err(err) => log::complex!(
w "[dwarf::parse] ",
y format!("Failed to parse dwarf: {err:?}"),
w ".",
)
};

let mut pdb = None;
if let Some(parsed_pdb) = pdb::PDB::parse(obj) {
pdb = Some(parsed_pdb?);
match parsed_pdb {
Ok(parsed_pdb) => pdb = Some(parsed_pdb),
Err(err) => log::complex!(
w "[pdb::parse] ",
y format!("Failed to parse pdb: {err}"),
w ".",
)
};
}

// NOTE: This is a little scuffed. We have to take a `ref mut` here
Expand Down

0 comments on commit 1c3cca6

Please sign in to comment.