ROSE  0.11.50.0
SharedMemory.h
1 #ifndef ROSE_BinaryAnalysis_Concolic_SharedMemory_H
2 #define ROSE_BinaryAnalysis_Concolic_SharedMemory_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_CONCOLIC_TESTING
5 
6 #include <Rose/BinaryAnalysis/Concolic/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/Types.h>
8 #include <Rose/BinaryAnalysis/SymbolicExpr.h>
9 
10 #include <Sawyer/Optional.h>
11 #include <Sawyer/SharedObject.h>
12 
13 namespace Rose {
14 namespace BinaryAnalysis {
15 namespace Concolic {
16 
18 // Shared memory context for callbacks
20 
24 class SharedMemoryContext {
25 public:
26  SharedMemoryContext() = delete;
27 
29  SharedMemoryContext(const ArchitecturePtr&, const ExecutionEventPtr &sharedMemoryEvent);
30 
32  SharedMemoryContext(const ArchitecturePtr&, const Emulation::RiscOperatorsPtr&,
33  const ExecutionEventPtr &sharedMemoryEvent);
34 
35  virtual ~SharedMemoryContext();
36 
37  /*------------------------------------------------------------------------------------------------------------
38  * Inputs to the callback
39  *------------------------------------------------------------------------------------------------------------*/
40 
47  ConcolicPhase phase = ConcolicPhase::EMULATION;
48 
50  ArchitecturePtr architecture;
51 
55  Emulation::RiscOperatorsPtr ops;
56 
58  rose_addr_t ip = 0;
59 
61  rose_addr_t memoryVa = 0;
62 
64  size_t nBytes = 0;
65 
67  IoDirection direction = IoDirection::READ;
68 
72  ExecutionEventPtr sharedMemoryEvent;
73 
79  SymbolicExpr::Ptr valueRead;
80 };
81 
83 // Callbacks to handle shared memory operations.
85 
87 class SharedMemoryCallback: public Sawyer::SharedObject {
88 public:
90  using Ptr = SharedMemoryCallbackPtr;
91 
92  virtual ~SharedMemoryCallback() {}
93 
97  void hello(const std::string &myName, const SharedMemoryContext&) const;
98 
104  virtual void playback(SharedMemoryContext&) = 0;
105 
124  virtual void handlePreSharedMemory(SharedMemoryContext&) = 0;
125  virtual void handlePostSharedMemory(SharedMemoryContext&) {}
128  virtual bool operator()(bool handled, SharedMemoryContext&) final;
129 };
130 
131 } // namespace
132 } // namespace
133 } // namespace
134 
135 #endif
136 #endif
Sawyer::SharedPointer< Node > Ptr
Shared-ownership pointer to an expression Node.
Definition: SymbolicExpr.h:156
Main namespace for the ROSE library.
const char * ops(int64_t)
Convert ops enum constant to a string.
Definition: stringify.C:9413
const char * direction(int64_t)
Convert CGFunction::iterator::direction enum constant to a string.
Definition: stringify.C:3135
Base class for reference counted objects.
Definition: SharedObject.h:64