1 #ifndef ROSE_BinaryAnalysis_Partitioner2_DataFlow_H
2 #define ROSE_BinaryAnalysis_Partitioner2_DataFlow_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/DataFlow.h>
7 #include <Rose/BinaryAnalysis/Partitioner2/BasicBlock.h>
8 #include <Rose/BinaryAnalysis/Partitioner2/ControlFlowGraph.h>
9 #include <Rose/BinaryAnalysis/Partitioner2/Function.h>
10 #include <Sawyer/Graph.h>
13 namespace BinaryAnalysis {
14 namespace Partitioner2 {
46 : type_(
BBLOCK), bblock_(bblock), parentFunction_(parentFunction), inliningId_(inliningId) {
47 ASSERT_not_null(bblock);
52 : type_(
FAKED_CALL), callee_(function), parentFunction_(parentFunction), inliningId_(inliningId) {}
56 : type_(type), parentFunction_(parentFunction), inliningId_(inliningId) {
57 ASSERT_require2(
BBLOCK!=type &&
FAKED_CALL!=type,
"use a different constructor");
125 virtual bool operator()(
const ControlFlowGraph&,
const ControlFlowGraph::ConstEdgeIterator&,
size_t depth) = 0;
131 bool operator()(
const ControlFlowGraph&,
const ControlFlowGraph::ConstEdgeIterator&,
size_t )
override {
150 void dumpDfCfg(std::ostream&,
const DfCfg&);
164 template<
class DfCfg>
171 ASSERT_require(retval == dfCfg.
vertices().end());
198 : cpu_(cpu), STACK_POINTER_REG(cpu->stackPointerRegister()), INSN_POINTER_REG(cpu->instructionPointerRegister()) {
199 size_t adjustment = STACK_POINTER_REG.
nBits() / 8;
200 callRetAdjustment_ = cpu->number_(STACK_POINTER_REG.
nBits(), adjustment);
Rose::BinaryAnalysis::DataFlow::Engine< DfCfg, BaseSemantics::StatePtr, TransferFunction, MergeFunction > Engine
Data-Flow engine.
Rose::BinaryAnalysis::DataFlow::SemanticsMerge MergeFunction
Data-flow merge function.
Type type() const
Type of the vertex.
std::vector< AbstractLocation > findGlobalVariables(const BaseSemantics::RiscOperatorsPtr &ops, size_t wordNBytes)
Returns a list of global variables.
Predicate that always returns false, preventing interprocedural analysis.
BaseSemantics::DispatcherPtr cpu() const
Property: Virtual CPU.
Graph containing user-defined vertices and edges.
size_t nBits() const
Property: Size in bits.
Function::Ptr bestSummaryFunction(const FunctionSet &functions)
Choose best function for data-flow summary vertex.
const BasicBlock::Ptr & bblock() const
Basic block.
Sawyer::Container::GraphTraits< DfCfg >::VertexIterator findReturnVertex(DfCfg &dfCfg)
Find the return vertex.
Basic merge operation for instruction semantics.
DfCfgVertex(Type type, const Function::Ptr &parentFunction, size_t inliningId)
Construct a vertex of specified type that takes no auxiliary data.
void defaultCallingConvention(const CallingConvention::DefinitionPtr &x)
Property: Default calling convention.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
Variables::StackVariables findStackVariables(const FunctionPtr &function, const BaseSemantics::RiscOperatorsPtr &ops, const BaseSemantics::SValuePtr &initialStackPointer)
Returns the list of all known stack variables.
Data-Flow transfer functor.
Sawyer::Optional< rose_addr_t > address() const
Virtual address of vertex.
DfCfgVertex(const Function::Ptr &function, const Function::Ptr &parentFunction, size_t inliningId)
Construct a faked call vertex.
Function::Ptr parentFunction() const
Function owning this vertex.
boost::iterator_range< VertexIterator > vertices()
Iterators for all vertices.
Main namespace for the ROSE library.
Variables::StackVariables findFunctionArguments(const FunctionPtr &function, const BaseSemantics::RiscOperatorsPtr &ops, const BaseSemantics::SValuePtr &initialStackPointer)
Returns the list of all known function arguments.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
TransferFunction(const BaseSemantics::DispatcherPtr &cpu)
Construct from a CPU.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
CFG vertex for data-flow analysis.
Vertex represents a basic block.
Vertex represents returning to the caller.
DfCfg buildDfCfg(const Partitioner &, const ControlFlowGraph &, const ControlFlowGraph::ConstVertexIterator &startVertex, InterproceduralPredicate &predicate=NOT_INTERPROCEDURAL)
build a cfg useful for data-flow analysis.
Container classes that store user-defined values.
BaseSemantics::StatePtr initialState() const
Construct an initial state.
Describes (part of) a physical CPU register.
Predicate that decides when to use inter-procedural data-flow.
size_t inliningId() const
Inlining invocation number.
Represents a whole called function.
std::vector< SgAsmInstruction * > vertexUnpacker(const DfCfgVertex &)
Unpacks a vertex into a list of instructions.
DfCfgVertex(const BasicBlock::Ptr &bblock, const Function::Ptr &parentFunction, size_t inliningId)
Construct a basic block vertex.
G::VertexIterator VertexIterator
Const or non-const vertex iterator.
void dumpDfCfg(std::ostream &, const DfCfg &)
Emit a data-flow CFG as a GraphViz file.
Indeterminate basic block where no information is available.
Partitions instructions into basic blocks and functions.
Variables::StackVariables findLocalVariables(const FunctionPtr &function, const BaseSemantics::RiscOperatorsPtr &ops, const BaseSemantics::SValuePtr &initialStackPointer)
Returns the list of all known local variables.
Sawyer::Container::Graph< DfCfgVertex > DfCfg
Control flow graph used by data-flow analysis.
const Function::Ptr & callee() const
Function represented by faked call.
CallingConvention::DefinitionPtr defaultCallingConvention() const
Property: Default calling convention.