1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_State_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_State_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
8 #include <boost/enable_shared_from_this.hpp>
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/export.hpp>
11 #include <boost/serialization/nvp.hpp>
12 #include <boost/serialization/shared_ptr.hpp>
15 namespace BinaryAnalysis {
16 namespace InstructionSemantics {
39 class State:
public boost::enable_shared_from_this<State> {
51 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
53 friend class boost::serialization::access;
56 void serialize(S &s,
const unsigned ) {
57 s & BOOST_SERIALIZATION_NVP(protoval_);
58 s & BOOST_SERIALIZATION_NVP(registers_);
59 s & BOOST_SERIALIZATION_NVP(memory_);
102 StatePtr self = boost::const_pointer_cast<
State>(shared_from_this());
121 virtual void clear();
195 void printRegisters(std::ostream &stream,
const std::string &prefix =
"");
204 void printMemory(std::ostream &stream,
const std::string &prefix =
"")
const;
210 void print(std::ostream &stream,
const std::string &prefix =
"")
const;
225 void print(std::ostream &stream)
const { obj->print(stream, fmt); }
245 WithFormatter
operator+(
const std::string &linePrefix);
256 std::ostream& operator<<(std::ostream&,
const State&);
257 std::ostream& operator<<(std::ostream&,
const State::WithFormatter&);
Base classes for instruction semantics.
virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps)
Write a value to memory.
void clearMemory()
Clear all memory locations.
virtual void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const
Compute a hash of the state.
virtual StatePtr clone() const
Virtual copy constructor.
void printMemory(std::ostream &stream, const std::string &prefix="") const
Print memory contents.
virtual SValuePtr peekRegister(RegisterDescriptor desc, const SValuePtr &dflt, RiscOperators *ops)
Read register without side effects.
WithFormatter with_format(Formatter &fmt)
Used for printing states with formatting.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
void zeroRegisters()
Initialize all registers to zero.
virtual void writeRegister(RegisterDescriptor desc, const SValuePtr &value, RiscOperators *ops)
Write a value to a register.
Main namespace for the ROSE library.
std::string toString() const
Convert the state to a string for debugging.
virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)
Read from memory without side effects.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
static StatePtr instance(const RegisterStatePtr ®isters, const MemoryStatePtr &memory)
Instantiate a new state object with specified register and memory states.
MemoryStatePtr memoryState() const
Property: Memory state.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual bool merge(const StatePtr &other, RiscOperators *ops)
Merge operation for data flow analysis.
Describes (part of) a physical CPU register.
WithFormatter operator+(Formatter &fmt)
Used for printing states with formatting.
virtual StatePtr create(const RegisterStatePtr ®isters, const MemoryStatePtr &memory) const
Virtual constructor.
SValuePtr protoval() const
Return the protoval.
static StatePtr instance(const StatePtr &other)
Instantiate a new copy of an existing state.
StatePtr Ptr
Shared-ownership pointer.
virtual SValuePtr readRegister(RegisterDescriptor desc, const SValuePtr &dflt, RiscOperators *ops)
Read a value from a register.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
void print(std::ostream &stream, const std::string &prefix="") const
Print the state.
RegisterStatePtr registerState() const
Property: Register state.
virtual void clear()
Initialize state.
Base class for most instruction semantics RISC operators.
Base class for semantics machine states.
void printRegisters(std::ostream &stream, const std::string &prefix="")
Print the register contents.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)
Read a value from memory.