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
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#include <Rose/BinaryAnalysis/ByteCode/Analysis.h>
12namespace BinaryAnalysis {
13namespace InstructionSemantics {
72 std::vector<SValuePtr> stack_;
73 std::vector<SValuePtr> locals_;
78#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
80 friend class boost::serialization::access;
83 void serialize(S &s,
const unsigned ) {
84 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
MemoryState);
85 s & BOOST_SERIALIZATION_NVP(frameId_);
86 s & BOOST_SERIALIZATION_NVP(returnAddress_);
87 s & BOOST_SERIALIZATION_NVP(stack_);
88 s & BOOST_SERIALIZATION_NVP(locals_);
89 s & BOOST_SERIALIZATION_NVP(method_);
134 SValuePtr readLocal(
size_t index)
const override;
135 void writeLocal(
size_t index,
const SValuePtr &value)
override;
147 SValuePtr createArgument(
const std::string &descriptor,
size_t argIdx);
148 static std::string argumentDescriptor(
const std::string &descriptor,
size_t argIdx);
153 size_t frameId()
const;
154 void frameId(
size_t);
155 static size_t newFrameId();
157 std::string frameLabel()
const;
158 std::string frameName()
const;
163 static bool isCategory1(
const SValuePtr&);
164 static bool isCategory2(
const SValuePtr&);
165 static bool isCategory2Tail(
const SValuePtr&);
169 void initializeForRootFrame();
176 void clearLocalRange(
size_t begin,
size_t nSlots);
184#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
Purely symbolic memory state.
void clear() override
Clear memory.
std::string label() const override
Label for this address space.
bool merge(const AddressSpacePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
Merge address spaces for data flow analysis.
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.
AddressSpacePtr clone() const override
Deep-copy of this address space.
void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
Hash this address space.
static FrameStatePtr promote(const AddressSpacePtr &)
Convert pointer to a FrameState pointer.
SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory.
FrameStatePtr Ptr
Shared-ownership pointer.
SValuePtr popOperand() override
Pop an operand value.
SValuePtr peekOperand(size_t depth=0) override
Peek at an operand value.
void print(std::ostream &, Formatter &) const override
Print an address space.
static FrameStatePtr instance(const SValuePtr &, const Sawyer::Optional< Address > &, const ByteCode::Method::Ptr &)
Instantiate a new empty frame state on the heap.
void writeMemory(const SValuePtr &address, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
Write a value to memory.
MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const override
Virtual allocating constructor.
Represents all memory in the state.
Base class for most instruction semantics RISC operators.
Holds a value or nothing.
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.
std::uint64_t Address
Address.