1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_NativeSemantics_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_NativeSemantics_H
3 #include <featureTests.h>
4 #if defined(ROSE_ENABLE_BINARY_ANALYSIS) && defined(ROSE_ENABLE_DEBUGGER_LINUX)
6 #include <Rose/BinaryAnalysis/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/Debugger/Linux.h>
8 #include <Rose/BinaryAnalysis/InstructionSemantics/ConcreteSemantics.h>
10 #include <boost/noncopyable.hpp>
11 #include <boost/filesystem.hpp>
14 namespace BinaryAnalysis {
15 namespace InstructionSemantics {
18 namespace NativeSemantics {
25 typedef ConcreteSemantics::SValue SValue;
38 typedef boost::shared_ptr<class RegisterState> RegisterStatePtr;
49 using Ptr = RegisterStatePtr;
52 Debugger::Linux::Ptr process_;
69 static RegisterStatePtr instance();
94 Debugger::Linux::Ptr process()
const;
100 virtual void clear()
override {}
102 virtual void zero()
override {
103 TODO(
"[Robb Matzke 2019-09-05]");
107 ASSERT_not_implemented(
"[Robb Matzke 2019-09-05]");
112 return peekRegister(reg, dflt, ops);
121 virtual void updateReadProperties(RegisterDescriptor)
override {}
126 virtual void print(std::ostream&, Formatter&)
const override;
145 using Ptr = MemoryStatePtr;
148 Debugger::Linux::Ptr process_;
157 const Debugger::Linux::Ptr &process);
166 static MemoryStatePtr instance();
170 const Debugger::Linux::Ptr &process);
192 Debugger::Linux::Ptr process()
const;
198 virtual void clear()
override {}
202 ASSERT_not_implemented(
"not applicable for this class");
208 return peekMemory(address, dflt, addrOps, valOps);
217 ASSERT_not_implemented(
"[Robb Matzke 2019-09-05]");
222 ASSERT_not_implemented(
"[Robb Matzke 2021-03-26]");
226 ASSERT_not_implemented(
"[Robb Matzke 2019-09-05]");
235 typedef boost::shared_ptr<class State> StatePtr;
241 class State:
public ConcreteSemantics::State, boost::noncopyable {
244 using Super = ConcreteSemantics::State;
247 using Ptr = StatePtr;
254 : ConcreteSemantics::
State(registers, memory) {
255 (void) RegisterState::promote(registers);
256 (void) MemoryState::promote(memory);
264 return StatePtr(
new State(registers, memory));
275 class RiscOperators:
public ConcreteSemantics::RiscOperators {
278 using Super = ConcreteSemantics::RiscOperators;
281 using Ptr = RiscOperatorsPtr;
300 static RiscOperatorsPtr instanceFromProtoval(
const BaseSemantics::SValuePtr &protoval,
const Debugger::Linux::Ptr &process);
332 Debugger::Linux::Ptr process()
const {
333 return RegisterState::promote(currentState()->registerState())->process();
350 using Ptr = DispatcherPtr;
353 Debugger::Linux::Ptr process_;
370 static DispatcherPtr instance(
const Debugger::Linux::Ptr &process,
const BaseSemantics::SValuePtr &protoval = SValue::instance());
373 static DispatcherPtr instance(
const Debugger::Linux::Specimen&,
const BaseSemantics::SValuePtr &protoval = SValue::instance());
400 void processInstruction(rose_addr_t va);
408 virtual RegisterDescriptor instructionPointerRegister()
const override;
409 virtual RegisterDescriptor stackPointerRegister()
const override;
410 virtual RegisterDescriptor stackFrameRegister()
const override;
411 virtual RegisterDescriptor callReturnRegister()
const override;
417 notApplicable(
"iprocReplace");
420 notApplicable(
"iprocSet");
423 notApplicable(
"iprocKey");
428 [[noreturn]]
void notApplicable(
const std::string &what)
const {
429 ASSERT_not_implemented(what +
" is not applicable for this class");
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
ROSE_DLL_API void clear()
Empties the memory pool of all nodes.
Base class for machine instructions.
Sawyer::SharedPointer< class SValue > SValuePtr
Smart-ownership pointer to a concrete semantic value.
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer to a concrete memory state.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
Sawyer::SharedPointer< RegisterDictionary > RegisterDictionaryPtr
Reference counting pointer.
Main namespace for the ROSE library.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
Dispatches instructions through the RISC layer.
ROSE_DLL_API void merge(SgProject *project)
Performs sharing of AST nodes followed by linking accross translation units.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
void print(const StackVariables &, const Partitioner2::PartitionerConstPtr &, std::ostream &out, const std::string &prefix="")
Print info about multiple local variables.
Functor that knows how to dispatch a single kind of instruction.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to concrete RISC operations.
The set of all registers and their values.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
BaseSemantics::Formatter Formatter
Formatter for symbolic values.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
Base class for most instruction semantics RISC operators.
InputOutputProperty
Boolean properties related to I/O.
Represents all memory in the state.
Hash hash(const std::vector< Ptr > &)
Hash zero or more expressions.