ROSE 2.1.0
Loading...
Searching...
No Matches
FrameState.h
1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_FrameState_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_FrameState_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/AddressSpace.h>
8#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryState.h>
9
10namespace Rose {
11namespace BinaryAnalysis {
12namespace InstructionSemantics {
13namespace BaseSemantics {
14
16using FrameStatePtr = boost::shared_ptr<class FrameState>;
17
24// Frame State
26
60class FrameState: public MemoryState {
61public:
64
67
68private:
69 std::vector<SValuePtr> stack_; // operand stack for the frame
70 std::vector<SValuePtr> locals_; // local variables array for the frame
71
73 // Serialization
74#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
75private:
76 friend class boost::serialization::access;
77
78 template<class S>
79 void serialize(S &s, const unsigned /*version*/) {
80 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MemoryState);
81 s & BOOST_SERIALIZATION_NVP(stack_);
82 s & BOOST_SERIALIZATION_NVP(locals_);
83 }
84#endif
85
86public:
88
89protected:
90 FrameState(); // for serialization
91
92 // All memory states should be heap allocated; use instance(), create(), or clone() instead.
93 explicit FrameState(const SValuePtr &valProtoval);
94
95public:
97 static FrameStatePtr instance(const SValuePtr &valProtoval);
98
99public:
100 // documented in base class
101 virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const override;
102
103 // documented in base class
104 virtual AddressSpacePtr clone() const override;
105
110
111public:
112 virtual bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override;
113
114 virtual void clear() override;
115
116 virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt,
117 RiscOperators *addrOps, RiscOperators *valOps) override;
118
119 virtual void writeMemory(const SValuePtr &address, const SValuePtr &value,
120 RiscOperators *addrOps, RiscOperators *valOps) override;
121
122 virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt,
123 RiscOperators *addrOps, RiscOperators *valOps) override;
124
125 SValuePtr readLocal(uint8_t index) override;
126 void writeLocal(uint8_t index, const SValuePtr &value) override;
127
129 void pushOperand(const SValuePtr &value) override;
130
131public:
132 virtual void hash(Combinatorics::Hasher&, RiscOperators *addrOps, RiscOperators *valOps) const override;
133
134 virtual void print(std::ostream&, Formatter&) const override;
135};
136
137} // namespace
138} // namespace
139} // namespace
140} // namespace
141
142#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
144#endif
145
146#endif
147#endif
static FrameStatePtr instance(const SValuePtr &valProtoval)
Instantiate a new empty frame state on the heap.
virtual void writeMemory(const SValuePtr &address, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
Write a value to memory.
virtual bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
Merge address spaces for data flow analysis.
virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory without side effects.
void pushOperand(const SValuePtr &value) override
Push an operand value to a frame.
static FrameStatePtr promote(const AddressSpacePtr &)
Convert pointer to a FrameState pointer.
SValuePtr popOperand() override
Pop an operand value from a frame.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory.
virtual void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
Hash this address space.
virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const override
Virtual allocating constructor.
virtual AddressSpacePtr clone() const override
Deep-copy of this address space.
virtual void print(std::ostream &, Formatter &) const override
Print an address space.
Base class for most instruction semantics RISC operators.
Base classes for instruction semantics.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
boost::shared_ptr< AddressSpace > AddressSpacePtr
Shared-ownership pointer for AddressSpace objects.
boost::shared_ptr< FrameState > FrameStatePtr
Shared-ownership pointer to a frame state.
The ROSE library.