pub struct Functions {
pub by_address: BTreeMap<u32, Result<Function, DisassembleError>>,
pub unreferenced: BTreeSet<u32>,
pub dangling: BTreeSet<u32>,
}Expand description
The functions found in an image.
Fields§
§by_address: BTreeMap<u32, Result<Function, DisassembleError>>Each function found, by code pool address. An address that was referenced as a function but could not be disassembled maps to the error.
unreferenced: BTreeSet<u32>Functions nothing refers to. They were found because they sit directly after another function, in bytes that are not part of it.
dangling: BTreeSet<u32>Referenced addresses that lie beyond the code the image supplies. Pre-initialization discards static initializer code, which leaves such references behind in the properties that code initialized.
Implementations§
Source§impl Functions
impl Functions
Sourcepub fn functions(&self) -> impl Iterator<Item = &Function>
pub fn functions(&self) -> impl Iterator<Item = &Function>
The functions that disassembled, in address order.
Sourcepub fn errors(&self) -> impl Iterator<Item = (u32, &DisassembleError)>
pub fn errors(&self) -> impl Iterator<Item = (u32, &DisassembleError)>
The addresses that failed to disassemble, with their errors.
Examples found in repository?
examples/coverage.rs (line 26)
9fn main() {
10 for path in std::env::args().skip(1) {
11 let data = std::fs::read(&path).expect("cannot read image");
12 let image = Image::parse(&data).expect("cannot parse image");
13 let listed: BTreeSet<u32> = image.debug.method_headers.iter().copied().collect();
14 let with: BTreeSet<u32> = discover(&image).by_address.keys().copied().collect();
15 let found = discover_without_debug_info(&image);
16 let without: BTreeSet<u32> = found.by_address.keys().copied().collect();
17 let missed: Vec<u32> = listed.difference(&without).copied().collect();
18 let extra: Vec<u32> = without.difference(&listed).copied().collect();
19 println!(
20 "{path}: listed {}, with debug info {}, without {}, missed {}, not listed {}, failures {}",
21 listed.len(),
22 with.len(),
23 without.len(),
24 missed.len(),
25 extra.len(),
26 found.errors().count()
27 );
28 println!(" missed: {:x?}", &missed[..missed.len().min(12)]);
29 println!(" not listed: {:x?}", &extra[..extra.len().min(12)]);
30 }
31}Trait Implementations§
Auto Trait Implementations§
impl Forget for Functions
impl Freeze for Functionswhere
*const LeafNode<u32, Result<Function, DisassembleError>> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(u32, Result<Function, DisassembleError>)>>: Freeze,
*const LeafNode<u32, SetValZST> is !null: Freeze,
PhantomData<Box<(u32, SetValZST)>>: Freeze,
impl Move for Functions
impl RefUnwindSafe for Functions
impl Send for Functions
impl Sync for Functions
impl Unpin for Functions
impl UnsafeUnpin for Functionswhere
*const LeafNode<u32, Result<Function, DisassembleError>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(u32, Result<Function, DisassembleError>)>>: UnsafeUnpin,
*const LeafNode<u32, SetValZST> is !null: UnsafeUnpin,
PhantomData<Box<(u32, SetValZST)>>: UnsafeUnpin,
impl UnwindSafe for Functionswhere
BTreeMap<u32, Result<Function, DisassembleError>>: UnwindSafe,
BTreeMap<u32, SetValZST>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more