27 enum { kFlagNewProcess = (1 << 0), kFlagAttachedProcess = (1 << 1) };
28 typedef std::map<ThreadId, Thread *> IdentityMap;
38 Thread *_currentThread;
39 mutable std::unique_ptr<SoftwareBreakpointManager> _softwareBreakpointManager;
40 mutable std::unique_ptr<HardwareBreakpointManager> _hardwareBreakpointManager;
47 inline ProcessId pid()
const {
return _pid; }
50 inline bool attached()
const {
return (_flags & kFlagAttachedProcess) != 0; }
53 inline Address const &loadBase()
const {
return _loadBase; }
54 inline Address const &entryPoint()
const {
return _entryPoint; }
57 inline Thread *currentThread()
const {
58 return const_cast<ProcessBase *
>(
this)->_currentThread;
60 Thread *thread(ThreadId tid)
const;
63 virtual ErrorCode initialize(ProcessId pid, uint32_t flags);
69 virtual ErrorCode getAuxiliaryVector(std::string &auxv);
70 virtual uint64_t getAuxiliaryVectorValue(uint64_t type);
73 virtual void cleanup();
76 virtual ErrorCode detach() = 0;
79 virtual ErrorCode suspend();
81 resume(
int signal = 0,
82 std::set<Thread *>
const &excluded = std::set<Thread *>());
85 virtual ErrorCode interrupt() = 0;
86 virtual ErrorCode terminate() = 0;
87 virtual bool isAlive()
const = 0;
91 enumerateThreads(std::function<
void(Thread *)>
const &cb)
const;
94 virtual ErrorCode readString(
Address const &address, std::string &str,
95 size_t length,
size_t *nread =
nullptr) = 0;
96 virtual ErrorCode readMemory(
Address const &address,
void *buffer,
97 size_t length,
size_t *nread =
nullptr) = 0;
98 virtual ErrorCode writeMemory(
Address const &address,
void const *buffer,
99 size_t length,
size_t *nwritten =
nullptr) = 0;
102 virtual ErrorCode enumerateSharedLibraries(
105 enumerateMappedFiles(std::function<
void(
MappedFileInfo const &)>
const &cb);
108 ErrorCode readMemoryBuffer(
Address const &address,
size_t length,
110 ErrorCode writeMemoryBuffer(
Address const &address, ByteVector
const &buffer,
111 size_t *nwritten =
nullptr);
112 ErrorCode writeMemoryBuffer(
Address const &address, ByteVector
const &buffer,
113 size_t length,
size_t *nwritten =
nullptr);
116 virtual ErrorCode wait() = 0;
119 virtual ErrorCode allocateMemory(
size_t size, uint32_t protection,
120 uint64_t *address) = 0;
121 virtual ErrorCode deallocateMemory(uint64_t address,
size_t size) = 0;
124 virtual ErrorCode getMemoryRegionInfo(
Address const &address,
128 virtual void getThreadIds(std::vector<ThreadId> &tids);
131 virtual ErrorCode updateInfo() = 0;
138 virtual void prepareForDetach();
139 virtual ErrorCode beforeResume();
140 virtual ErrorCode afterResume();
143 virtual int getMaxBreakpoints()
const {
return 0; }
144 virtual int getMaxWatchpoints()
const {
return 0; }
145 virtual int getMaxWatchpointSize()
const {
return 0; }
150 getGDBRegistersDescriptor()
const final;
152 getLLDBRegistersDescriptor()
const final;
158 virtual void removeThread(ThreadId tid);