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_DEBUGGEE_PROCESS_H_ | |
5 #define DEBUGGER_CORE_DEBUGGEE_PROCESS_H_ | |
6 | |
7 #include <deque> | |
8 #include <map> | |
9 #include <string> | |
10 #include "debugger/base/debug_blob.h" | |
11 #include "debugger/core/debug_event.h" | |
12 | |
13 namespace debug { | |
14 class DebugAPI; | |
15 class DebuggeeThread; | |
16 | |
17 class DebuggeeProcess { | |
18 public: | |
19 explicit DebuggeeProcess (DebugAPI* debug_api); | |
20 virtual ~DebuggeeProcess (); | |
21 | |
22 /// @param[out] debug_event received debug event. | |
23 /// @return true if debug event is received, dispatched and process is halted. | |
24 /// Some debug events are ignored - and thread allowed to continue execution. | |
25 /// For example, all debug events for non-NaCl threads are ignored. | |
26 bool WaitForDebugEventAndDispatchIt(DebugEvent* debug_event); | |
27 | |
28 /// @param tid thread id | |
29 /// @return pointer to traced thread object, or NULL if there's no thread | |
30 /// with requested tid. Only NaClApp threads are been traced. | |
31 /// ExecutionEngine owns returned object, caller shall not delete it. | |
32 DebuggeeThread* GetThread(int tid); | |
33 | |
34 /// @param[out] pids list of all tracked threads | |
35 void GetThreadsIds(std::deque<int>* tids) const; | |
36 | |
37 uint64_t nexe_mem_base() const { return nexe_mem_base_; } | |
38 | |
39 void Continue(int tid); | |
40 | |
41 protected: | |
42 /// Handler of debug events. | |
43 /// @param[in] debug_event debug event received from debuggee process | |
44 /// @return true if process is halted. | |
45 bool OnDebugEvent(const DebugEvent& debug_event); | |
46 | |
47 DebugAPI& debug_api() { return debug_api_; } | |
48 | |
49 void StopAllThreads(); | |
50 bool AllThreadStopped(); | |
51 void DeleteThread(int tid); | |
52 | |
53 typedef std::deque<DebuggeeThread*>::const_iterator ThreadConstIter; | |
54 typedef std::deque<DebuggeeThread*>::iterator ThreadIter; | |
55 | |
56 private: | |
57 std::deque<DebuggeeThread*> threads_; | |
58 DebugAPI& debug_api_; | |
59 uint64_t nexe_mem_base_; | |
60 bool stopping_treads_; | |
61 bool is_first_event_; | |
62 | |
63 DebuggeeProcess (const DebuggeeProcess &); // DISALLOW_COPY_AND_ASSIGN | |
64 void operator=(const DebuggeeProcess &); | |
65 }; | |
66 } // namespace debug | |
67 | |
68 #endif // DEBUGGER_CORE_DEBUGGEE_PROCESS_H_ | |
69 | |
OLD | NEW |