Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: experimental/mac_debugger/debug_api_mac.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/mac_debugger/README ('k') | experimental/mac_debugger/debug_api_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 EXPERIMENTAL_MAC_OOP_DEBUGGER_DEBUG_API_MAC_H_
5 #define EXPERIMENTAL_MAC_OOP_DEBUGGER_DEBUG_API_MAC_H_
6
7 #ifndef WIN32
8 #include <signal.h>
9 #include <sys/types.h>
10 #include <sys/ptrace.h>
11 #include <sys/user.h>
12 #include <mach/mach_vm.h>
13 #include <mach/mach.h>
14 #else
15 #include "mac_sys_mock.h"
16 #endif
17
18 #include <deque>
19 #include <string>
20
21 namespace debug {
22 enum ProcessState {
23 PROCESS_RUNNING,
24 PROCESS_STOPPED,
25 PROCESS_TERMINATED,
26 PROCESS_EXITED
27 };
28
29 // mach exceptions:
30 #define MACH_EXCEPTIONS_START_CODE 2000
31 #define MACH_BAD_ACCESS MACH_EXCEPTIONS_START_CODE + EXC_BAD_ACCESS
32 #define MACH_BAD_INSTRUCTION MACH_EXCEPTIONS_START_CODE + EXC_BAD_INSTRUCTION
33 #define MACH_ARITHMETIC MACH_EXCEPTIONS_START_CODE + EXC_ARITHMETIC
34 #define MACH_BREAKPOINT MACH_EXCEPTIONS_START_CODE + EXC_BREAKPOINT
35
36 /// Struct that receives information about the debugging event.
37 struct DebugEvent {
38 DebugEvent()
39 : pid_(0),
40 process_state_(PROCESS_STOPPED),
41 signal_no_(0),
42 exit_code_(0),
43 //child_pid_(0),
44 thread_(0),
45 task_(0) {}
46
47 void Print();
48
49 int pid_;
50 ProcessState process_state_;
51 int signal_no_; // Unix signals + mach exception codes
52 int exit_code_;
53 //int child_pid_; // Relevent only for SIGCHLD signal
54
55 // mach stuff
56 mach_port_t task_;
57 mach_port_t thread_; // can be used as tid
58 };
59
60 class DebugAPI {
61 public:
62 DebugAPI();
63
64 bool StartProcess(const char* cmd_line,
65 bool trace,
66 pid_t* child_pid_out);
67
68 bool WaitForDebugEvent(int wait_ms, DebugEvent* de);
69 bool ContinueDebugEvent(DebugEvent de, int signo);
70
71 bool SingleStep(DebugEvent de);
72 bool PostSignal(pid_t pid, int signo);
73 bool DebugBreak(pid_t pid);
74
75 bool GetThreadList(pid_t pid, std::deque<int>* list);
76
77 bool ReadProcessMemory(pid_t pid,
78 uint64_t addr,
79 void* dest,
80 size_t size,
81 size_t* readed_bytes_out);
82
83 bool WriteProcessMemory(pid_t pid,
84 uint64_t addr,
85 void* src,
86 size_t size,
87 size_t* written_bytes_out);
88
89 bool ReadThreadContext(int tid, x86_thread_state* context);
90 bool WriteThreadContext(int tid, const x86_thread_state& context);
91
92 bool ReadDebugString(const DebugEvent& de, std::string* string);
93
94 bool ReadIP(int tid, unsigned int* ip);
95 bool WriteIP(int tid, unsigned int ip);
96
97 bool EnableSingleStep(int pid, bool enable);
98
99 // br_no should be 0..3
100 bool SetHwBreakpoint(int tid, uint64_t addr, int br_no);
101
102 // Setups debuggee process to send mach exceptions our way.
103 // Shall be called only once.
104 bool HookupDebugeeProcess(pid_t pid);
105
106 private:
107 DebugAPI(const DebugAPI&); // DISALLOW_COPY_AND_ASSIGN
108 void operator=(const DebugAPI&);
109
110 bool WaitForMachException(int wait_ms, DebugEvent* de);
111
112 size_t page_size_;
113 mach_port_t exception_port_; // Exception port on which we will receive
114 // exceptions from debugee processes.
115 };
116
117 } // namespace debug
118 #endif // EXPERIMENTAL_MAC_OOP_DEBUGGER_DEBUG_API_MAC_H_
119
OLDNEW
« no previous file with comments | « experimental/mac_debugger/README ('k') | experimental/mac_debugger/debug_api_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698