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 {
69 SValuePair functionStackPtrs_;
78#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
80 friend class boost::serialization::access;
83 void serializeCommon(S &s,
const unsigned version) {
85 s & BOOST_SERIALIZATION_NVP(cpu_);
86 s & BOOST_SERIALIZATION_NVP(initialConcreteStackPointer_);
87 s & BOOST_SERIALIZATION_NVP(hasResults_);
88 s & BOOST_SERIALIZATION_NVP(didConverge_);
89 s & BOOST_SERIALIZATION_NVP(functionStackPtrs_);
90 s & BOOST_SERIALIZATION_NVP(functionDelta_);
91 s & BOOST_SERIALIZATION_NVP(bblockStackPtrs_);
92 s & BOOST_SERIALIZATION_NVP(bblockDeltas_);
93 s & BOOST_SERIALIZATION_NVP(insnStackPtrs_);
94 s & BOOST_SERIALIZATION_NVP(insnDeltas_);
98 void save(S &s,
const unsigned version)
const {
99 const_cast<Analysis*
>(
this)->serializeCommon(s, version);
101 std::string archName;
105 ops = cpu_->operators();
107 s & BOOST_SERIALIZATION_NVP(archName);
108 s & BOOST_SERIALIZATION_NVP(ops);
113 void load(S &s,
const unsigned version) {
114 serializeCommon(s, version);
116 std::string archName;
118 s & BOOST_SERIALIZATION_NVP(archName);
119 s & BOOST_SERIALIZATION_NVP(ops);
120 if (!archName.empty())
125 BOOST_SERIALIZATION_SPLIT_MEMBER();
135 : hasResults_(false), didConverge_(false) {}
141 : hasResults_(false), didConverge_(false) {
153 : cpu_(
cpu), hasResults_(false), didConverge_(false) {}
322std::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.
void clearStackDeltas()
Clear stack deltas, not pointers.
InstructionSemantics::BaseSemantics::SValuePtr instructionStackDelta(SgAsmInstruction *) const
Stack delta for an instruction.
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.
static int64_t toInt(const InstructionSemantics::BaseSemantics::SValuePtr &)
Convert a symbolic value to an integer.
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.
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.