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

Side by Side Diff: experimental/linux_debug_server/debugger/nacl-gdb_server/debug_server.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
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 DEBUGGER_NACL_GDB_SERVER_DEBUG_SERVER_H_
5 #define DEBUGGER_NACL_GDB_SERVER_DEBUG_SERVER_H_
6
7 #include "debugger/base/debug_socket.h"
8 #include "debugger/core/debug_api.h"
9 #include "debugger/core/debuggee_process.h"
10 #include "debugger/rsp/rsp_packetizer.h"
11 #include "debugger/rsp/rsp_packets.h"
12
13 namespace debug {
14 class DebugEvent;
15 class DebuggeeThread;
16
17 /// Class implementing the GDB RSP debug server for the NaCl applications.
18 /// It creates illusion to the client (debugger), that it debugs NaCl
19 /// application (aka nexe), hidding all other intermediate processes,
20 /// such as chrome + sel_ldr. It also hides all non-nexe threads.
21 /// For example of how to use it, look in nacl-gdb_server.cc.
22 ///
23 /// Note: current implementation has roughly the same set of features as
24 /// in-process debug stub (major difference is the support of Win32).
25 /// In order to be compatible with current VisualStudio debugger plugin,
26 /// it's also limited to one nexe per session.
27 class DebugServer : public rsp::PacketConsumerInterface,
28 public rsp::PacketVisitor {
29 public:
30 /// @param[in] debug_api pointer to DebugAPI object.
31 /// DebugServer doesn't take ownership of |debug_api|.
32 /// @param[in] listen_port port to listen on (for RSP client).
33 explicit DebugServer(DebugAPI* debug_api, int listen_port);
34 ~DebugServer();
35
36 /// Initializes internal objects.
37 /// @return true if operation succeeds.
38 bool Init();
39
40 /// Performs duty of debug server for no more than |wait_ms| milliseconds.
41 /// 1) Checks for incoming connection from the client (i.e. debugger).
42 /// 2) If connection is up, checks for incoming messages from the client.
43 /// 3) If RSP message has arrived, calls one of the rsp::PacketVisitor::Visit
44 /// methods (indirectly, see Visitor pattern).
45 /// 4) Calls ExecutionEngine::WaitForDebugEventAndDispatchIt method, handles
46 /// incoming debugger events.
47 void DoWork();
48
49 protected:
50 /// Starts listening for incoming RSP connection.
51 /// @return true if operation succeeds.
52 bool ListenForRspConnection();
53
54 void HandleNetwork();
55 void HandleExecutionEngine();
56 void SendRspMessageToClient(const rsp::Packet& msg);
57 void SendErrorReply(int error);
58
59 /// @return thread that has a user focus, i.e. thread that is used
60 /// in the processing of RSP messages.
61 /// Side effects: if there's no focused thread, sends error replies to
62 /// the client (i.e. debugger).
63 DebuggeeThread* GetFocusedThread();
64
65 void OnUnknownCommand();
66
67 // Inherited from rsp::PacketConsumer, see rsp/packets.h for more information.
68 virtual void OnPacket(const Blob& body, bool valid_checksum);
69 virtual void OnUnexpectedByte(uint8_t unexpected_byte);
70 virtual void OnBreak();
71
72 // Inherited from rsp::PacketVisitor
73 virtual void Visit(rsp::GetStopReasonCommand* packet);
74 virtual void Visit(rsp::ContinueCommand* packet);
75 virtual void Visit(rsp::QuerySupportedCommand* packet);
76 virtual void Visit(rsp::QXferFeaturesReadCommand* packet);
77 virtual void Visit(rsp::SetCurrentThreadCommand* packet);
78 virtual void Visit(rsp::ReadMemoryCommand* packet);
79 virtual void Visit(rsp::WriteMemoryCommand* packet);
80 virtual void Visit(rsp::ReadRegistersCommand* packet);
81 virtual void Visit(rsp::WriteRegistersCommand* packet);
82 virtual void Visit(rsp::GetCurrentThreadCommand* packet);
83 virtual void Visit(rsp::StepCommand* packet);
84 virtual void Visit(rsp::IsThreadAliveCommand* packet);
85 virtual void Visit(rsp::GetThreadInfoCommand* packet);
86 virtual void Visit(rsp::GetOffsetsCommand* packet);
87
88 protected:
89 DebugAPI* debug_api_;
90 ListeningSocket listening_socket_;
91 Socket client_connection_;
92 bool client_connected_;
93 rsp::Packetizer rsp_packetizer_;
94 DebuggeeProcess* debuggee_process_;
95 int focused_thread_id_;
96 int listen_port_;
97
98 // So that we don't send unsolicited rsp::StopReply.
99 bool continue_from_halt_;
100 };
101 } // namespace debug
102 #endif // DEBUGGER_NACL_GDB_SERVER_DEBUG_SERVER_H_
103
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698