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>
14namespace BinaryAnalysis {
15namespace InstructionSemantics {
18namespace NativeSemantics {
25typedef ConcreteSemantics::SValue SValue;
28typedef ConcreteSemantics::SValuePtr
SValuePtr;
31typedef ConcreteSemantics::Formatter
Formatter;
38typedef boost::shared_ptr<class RegisterState> RegisterStatePtr;
49 using Ptr = RegisterStatePtr;
52 Debugger::Linux::Ptr process_;
69 static RegisterStatePtr instance();
79 const RegisterDictionaryPtr&)
const override;
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;
148 Debugger::Linux::Ptr process_;
157 const Debugger::Linux::Ptr &process);
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]");
235typedef boost::shared_ptr<class State> StatePtr;
241class 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));
275class RiscOperators:
public ConcreteSemantics::RiscOperators {
278 using Super = ConcreteSemantics::RiscOperators;
314 const SmtSolverPtr &solver =
SmtSolverPtr())
const override;
332 Debugger::Linux::Ptr process()
const {
333 return RegisterState::promote(currentState()->registerState())->process();
353 Debugger::Linux::Ptr process_;
359 Dispatcher(
const Architecture::BaseConstPtr&,
const Debugger::Linux::Ptr &process,
const BaseSemantics::SValuePtr &protoval);
370 static DispatcherPtr instance(
const Architecture::BaseConstPtr&,
const Debugger::Linux::Ptr &process,
374 static DispatcherPtr instance(
const Architecture::BaseConstPtr&,
const Debugger::Linux::Specimen&,
402 void processInstruction(rose_addr_t va);
410 virtual RegisterDescriptor instructionPointerRegister()
const override;
411 virtual RegisterDescriptor stackPointerRegister()
const override;
412 virtual RegisterDescriptor stackFrameRegister()
const override;
413 virtual RegisterDescriptor callReturnRegister()
const override;
419 notApplicable(
"iprocReplace");
422 notApplicable(
"iprocSet");
425 notApplicable(
"iprocKey");
430 [[noreturn]]
void notApplicable(
const std::string &what)
const {
431 ASSERT_not_implemented(what +
" is not applicable for this class");
Dispatches instructions through the RISC layer.
Functor that knows how to dispatch a single kind of instruction.
Represents all memory in the state.
The set of all registers and their values.
Base class for most instruction semantics RISC operators.
Base class for machine instructions.
ROSE_DLL_API void clear()
Empties the memory pool of all nodes.
ROSE_DLL_API void merge(SgProject *project)
Performs sharing of AST nodes followed by linking accross translation units.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
InputOutputProperty
Boolean properties related to I/O.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer to a concrete memory state.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to concrete RISC operations.
BaseSemantics::Formatter Formatter
Formatter for symbolic values.
Sawyer::SharedPointer< class SValue > SValuePtr
Smart-ownership pointer to a concrete semantic value.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
Hash hash(const std::vector< Ptr > &)
Hash zero or more expressions.
void print(const StackVariables &, const Partitioner2::PartitionerConstPtr &, std::ostream &out, const std::string &prefix="")
Print info about multiple local variables.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.