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_DEBUG_SERVER_DEBUG_SERVER_H_ | |
5 #define DEBUGGER_DEBUG_SERVER_DEBUG_SERVER_H_ | |
6 | |
7 #include "debugger/base/debug_socket.h" | |
8 #include "debugger/core/debug_api.h" | |
9 #include "debugger/core/debug_execution_engine.h" | |
10 #include "debugger/core/debug_logger.h" | |
11 #include "debugger/rsp/rsp_packetizer.h" | |
12 #include "debugger/rsp/rsp_packet.h" | |
13 | |
14 namespace debug { | |
15 class DebugEvent; | |
16 class DebuggeeProcess; | |
17 | |
18 class DebugServer : public rsp::PacketConsumer, public rsp::PacketVisitor { | |
19 public: | |
20 DebugServer(); | |
21 ~DebugServer(); | |
22 | |
23 bool ListenOnPort(int port); | |
24 bool StartProcess(const char* cmd, const char* work_dir); | |
25 void DoWork(int wait_ms); | |
26 void Quit(); | |
27 | |
28 private: | |
29 // inherited from rsp::PacketConsumer | |
30 virtual void OnPacket(const Blob& body, bool valid_checksum); | |
31 virtual void OnUnexpectedChar(char unexpected_char); | |
32 virtual void OnBreak(); | |
33 | |
34 // inherited from rsp::PacketVisitor | |
35 virtual void Visit(rsp::GetStopReasonCommand* packet); | |
36 virtual void Visit(rsp::ContinueCommand* packet); | |
37 virtual void Visit(rsp::QuerySupportedCommand* packet); | |
38 virtual void Visit(rsp::QXferFeaturesReadCommand* packet); | |
39 virtual void Visit(rsp::SetCurrentThreadCommand* packet); | |
40 virtual void Visit(rsp::ReadMemoryCommand* packet); | |
41 virtual void Visit(rsp::WriteMemoryCommand* packet); | |
42 virtual void Visit(rsp::ReadRegistersCommand* packet); | |
43 virtual void Visit(rsp::WriteRegistersCommand* packet); | |
44 virtual void Visit(rsp::GetCurrentThreadCommand* packet); | |
45 virtual void Visit(rsp::StepCommand* packet); | |
46 virtual void Visit(rsp::IsThreadAliveCommand* packet); | |
47 virtual void Visit(rsp::GetThreadInfoCommand* packet); | |
48 | |
49 void OnHaltedProcess(IDebuggeeProcess* halted_process, | |
50 const DebugEvent& debug_event); | |
51 void PostRspMessage(const rsp::Packet& msg); | |
52 void OnUnknownCommand(); | |
53 bool ReadGdbRegisters(Blob* blob); | |
54 void GdbRegistersToCONTEXT(const Blob& gdb_regs, CONTEXT* ct); | |
55 | |
56 private: | |
57 bool connection_was_established_; | |
58 ListeningSocket listening_socket_; | |
59 Socket debugger_connection_; | |
60 rsp::Packetizer rsp_packetizer_; | |
61 ExecutionEngine* execution_engine_; | |
62 DebugAPI debug_api_; | |
63 Logger* logger_; | |
64 | |
65 int focused_process_id_; | |
66 int focused_thread_id_; | |
67 int main_nexe_thread_id_; | |
68 }; | |
69 } // namespace debug | |
70 #endif // DEBUGGER_DEBUG_SERVER_DEBUG_SERVER_H_ | |
OLD | NEW |