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#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
12#include <boost/serialization/access.hpp>
13#include <boost/serialization/split_member.hpp>
17namespace BinaryAnalysis {
20namespace Partitioner2 {
75 SValuePair functionStackPtrs_;
84 bool hasConsistentFramePointer_ =
false;
86#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
88 friend class boost::serialization::access;
91 void serializeCommon(S &s,
const unsigned version) {
93 s & BOOST_SERIALIZATION_NVP(cpu_);
94 s & BOOST_SERIALIZATION_NVP(initialConcreteStackPointer_);
95 s & BOOST_SERIALIZATION_NVP(hasResults_);
96 s & BOOST_SERIALIZATION_NVP(didConverge_);
97 s & BOOST_SERIALIZATION_NVP(functionStackPtrs_);
98 s & BOOST_SERIALIZATION_NVP(functionDelta_);
99 s & BOOST_SERIALIZATION_NVP(bblockStackPtrs_);
100 s & BOOST_SERIALIZATION_NVP(bblockDeltas_);
101 s & BOOST_SERIALIZATION_NVP(insnStackPtrs_);
102 s & BOOST_SERIALIZATION_NVP(insnSpDeltas_);
104 s & BOOST_SERIALIZATION_NVP(insnFramePtrs_);
105 s & BOOST_SERIALIZATION_NVP(hasConsistentFramePointer_);
110 void save(S &s,
const unsigned version)
const {
111 const_cast<Analysis*
>(
this)->serializeCommon(s, version);
113 std::string archName;
117 ops = cpu_->operators();
119 s & BOOST_SERIALIZATION_NVP(archName);
120 s & BOOST_SERIALIZATION_NVP(ops);
125 void load(S &s,
const unsigned version) {
126 serializeCommon(s, version);
128 std::string archName;
130 s & BOOST_SERIALIZATION_NVP(archName);
131 s & BOOST_SERIALIZATION_NVP(ops);
132 if (!archName.empty())
137 BOOST_SERIALIZATION_SPLIT_MEMBER();
147 : hasResults_(false), didConverge_(false) {}
153 : hasResults_(false), didConverge_(false) {
165 : cpu_(
cpu), hasResults_(false), didConverge_(false) {}
354std::ostream& operator<<(std::ostream&,
const Analysis&);
361#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
Various tools for data-flow analysis.
RiscOperatorsPtr Ptr
Shared-ownership pointer.
Predicate that decides when to use inter-procedural data-flow.
InstructionSemantics::BaseSemantics::SValuePtr basicBlockOutputStackDeltaWrtFunction(Address basicBlockAddress) const
Stack delta for block w.r.t.
InstructionSemantics::BaseSemantics::SValuePtr instructionInputStackDeltaWrtFunction(SgAsmInstruction *) const
Stack delta for instruction w.r.t.
InstructionSemantics::BaseSemantics::SValuePtr basicBlockInputStackDeltaWrtFunction(Address basicBlockAddress) const
Stack delta for block 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.
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 saveAnalysisResults(SgAsmFunction *) const
Update AST with analysis results.
static void clearAstStackDeltas(SgNode *)
Clear AST stack deltas.
Sawyer::Optional< Address > initialConcreteStackPointer() const
Property: Initial value to use for stack pointers.
InstructionSemantics::BaseSemantics::SValuePtr functionStackDelta() const
Stack delta for an analyzed function.
int64_t functionStackDeltaConcrete() const
Concrete stack delta for an analyzed function.
int64_t basicBlockStackDeltaConcrete(Address basicBlockAddress) const
Concrete stack delta for an analyzed basic block.
SValuePair basicBlockStackPointers(Address basicBlockAddress) const
Initial and final stack pointers for a basic block.
InstructionSemantics::BaseSemantics::SValuePtr instructionOutputStackDeltaWrtFunction(SgAsmInstruction *) const
Stack delta for instruction w.r.t.
InstructionSemantics::BaseSemantics::SValuePtr basicBlockStackDelta(Address basicBlockAddress) const
Stack delta for an analyzed basic block.
void initialConcreteStackPointer(const Sawyer::Optional< Address > &val)
Property: Initial value to use for stack pointers.
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.
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.
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.
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.
std::uint64_t Address
Address.