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

Side by Side Diff: src/d8-debug.h

Issue 40011: Add remote debugging front end to developer shell.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | « src/d8.cc ('k') | src/d8-debug.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 23 matching lines...) Expand all
34 34
35 35
36 namespace v8 { 36 namespace v8 {
37 37
38 38
39 void HandleDebugEvent(DebugEvent event, 39 void HandleDebugEvent(DebugEvent event,
40 Handle<Object> exec_state, 40 Handle<Object> exec_state,
41 Handle<Object> event_data, 41 Handle<Object> event_data,
42 Handle<Value> data); 42 Handle<Value> data);
43 43
44 // Start the remove debugger connecting to a V8 debugger agent on the specified
45 // port.
46 void RunRemoteDebugger(int port);
47
48 // Forward declerations.
49 class RemoteDebuggerEvent;
50 class ReceiverThread;
51
52
53 // Remote debugging class.
54 class RemoteDebugger {
55 public:
56 explicit RemoteDebugger(int port)
57 : port_(port),
58 event_access_(i::OS::CreateMutex()),
59 event_available_(i::OS::CreateSemaphore(0)),
60 head_(NULL), tail_(NULL) {}
61 void Run();
62
63 // Handle events from the subordinate threads.
64 void MessageReceived(i::SmartPointer<char> message);
65 void KeyboardCommand(i::SmartPointer<char> command);
66 void ConnectionClosed();
67
68 private:
69 // Add new debugger event to the list.
70 void AddEvent(RemoteDebuggerEvent* event);
71 // Read next debugger event from the list.
72 RemoteDebuggerEvent* GetEvent();
73
74 // Handle a message from the debugged V8.
75 void HandleMessageReceived(char* message);
76 // Handle a keyboard command.
77 void HandleKeyboardCommand(char* command);
78
79 // Get connection to agent in debugged V8.
80 i::Socket* conn() { return conn_; }
81
82 int port_; // Port used to connect to debugger V8.
83 i::Socket* conn_; // Connection to debugger agent in debugged V8.
84
85 // Linked list of events from debugged V8 and from keyboard input. Access to
86 // the list is guarded by a mutex and a semaphore signals new items in the
87 // list.
88 i::Mutex* event_access_;
89 i::Semaphore* event_available_;
90 RemoteDebuggerEvent* head_;
91 RemoteDebuggerEvent* tail_;
92
93 friend class ReceiverThread;
94 };
95
96
97 // Thread reading from debugged V8 instance.
98 class ReceiverThread: public i::Thread {
99 public:
100 explicit ReceiverThread(RemoteDebugger* remote_debugger)
101 : remote_debugger_(remote_debugger) {}
102 ~ReceiverThread() {}
103
104 void Run();
105
106 private:
107 RemoteDebugger* remote_debugger_;
108 };
109
110
111 // Thread reading keyboard input.
112 class KeyboardThread: public i::Thread {
113 public:
114 explicit KeyboardThread(RemoteDebugger* remote_debugger)
115 : remote_debugger_(remote_debugger) {}
116 ~KeyboardThread() {}
117
118 void Run();
119
120 private:
121 RemoteDebugger* remote_debugger_;
122 };
123
124
125 // Events processed by the main deubgger thread.
126 class RemoteDebuggerEvent {
127 public:
128 RemoteDebuggerEvent(int type, i::SmartPointer<char> data)
129 : type_(type), data_(data), next_(NULL) {
130 ASSERT(type == kMessage || type == kKeyboard || type == kDisconnect);
131 }
132
133 static const int kMessage = 1;
134 static const int kKeyboard = 2;
135 static const int kDisconnect = 3;
136
137 int type() { return type_; }
138 char* data() { return *data_; }
139
140 private:
141 void set_next(RemoteDebuggerEvent* event) { next_ = event; }
142 RemoteDebuggerEvent* next() { return next_; }
143
144 int type_;
145 i::SmartPointer<char> data_;
146 RemoteDebuggerEvent* next_;
147
148 friend class RemoteDebugger;
149 };
150
44 151
45 } // namespace v8 152 } // namespace v8
46 153
47 154
48 #endif // V8_D8_DEBUG_H_ 155 #endif // V8_D8_DEBUG_H_
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | src/d8-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698