pub struct Analysis<'a> {
pub instructions: Vec<Insn>,
pub functions: BTreeMap<usize, (u32, String)>,
pub cfg_nodes: BTreeMap<usize, CfgNode>,
pub topological_order: Vec<usize>,
pub entrypoint: usize,
pub super_root: usize,
pub dfg_forward_edges: BTreeMap<DfgNode, BTreeSet<DfgEdge>>,
pub dfg_reverse_edges: BTreeMap<DfgNode, BTreeSet<DfgEdge>>,
/* private fields */
}
Expand description
Result of the executable analysis
Fields§
§instructions: Vec<Insn>
Plain list of instructions as they occur in the executable
functions: BTreeMap<usize, (u32, String)>
Functions in the executable
cfg_nodes: BTreeMap<usize, CfgNode>
Nodes of the control-flow graph
topological_order: Vec<usize>
Topological order of cfg_nodes
entrypoint: usize
CfgNode where the execution starts
super_root: usize
Virtual CfgNode that reaches all functions
dfg_forward_edges: BTreeMap<DfgNode, BTreeSet<DfgEdge>>
Data flow edges (the keys are DfgEdge sources)
dfg_reverse_edges: BTreeMap<DfgNode, BTreeSet<DfgEdge>>
Data flow edges (the keys are DfgEdge destinations)
Implementations§
Source§impl<'a> Analysis<'a>
impl<'a> Analysis<'a>
Sourcepub fn from_executable<C: ContextObject>(
executable: &'a Executable<C>,
) -> Result<Self, EbpfError>
pub fn from_executable<C: ContextObject>( executable: &'a Executable<C>, ) -> Result<Self, EbpfError>
Analyze an executable statically
Sourcepub fn split_into_basic_blocks(
&mut self,
flatten_call_graph: bool,
sbpf_version: SBPFVersion,
)
pub fn split_into_basic_blocks( &mut self, flatten_call_graph: bool, sbpf_version: SBPFVersion, )
Splits the sequence of instructions into basic blocks
Also links the control-flow graph edges between the basic blocks.
Sourcepub fn label_basic_blocks(&mut self)
pub fn label_basic_blocks(&mut self)
Gives the basic blocks names
Sourcepub fn disassemble_label<W: Write>(
&self,
output: &mut W,
suppress_extra_newlines: bool,
pc: usize,
last_basic_block: &mut usize,
) -> Result<()>
pub fn disassemble_label<W: Write>( &self, output: &mut W, suppress_extra_newlines: bool, pc: usize, last_basic_block: &mut usize, ) -> Result<()>
Generates labels for assembler code
Sourcepub fn disassemble_instruction(&self, insn: &Insn, pc: usize) -> String
pub fn disassemble_instruction(&self, insn: &Insn, pc: usize) -> String
Generates assembler code for a single instruction
Sourcepub fn disassemble<W: Write>(&self, output: &mut W) -> Result<()>
pub fn disassemble<W: Write>(&self, output: &mut W) -> Result<()>
Generates assembler code for the analyzed executable
Sourcepub fn disassemble_trace_log<W: Write>(
&self,
output: &mut W,
trace_log: &[TraceLogEntry],
) -> Result<(), Error>
pub fn disassemble_trace_log<W: Write>( &self, output: &mut W, trace_log: &[TraceLogEntry], ) -> Result<(), Error>
Use this method to print the trace log
Sourcepub fn iter_cfg_by_function(
&self,
) -> impl Iterator<Item = (Range<usize>, usize, &CfgNode)> + '_
pub fn iter_cfg_by_function( &self, ) -> impl Iterator<Item = (Range<usize>, usize, &CfgNode)> + '_
Iterates over the cfg_nodes while providing the PC range of the function they belong to.
Sourcepub fn visualize_graphically<W: Write>(
&self,
output: &mut W,
dynamic_analysis: Option<&DynamicAnalysis>,
) -> Result<()>
pub fn visualize_graphically<W: Write>( &self, output: &mut W, dynamic_analysis: Option<&DynamicAnalysis>, ) -> Result<()>
Generates a graphviz DOT of the analyzed executable
Sourcepub fn control_flow_graph_tarjan(&mut self)
pub fn control_flow_graph_tarjan(&mut self)
Finds the strongly connected components
Generates a topological order as by-product.
Sourcepub fn control_flow_graph_dominance_hierarchy(&mut self)
pub fn control_flow_graph_dominance_hierarchy(&mut self)
Finds the dominance hierarchy of the control-flow graph
Uses the Cooper-Harvey-Kennedy algorithm.
Sourcepub fn intra_basic_block_data_flow(
&mut self,
) -> BTreeMap<usize, HashMap<DataResource, usize>>
pub fn intra_basic_block_data_flow( &mut self, ) -> BTreeMap<usize, HashMap<DataResource, usize>>
Connect the dependencies between the instructions inside of the basic blocks
Sourcepub fn inter_basic_block_data_flow(
&mut self,
basic_block_outputs: BTreeMap<usize, HashMap<DataResource, usize>>,
)
pub fn inter_basic_block_data_flow( &mut self, basic_block_outputs: BTreeMap<usize, HashMap<DataResource, usize>>, )
Connect the dependencies inbetween the basic blocks
Auto Trait Implementations§
impl<'a> Freeze for Analysis<'a>
impl<'a> RefUnwindSafe for Analysis<'a>
impl<'a> Send for Analysis<'a>
impl<'a> Sync for Analysis<'a>
impl<'a> Unpin for Analysis<'a>
impl<'a> UnwindSafe for Analysis<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more