[][src]Struct p8n_types::Function

pub struct Function {
    pub name: Str,
    pub names: Names,
    pub strings: Strings,
    pub segments: Segments,
    // some fields omitted
}

A single function in the binary.

A function is a set of basic blocks, with one serving as an entry point. Basic blocks form a control flow graph.

Each function also has a user-changeable name and a unchangeable uuid.

Fields

name: Str

Canonical name of the function. Can be anything.

names: Names

Table mapping SSA variable names to integers.

strings: Strings

Table mapping strings to integers.

segments: Segments

Table mapping segments identifiers to integers.

Methods

impl Function[src]

pub fn new<A: Architecture>(
    init: A::Configuration,
    start: u64,
    region: &Region,
    uuid: UUID
) -> Result<Function>
[src]

Creates a new function by disassembling from region starting at start.

pub fn known_cflow_graph<A>(
    init: A::Configuration,
    names: Names,
    cfg: Vec<(Range<u64>, SmallVec<[(Value, Guard); 2]>)>,
    entry: u64,
    region: &Region,
    uuid: UUID,
    name: String
) -> Result<Function> where
    A: Architecture
[src]

Disassemble a function with known control flow graph.

pub fn extend<A: Architecture>(
    &mut self,
    init: A::Configuration,
    region: &Region
) -> Result<()>
[src]

Continues disassembling of region. The function looks for resolved, indirect control flow edges.

pub fn entry_point(&self) -> BasicBlockIndex[src]

Function entry point.

Important traits for MnemonicIterator<'a>
pub fn mnemonics<'a, Idx: IntoMnemonicRange + Sized>(
    &'a self,
    idx: Idx
) -> MnemonicIterator<'a>
[src]

Iterator over all mnemonics in basic block idx.

Important traits for BasicBlockIterator<'a>
pub fn basic_blocks<'a>(&'a self) -> BasicBlockIterator<'a>[src]

Iterator over all basic blocks in reverse post order.

pub fn cflow_graph<'a>(&'a self) -> &'a Graph<CfgNode, Guard>[src]

The Functions control flow graph.

pub fn basic_block<'a>(&'a self, idx: BasicBlockIndex) -> &'a BasicBlock[src]

Returns a reference to the basic block idx.

pub fn mnemonic<'a>(&'a self, idx: MnemonicIndex) -> &'a Mnemonic[src]

Returns a reference to the mnemonic idx.

pub fn uuid<'a>(&'a self) -> &'a UUID[src]

The functions uuid.

pub fn region<'a>(&'a self) -> &'a UUID[src]

The functions region.

pub fn statements<'a, Idx: IntoStatementRange + Sized>(
    &'a self,
    rgn: Idx
) -> StatementsIter<'a>
[src]

Iterator over all IL statements in rgn.

pub fn first_address(&self) -> u64[src]

Lowest address occupied by a basic block. Not neccecarly the entry point.

pub fn entry_address(&self) -> u64[src]

First address of the functions entry basic block.

pub fn indirect_jumps<'a>(&'a self) -> IndirectJumps<'a>[src]

Iterator over all indirect, unresolved jumps.

pub fn cflow_graph_mut<'a>(&'a mut self) -> &'a mut Graph<CfgNode, Guard>[src]

Mutable reference to the control flow graph.

pub fn resolve_indirect_jumps<F: FnMut(&Variable) -> SmallVec<[Constant; 1]>>(
    &mut self,
    func: F
) -> bool
[src]

Calls func on each indirect jump and call instruction and rewrites it to jump/call the returned concrete addresses.

pub fn rewrite_basic_block<F: FnMut(&mut Statement, &mut Names, &mut Strings, &mut Segments) -> Result<RewriteControl> + Sized>(
    &mut self,
    basic_block: BasicBlockIndex,
    func: F
) -> Result<()>
[src]

Iterates thru all statements in basic_block calling func one each. The function is allowed to modify the IL.

pub fn insert_mnemonic(
    &mut self,
    basic_block: BasicBlockIndex,
    pos: usize,
    opcode: StrRef,
    args: SmallVec<[Value; 3]>,
    stmts: Vec<Statement>
) -> Result<()>
[src]

Inserts a new mnemonic at position pos inside basic_block with opcode and semantics described by stmts.

pub fn remove_mnemonic(&mut self, mnemonic: MnemonicIndex) -> Result<()>[src]

Removes mnemonic.

pub fn drop_first_mnemonic(
    &mut self,
    basic_block: BasicBlockIndex
) -> Result<()>
[src]

Removes the first mnemonic of basic_block. Fails of basic_block has no mnemonics.

pub fn retain_basic_blocks<F: FnMut(&Function, BasicBlockIndex) -> bool>(
    &mut self,
    f: F
) -> Result<()>
[src]

Deletes all basic blocks for which f returns false.

pub fn assemble(
    name: Str,
    names: Names,
    segments: Segments,
    region: UUID,
    strings: Strings,
    uuid: UUID,
    start: u64,
    mnemonics: Vec<(Mnemonic, Vec<Statement>)>,
    by_source: HashMap<(u64, usize), Vec<(CfgTarget, Guard)>>,
    by_destination: HashMap<(u64, usize), Vec<(CfgTarget, Guard)>>
) -> Result<Function>
[src]

Assembles a new function from a list of mnemonics and control flow edges. Used for deserializing functions.

pub fn pack(&mut self) -> Result<()>[src]

Compresses the internal representation of the function. Call this if you're running low on memory.

pub fn unpack(&mut self) -> Result<()>[src]

Uncompresses the function into a faster to process representation.

Trait Implementations

impl Clone for Function[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Function[src]

Auto Trait Implementations

impl Send for Function

impl Sync for Function

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]