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);
123 virtual void print(std::ostream&, Formatter&)
const override;
142 using Ptr = MemoryStatePtr;
145 Debugger::Linux::Ptr process_;
154 const Debugger::Linux::Ptr &process);
163 static MemoryStatePtr instance();
167 const Debugger::Linux::Ptr &process);
189 Debugger::Linux::Ptr process()
const;
195 virtual void clear()
override {}
199 ASSERT_not_implemented(
"not applicable for this class");
205 return peekMemory(address, dflt, addrOps, valOps);
214 ASSERT_not_implemented(
"[Robb Matzke 2019-09-05]");
219 ASSERT_not_implemented(
"[Robb Matzke 2021-03-26]");
223 ASSERT_not_implemented(
"[Robb Matzke 2019-09-05]");
232 typedef boost::shared_ptr<class State> StatePtr;
238 class State:
public ConcreteSemantics::State, boost::noncopyable {
241 using Super = ConcreteSemantics::State;
244 using Ptr = StatePtr;
251 : ConcreteSemantics::
State(registers, memory) {
252 (void) RegisterState::promote(registers);
253 (void) MemoryState::promote(memory);
261 return StatePtr(
new State(registers, memory));
272 class RiscOperators:
public ConcreteSemantics::RiscOperators {
275 using Super = ConcreteSemantics::RiscOperators;
278 using Ptr = RiscOperatorsPtr;
297 static RiscOperatorsPtr instanceFromProtoval(
const BaseSemantics::SValuePtr &protoval,
const Debugger::Linux::Ptr &process);
329 Debugger::Linux::Ptr process()
const {
330 return RegisterState::promote(currentState()->registerState())->process();
347 using Ptr = DispatcherPtr;
350 Debugger::Linux::Ptr process_;
367 static DispatcherPtr instance(
const Debugger::Linux::Ptr &process,
const BaseSemantics::SValuePtr &protoval = SValue::instance());
370 static DispatcherPtr instance(
const Debugger::Linux::Specimen&,
const BaseSemantics::SValuePtr &protoval = SValue::instance());
397 void processInstruction(rose_addr_t va);
405 virtual RegisterDescriptor instructionPointerRegister()
const override;
406 virtual RegisterDescriptor stackPointerRegister()
const override;
407 virtual RegisterDescriptor stackFrameRegister()
const override;
408 virtual RegisterDescriptor callReturnRegister()
const override;
414 notApplicable(
"iprocReplace");
417 notApplicable(
"iprocSet");
420 notApplicable(
"iprocKey");
425 [[noreturn]]
void notApplicable(
const std::string &what)
const {
426 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.
void print(const StackVariables &, const Partitioner2::Partitioner &, std::ostream &out, const std::string &prefix="")
Print info about multiple local variables.
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.
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.
Represents all memory in the state.
Hash hash(const std::vector< Ptr > &)
Hash zero or more expressions.