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

Side by Side Diff: runtime/bin/dbg_connection.h

Issue 10990089: First step towards support for being able to interrupt a running Dart Isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/dbg_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_DBG_CONNECTION_H_ 5 #ifndef BIN_DBG_CONNECTION_H_
6 #define BIN_DBG_CONNECTION_H_ 6 #define BIN_DBG_CONNECTION_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 13 matching lines...) Expand all
24 #include "bin/dbg_connection_win.h" 24 #include "bin/dbg_connection_win.h"
25 #else 25 #else
26 #error Unknown target os. 26 #error Unknown target os.
27 #endif 27 #endif
28 28
29 29
30 class MessageBuffer; 30 class MessageBuffer;
31 31
32 class DebuggerConnectionHandler { 32 class DebuggerConnectionHandler {
33 public: 33 public:
34 explicit DebuggerConnectionHandler(int debug_fd);
34 ~DebuggerConnectionHandler(); 35 ~DebuggerConnectionHandler();
36
37 // Accessors.
38 int debug_fd() const { return debug_fd_; }
39
40 // Return message id of current debug command message.
41 int MessageId();
42
43 // Starts the native thread which listens for connections from
44 // debugger clients, reads and dispatches debug command messages
45 // from the client.
35 static void StartHandler(const char* address, int port_number); 46 static void StartHandler(const char* address, int port_number);
36 47
37 static bool IsConnected() { 48 // Called by Isolates when they need to wait for a connection
38 return debugger_fd_ >= 0; 49 // from debugger clients.
39 } 50 static void WaitForConnection();
51
52 // Sends a reply or an error message to a specific debugger client.
53 static void SendMsg(int debug_fd, dart::TextBuffer* msg);
54 static void SendError(int debug_fd, int msg_id, const char* err_msg);
55
56 // Sends an event message to all debugger clients that are connected.
57 static void BroadcastMsg(dart::TextBuffer* msg);
40 58
41 private: 59 private:
42 static void SendMsg(dart::TextBuffer* msg); 60 void HandleUnknownMsg();
43 static void QueueMsg(dart::TextBuffer* msg); 61 void HandleMessages();
44 static void SendQueuedMsgs();
45 62
46 static void SendBreakpointEvent(Dart_StackTrace trace); 63 void CloseDbgConnection();
47 static void SendExceptionEvent(Dart_Handle exception, Dart_StackTrace trace);
48 static void BptResolvedHandler(intptr_t bp_id,
49 Dart_Handle url,
50 intptr_t line_number);
51 static void IsolateEventHandler(Dart_Isolate isolate, Dart_IsolateEvent kind);
52 static void BreakpointHandler(Dart_Breakpoint bpt, Dart_StackTrace trace);
53 static void ExceptionThrownHandler(Dart_Handle exception,
54 Dart_StackTrace stack_trace);
55 64
65 // The socket that connects with the debugger client.
66 // The descriptor is created and closed by the debugger connection thread.
67 int debug_fd_;
68
69 // Buffer holding the messages received over the wire from the debugger
70 // front end..
71 MessageBuffer* msgbuf_;
72
73 // Accepts connection requests from debugger client and sets up a
74 // connection handler object to read and handle messages from the client.
56 static void AcceptDbgConnection(int debug_fd); 75 static void AcceptDbgConnection(int debug_fd);
57 static void WaitForConnection();
58 static void CloseDbgConnection();
59 76
60 static void HandleMessages(); 77 // Handlers for generic debug command messages which are not specific to
61 static void HandleResumeCmd(const char* msg); 78 // an isolate.
62 static void HandleStepIntoCmd(const char* msg); 79 static void HandleInterruptCmd(DebuggerConnectionHandler* handler);
63 static void HandleStepOverCmd(const char* msg); 80 static void HandleIsolatesListCmd(DebuggerConnectionHandler* handler);
64 static void HandleStepOutCmd(const char* msg); 81 static void HandleQuitCmd(DebuggerConnectionHandler* handler);
65 static void HandleGetLibrariesCmd(const char* json_msg);
66 static void HandleGetClassPropsCmd(const char* json_msg);
67 static void HandleGetLibPropsCmd(const char* json_msg);
68 static void HandleSetLibPropsCmd(const char* json_msg);
69 static void HandleGetGlobalsCmd(const char* json_msg);
70 static void HandleGetObjPropsCmd(const char* json_msg);
71 static void HandleGetListCmd(const char* json_msg);
72 static void HandleGetScriptURLsCmd(const char* json_msg);
73 static void HandleGetSourceCmd(const char* json_msg);
74 static void HandleGetStackTraceCmd(const char* json_msg);
75 static void HandlePauseOnExcCmd(const char* json_msg);
76 static void HandleSetBpCmd(const char* json_msg);
77 static void HandleRemBpCmd(const char* json_msg);
78 static void HandleUnknownMsg(const char* json_msg);
79 82
80 static void SendError(int msg_id, const char* err_msg); 83 // Helper methods to manage debugger client connections.
84 static void AddNewDebuggerConnection(int debug_fd);
85 static void RemoveDebuggerConnection(int debug_fd);
86 static DebuggerConnectionHandler* GetDebuggerConnectionHandler(int debug_fd);
87 static bool IsConnected();
81 88
82 // Text buffer that accumulates messages to be sent to front end. 89 // Helper method for sending messages back to a debugger client.
83 static dart::TextBuffer queued_messages_; 90 static void SendMsgHelper(int debug_fd, dart::TextBuffer* msg);
84 91
85 static bool handler_started_; 92 // mutex/condition variable used by isolates when writing back to the
86 93 // debugger. This is also used to ensure that the isolate waits for
87 static bool request_resume_; 94 // a debugger to be attached when that is requested on the command line.
95 static dart::Monitor handler_lock_;
88 96
89 // The socket that is listening for incoming debugger connections. 97 // The socket that is listening for incoming debugger connections.
90 // This descriptor is created and closed by a VM thread. 98 // This descriptor is created and closed by a native thread.
91 static int listener_fd_; 99 static int listener_fd_;
92 100
93 // The socket that connects with the debugger client.
94 // The descriptor is created by the debugger connection thread and
95 // closed by a VM thread.
96 static int debugger_fd_;
97
98 // The VM thread waits on this condition variable when it reaches a
99 // breakpoint and the debugger client has not connected yet.
100 static dart::Monitor is_connected_;
101
102 static MessageBuffer* msgbuf_;
103
104 friend class DebuggerConnectionImpl; 101 friend class DebuggerConnectionImpl;
105 102
106 DISALLOW_ALLOCATION();
107 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); 103 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler);
108 }; 104 };
109 105
110 #endif // BIN_DBG_CONNECTION_H_ 106 #endif // BIN_DBG_CONNECTION_H_
OLDNEW
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/dbg_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698