Skip to main content

Functions

Struct Functions 

Source
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

Source

pub fn functions(&self) -> impl Iterator<Item = &Function>

The functions that disassembled, in address order.

Source

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§

Source§

impl Clone for Functions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Functions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Functions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Functions

§

impl Freeze for Functions
where *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
where NodeRef<Owned, u32, Result<Function, DisassembleError>, LeafOrInternal>: Send, BoxRaw<(u32, Result<Function, DisassembleError>)>: Send, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Send, BoxRaw<(u32, SetValZST)>: Send,

§

impl Sync for Functions
where NodeRef<Owned, u32, Result<Function, DisassembleError>, LeafOrInternal>: Sync, BoxRaw<(u32, Result<Function, DisassembleError>)>: Sync, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Sync, BoxRaw<(u32, SetValZST)>: Sync,

§

impl Unpin for Functions
where *const LeafNode<u32, Result<Function, DisassembleError>> is !null: Unpin, Box<(u32, Result<Function, DisassembleError>)>: Unpin, *const LeafNode<u32, SetValZST> is !null: Unpin, Box<(u32, SetValZST)>: Unpin,

§

impl UnsafeUnpin for Functions
where *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 Functions

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.