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

Side by Side Diff: src/debug-agent.cc

Issue 6577036: [Isolates] Merge from bleeding_edge to isolates, revisions 6100-6300. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 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/debug-agent.h ('k') | src/debug-debugger.js » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 28
29 #include "v8.h" 29 #include "v8.h"
30 #include "debug.h"
30 #include "debug-agent.h" 31 #include "debug-agent.h"
31 32
32 #ifdef ENABLE_DEBUGGER_SUPPORT 33 #ifdef ENABLE_DEBUGGER_SUPPORT
34
33 namespace v8 { 35 namespace v8 {
34 namespace internal { 36 namespace internal {
35 37
36 // Public V8 debugger API message handler function. This function just delegates 38 // Public V8 debugger API message handler function. This function just delegates
37 // to the debugger agent through it's data parameter. 39 // to the debugger agent through it's data parameter.
38 void DebuggerAgentMessageHandler(const v8::Debug::Message& message) { 40 void DebuggerAgentMessageHandler(const v8::Debug::Message& message) {
39 DebuggerAgent* agent = Isolate::Current()->debugger_agent_instance(); 41 DebuggerAgent* agent = Isolate::Current()->debugger_agent_instance();
40 ASSERT(agent != NULL); 42 ASSERT(agent != NULL);
41 agent->DebuggerMessage(message); 43 agent->DebuggerMessage(message);
42 } 44 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 163
162 164
163 void DebuggerAgentSession::Run() { 165 void DebuggerAgentSession::Run() {
164 // Send the hello message. 166 // Send the hello message.
165 bool ok = DebuggerAgentUtil::SendConnectMessage(client_, *agent_->name_); 167 bool ok = DebuggerAgentUtil::SendConnectMessage(client_, *agent_->name_);
166 if (!ok) return; 168 if (!ok) return;
167 169
168 while (true) { 170 while (true) {
169 // Read data from the debugger front end. 171 // Read data from the debugger front end.
170 SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_); 172 SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_);
171 if (*message == NULL) { 173
172 // Session is closed. 174 const char* msg = *message;
173 agent_->OnSessionClosed(this); 175 bool is_closing_session = (msg == NULL);
174 return; 176
177 if (msg == NULL) {
178 // If we lost the connection, then simulate a disconnect msg:
179 msg = "{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}";
180
181 } else {
182 // Check if we're getting a disconnect request:
183 const char* disconnectRequestStr =
184 "\"type\":\"request\",\"command\":\"disconnect\"}";
185 const char* result = strstr(msg, disconnectRequestStr);
186 if (result != NULL) {
187 is_closing_session = true;
188 }
175 } 189 }
176 190
177 // Convert UTF-8 to UTF-16. 191 // Convert UTF-8 to UTF-16.
178 unibrow::Utf8InputBuffer<> buf(*message, 192 unibrow::Utf8InputBuffer<> buf(msg, StrLength(msg));
179 StrLength(*message));
180 int len = 0; 193 int len = 0;
181 while (buf.has_more()) { 194 while (buf.has_more()) {
182 buf.GetNext(); 195 buf.GetNext();
183 len++; 196 len++;
184 } 197 }
185 ScopedVector<int16_t> temp(len + 1); 198 ScopedVector<int16_t> temp(len + 1);
186 buf.Reset(*message, StrLength(*message)); 199 buf.Reset(msg, StrLength(msg));
187 for (int i = 0; i < len; i++) { 200 for (int i = 0; i < len; i++) {
188 temp[i] = buf.GetNext(); 201 temp[i] = buf.GetNext();
189 } 202 }
190 203
191 // Send the request received to the debugger. 204 // Send the request received to the debugger.
192 v8::Debug::SendCommand(reinterpret_cast<const uint16_t *>(temp.start()), 205 v8::Debug::SendCommand(reinterpret_cast<const uint16_t *>(temp.start()),
193 len); 206 len);
207
208 if (is_closing_session) {
209 // Session is closed.
210 agent_->OnSessionClosed(this);
211 return;
212 }
194 } 213 }
195 } 214 }
196 215
197 216
198 void DebuggerAgentSession::DebuggerMessage(Vector<uint16_t> message) { 217 void DebuggerAgentSession::DebuggerMessage(Vector<uint16_t> message) {
199 DebuggerAgentUtil::SendMessage(client_, message); 218 DebuggerAgentUtil::SendMessage(client_, message);
200 } 219 }
201 220
202 221
203 void DebuggerAgentSession::Shutdown() { 222 void DebuggerAgentSession::Shutdown() {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 return total_received; 438 return total_received;
420 } 439 }
421 total_received += received; 440 total_received += received;
422 } 441 }
423 return total_received; 442 return total_received;
424 } 443 }
425 444
426 } } // namespace v8::internal 445 } } // namespace v8::internal
427 446
428 #endif // ENABLE_DEBUGGER_SUPPORT 447 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/debug-agent.h ('k') | src/debug-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698