OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 #ifndef DEBUGGER_CORE_DEBUG_API_H_ | |
5 #define DEBUGGER_CORE_DEBUG_API_H_ | |
6 #include <sys/ptrace.h> | |
7 #include <sys/types.h> | |
8 #include <sys/user.h> | |
9 #include <string> | |
10 | |
11 #include "debugger/base/debug_blob.h" | |
12 #include "debugger/core/debug_event.h" | |
13 | |
14 namespace debug { | |
15 /// This class is a layer on top of linux ptrace() syscall. | |
16 class DebugAPI { | |
17 public: | |
18 DebugAPI() {} | |
19 | |
20 bool StartProcess(const char* cmd_line, bool trace, pid_t* child_pid
_out); | |
21 bool SetupProc(pid_t pid); | |
22 | |
23 bool WaitForDebugEvent(DebugEvent* de); | |
24 | |
25 bool ContinueDebugEvent(pid_t pid, int signo); | |
26 bool SingleStep(pid_t pid); | |
27 bool PostSignal(pid_t pid, int signo); | |
28 bool DebugBreak(pid_t pid); | |
29 | |
30 bool ReadMemory(pid_t pid, | |
31 uint64_t addr, | |
32 void* dest, | |
33 size_t size, | |
34 size_t* readed_bytes_out); | |
35 | |
36 bool WriteMemory(pid_t pid, | |
37 uint64_t addr, | |
38 void* src, | |
39 size_t size, | |
40 size_t* written_bytes_out); | |
41 | |
42 bool ReadThreadContext(pid_t pid, user_regs_struct* context); | |
43 bool WriteThreadContext(pid_t pid, user_regs_struct* context); | |
44 | |
45 bool ReadDebugString(const DebugEvent& de, std::string* string); | |
46 | |
47 private: | |
48 DebugAPI(const DebugAPI&); // DISALLOW_COPY_AND_ASSIGN | |
49 void operator=(const DebugAPI&); | |
50 }; | |
51 } // namespace debug | |
52 #endif // DEBUGGER_CORE_DEBUG_API_H_ | |
53 | |
OLD | NEW |