Struct solana_rbpf::static_analysis::Analysis
source · 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)
pub fn split_into_basic_blocks(&mut self, flatten_call_graph: bool)
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) -> String
pub fn disassemble_instruction(&self, insn: &Insn) -> 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