SVF Python APIs - SVF-tools/Teaching-Software-Verification GitHub Wiki
SVF-Python APIs
At the beginning of your Python script, you need to import the pysvf
module.
from pysvf import *
Then, you can use the following APIs to access the members of the classes in the pysvf
module.
ICFGNode
Members | Meanings |
---|---|
ICFGNode.to_string() |
Get the string representation of the ICFG node |
ICFGNode.get_id() |
Get the ID of the ICFG node |
ICFGNode.get_fun() |
Get the function that the ICFG node belongs to |
ICFGNode.get_bb() |
Get the basic block that the ICFG node belongs to |
ICFGNode.get_svf_stmts() |
Get the SVF statements associated with the ICFG node |
ICFGNode.as_fun_entry() |
Downcast to FunEntryICFGNode |
ICFGNode.as_fun_exit() |
Downcast to FunExitICFGNode |
ICFGNode.as_call() |
Downcast to CallICFGNode |
ICFGNode.as_ret() |
Downcast to RetICFGNode |
ICFGNode.is_fun_entry() |
Check if the ICFG node is a function entry node |
ICFGNode.is_fun_exit() |
Check if the ICFG node is a function exit node |
ICFGNode.is_call() |
Check if the ICFG node is a function call node |
ICFGNode.is_ret() |
Check if the ICFG node is a function return node |
ICFGNode.get_out_edges() |
Get the out edges of the ICFG node |
ICFGNode.get_in_edges() |
Get the in edges of the ICFG node |
ICFGEdge
Members | Meanings |
---|---|
ICFGEdge.to_string() |
Get the string representation of the ICFG edge |
ICFGEdge.is_cfg_edge() |
Check if the edge is a CFG edge |
ICFGEdge.is_call_cfg_edge() |
Check if the edge is a call CFG edge |
ICFGEdge.is_ret_cfg_edge() |
Check if the edge is a return CFG edge |
ICFGEdge.is_intra_cfg_edge() |
Check if the edge is an intra CFG edge |
ICFGEdge.get_src() |
Get the source node of the edge |
ICFGEdge.get_dst() |
Get the destination node of the edge |
ICFGEdge.as_intra_cfg_edge() |
Downcast to IntraCFGEdge |
ICFGEdge.as_call_cfg_edge() |
Downcast to CallCFGEdge |
ICFGEdge.as_ret_cfg_edge() |
Downcast to RetCFGEdge |
CallCFGEdge.get_call_site() |
Get CallNode of CallCFGEdge |
RetCFGEdge.get_call_site() |
Get CallNode that matches the RetCFGNode of RetCFGEdge |
SVFVar
Members | Meanings |
---|---|
SVFVar.get_name() |
Get the name of the SVF variable |
SVFVar.get_id() |
Get the ID of the SVF variable |
SVFVar.is_pointer() |
Check if the SVF variable is a pointer |
SVFVar.is_const_data_or_agg_data_but_not_null_ptr() |
Check if the SVF variable is const data or agg data but not a null pointer |
SVFVar.is_isolated_node() |
Check if the SVF variable is an isolated node |
SVFVar.get_value_name() |
Get the value name of the SVF variable |
SVFVar.get_function() |
Get the function that the SVF variable belongs to |
SVFVar.ptr_in_uncalled_function() |
Check if the pointer is in an uncalled function |
SVFVar.is_const_data_or_agg_data() |
Check if the SVF variable is const data or agg data |
SVFVar.to_string() |
Get the string representation of the SVF variable |
SVFStmt
Members | Meanings |
---|---|
SVFStmt.to_string() |
Get the string representation of the SVF statement |
SVFStmt.get_edge_id() |
Get the ID of the SVF statement |
SVFStmt.get_icfg_node() |
Get the ICFG node that the SVF statement belongs to |
SVFStmt.get_value() |
Get the value of the SVF statement |
SVFStmt.get_bb() |
Get the basic block that the SVF statement belongs to |
SVFStmt.is_addr_stmt() |
Check if the SVF statement is an address statement |
SVFStmt.is_copy_stmt() |
Check if the SVF statement is a copy statement |
SVFStmt.is_store_stmt() |
Check if the SVF statement is a store statement |
SVFStmt.is_load_stmt() |
Check if the SVF statement is a load statement |
SVFStmt.is_call_pe() |
Check if the SVF statement is a call PE |
SVFStmt.is_ret_pe() |
Check if the SVF statement is a return PE |
SVFStmt.is_gep_stmt() |
Check if the SVF statement is a GEP statement |
SVFStmt.is_phi_stmt() |
Check if the SVF statement is a phi statement |
SVFStmt.is_select_stmt() |
Check if the SVF statement is a select statement |
SVFStmt.is_cmp_stmt() |
Check if the SVF statement is a compare statement |
SVFStmt.is_binary_op_stmt() |
Check if the SVF statement is a binary operation statement |
SVFStmt.is_unary_op_stmt() |
Check if the SVF statement is a unary operation statement |
SVFStmt.is_branch_stmt() |
Check if the SVF statement is a branch statement |
SVFStmt.as_addr_stmt() |
Downcast the SVF statement to an address statement |
SVFStmt.as_copy_stmt() |
Downcast the SVF statement to a copy statement |
SVFStmt.as_store_stmt() |
Downcast the SVF statement to a store statement |
SVFStmt.as_load_stmt() |
Downcast the SVF statement to a load statement |
SVFStmt.as_call_pe() |
Downcast the SVF statement to a call PE |
SVFStmt.as_ret_pe() |
Downcast the SVF statement to a return PE |
SVFStmt.as_gep_stmt() |
Downcast the SVF statement to a GEP statement |
SVFStmt.as_phi_stmt() |
Downcast the SVF statement to a phi statement |
SVFStmt.as_select_stmt() |
Downcast the SVF statement to a select statement |
SVFStmt.as_cmp_stmt() |
Downcast the SVF statement to a compare statement |
SVFStmt.as_binary_op_stmt() |
Downcast the SVF statement to a binary operation statement |
SVFStmt.as_unary_op_stmt() |
Downcast the SVF statement to a unary operation statement |
SVFStmt.as_branch_stmt() |
Downcast the SVF statement to a branch statement |
ICFGNode::toString()
- Get the string representation of the ICFG node
Output Sample:
<bound method PyCapsule.to_string of <pysvf.pysvf.FunExitICFGNode object at 0x7f4cd2f68a30>>
Downcasting to a Specific Subclass
In scenarios where you need to downcast an object to a specific subclass, it's important to first ensure that the object is an instance of that subclass. The following example demonstrates this process:
Example in Python:
edge = ICFGEdge()
if edge.is_call_cfg_edge():
call_edge = edge.as_call_cfg_edge()