1#ifndef ROSE_BinaryAnalysis_StackDelta_H
2#define ROSE_BinaryAnalysis_StackDelta_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/Disassembler/BasicTypes.h>
7#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
8#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics.h>
11#include <boost/serialization/access.hpp>
12#include <boost/serialization/split_member.hpp>
15namespace BinaryAnalysis {
18namespace Partitioner2 {
73 SValuePair functionStackPtrs_;
82 bool hasConsistentFramePointer_ =
false;
84#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
86 friend class boost::serialization::access;
89 void serializeCommon(S &s,
const unsigned version) {
91 s & BOOST_SERIALIZATION_NVP(cpu_);
92 s & BOOST_SERIALIZATION_NVP(initialConcreteStackPointer_);
93 s & BOOST_SERIALIZATION_NVP(hasResults_);
94 s & BOOST_SERIALIZATION_NVP(didConverge_);
95 s & BOOST_SERIALIZATION_NVP(functionStackPtrs_);
96 s & BOOST_SERIALIZATION_NVP(functionDelta_);
97 s & BOOST_SERIALIZATION_NVP(bblockStackPtrs_);
98 s & BOOST_SERIALIZATION_NVP(bblockDeltas_);
99 s & BOOST_SERIALIZATION_NVP(insnStackPtrs_);
100 s & BOOST_SERIALIZATION_NVP(insnSpDeltas_);
102 s & BOOST_SERIALIZATION_NVP(insnFramePtrs_);
103 s & BOOST_SERIALIZATION_NVP(hasConsistentFramePointer_);
108 void save(S &s,
const unsigned version)
const {
109 const_cast<Analysis*
>(
this)->serializeCommon(s, version);
111 std::string archName;
115 ops = cpu_->operators();
117 s & BOOST_SERIALIZATION_NVP(archName);
118 s & BOOST_SERIALIZATION_NVP(ops);
123 void load(S &s,
const unsigned version) {
124 serializeCommon(s, version);
126 std::string archName;
128 s & BOOST_SERIALIZATION_NVP(archName);
129 s & BOOST_SERIALIZATION_NVP(ops);
130 if (!archName.empty())
135 BOOST_SERIALIZATION_SPLIT_MEMBER();
145 : hasResults_(false), didConverge_(false) {}
151 : hasResults_(false), didConverge_(false) {
163 : cpu_(
cpu), hasResults_(false), didConverge_(false) {}
352std::ostream& operator<<(std::ostream&,
const Analysis&);
Various tools for data-flow analysis.
RiscOperatorsPtr Ptr
Shared-ownership pointer.
Predicate that decides when to use inter-procedural data-flow.
InstructionSemantics::BaseSemantics::SValuePtr instructionInputStackDeltaWrtFunction(SgAsmInstruction *) const
Stack delta for instruction w.r.t.
SValuePair instructionStackPointers(SgAsmInstruction *) const
Initial and final stack ponters for an analyzed instruction.
void analyzeFunction(const Partitioner2::PartitionerConstPtr &, const Partitioner2::FunctionPtr &, Partitioner2::DataFlow::InterproceduralPredicate &)
Analyze one function.
static Sawyer::Optional< int64_t > toInt(const InstructionSemantics::BaseSemantics::SValuePtr &)
Convert a symbolic value to an integer.
void clearStackDeltas()
Clear stack deltas, not pointers.
InstructionSemantics::BaseSemantics::SValuePtr instructionStackDelta(SgAsmInstruction *) const
Stack delta for an instruction.
void clearFramePointers()
Clear the frame pointers.
Sawyer::Optional< rose_addr_t > initialConcreteStackPointer() const
Property: Initial value to use for stack pointers.
SValuePair functionStackPointers() const
Initial and final stack pointers for an analyzed function.
int64_t instructionStackDeltaConcrete(SgAsmInstruction *) const
Concrete stack delta for an instruction.
void print(std::ostream &) const
Print multi-line value to specified stream.
void initialConcreteStackPointer(const Sawyer::Optional< rose_addr_t > &val)
Property: Initial value to use for stack pointers.
void saveAnalysisResults(SgAsmFunction *) const
Update AST with analysis results.
static void clearAstStackDeltas(SgNode *)
Clear AST stack deltas.
InstructionSemantics::BaseSemantics::SValuePtr functionStackDelta() const
Stack delta for an analyzed function.
InstructionSemantics::BaseSemantics::SValuePtr basicBlockOutputStackDeltaWrtFunction(rose_addr_t basicBlockAddress) const
Stack delta for block w.r.t.
int64_t functionStackDeltaConcrete() const
Concrete stack delta for an analyzed function.
InstructionSemantics::BaseSemantics::SValuePtr basicBlockStackDelta(rose_addr_t basicBlockAddress) const
Stack delta for an analyzed basic block.
InstructionSemantics::BaseSemantics::SValuePtr instructionOutputStackDeltaWrtFunction(SgAsmInstruction *) const
Stack delta for instruction w.r.t.
void clearNonResults()
Clears everything but results.
bool hasConsistentFramePointer() const
True if the function appears to have a frame pointer.
InstructionSemantics::BaseSemantics::SValuePtr instructionInputFrameDelta(SgAsmInstruction *) const
Frame delta for an instruction.
Analysis(const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu)
Construct an analysis using a specified dispatcher.
int64_t basicBlockStackDeltaConcrete(rose_addr_t basicBlockAddress) const
Concrete stack delta for an analyzed basic block.
void clearStackPointers()
Clear stack pointers, not deltas.
InstructionSemantics::BaseSemantics::DispatcherPtr cpu() const
Virtual CPU used for analysis.
bool hasResults() const
Whether a function has been analyzed.
SValuePair basicBlockStackPointers(rose_addr_t basicBlockAddress) const
Initial and final stack pointers for a basic block.
InstructionSemantics::BaseSemantics::SValuePtr instructionOutputFrameDelta(SgAsmInstruction *) const
Frame delta for an instruction.
void clearResults()
Clear analysis results.
Analysis(const Disassembler::BasePtr &d)
Construct an analyzer using a specified disassembler.
Analysis()
Default constructor.
InstructionSemantics::BaseSemantics::SValuePtr basicBlockInputStackDeltaWrtFunction(rose_addr_t basicBlockAddress) const
Stack delta for block w.r.t.
bool didConverge() const
Whether the analysis results are valid.
Container associating values with keys.
Holds a value or nothing.
Represents a synthesized function.
Base class for machine instructions.
This class represents the base class for all IR nodes within Sage III.
InstructionSemantics::BaseSemantics::DispatcherPtr newInstructionDispatcher(const std::string &name, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &)
Create a new instruction dispatcher by name.
const std::string & name(const BaseConstPtr &)
Architecture name free function.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
Sawyer::Message::Facility mlog
Facility for diagnostic output.
void initDiagnostics()
Initialize diagnostics.
void initNamespace()
Initialize this namespace.