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

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

Issue 6080009: Revert r6180 as it caused test failures (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 11 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.cc ('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"
31 #include "debug-agent.h" 30 #include "debug-agent.h"
32 31
33 #ifdef ENABLE_DEBUGGER_SUPPORT 32 #ifdef ENABLE_DEBUGGER_SUPPORT
34
35 namespace v8 { 33 namespace v8 {
36 namespace internal { 34 namespace internal {
37 35
38 // Public V8 debugger API message handler function. This function just delegates 36 // Public V8 debugger API message handler function. This function just delegates
39 // to the debugger agent through it's data parameter. 37 // to the debugger agent through it's data parameter.
40 void DebuggerAgentMessageHandler(const v8::Debug::Message& message) { 38 void DebuggerAgentMessageHandler(const v8::Debug::Message& message) {
41 DebuggerAgent::instance_->DebuggerMessage(message); 39 DebuggerAgent::instance_->DebuggerMessage(message);
42 } 40 }
43 41
44 // static 42 // static
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 160
163 161
164 void DebuggerAgentSession::Run() { 162 void DebuggerAgentSession::Run() {
165 // Send the hello message. 163 // Send the hello message.
166 bool ok = DebuggerAgentUtil::SendConnectMessage(client_, *agent_->name_); 164 bool ok = DebuggerAgentUtil::SendConnectMessage(client_, *agent_->name_);
167 if (!ok) return; 165 if (!ok) return;
168 166
169 while (true) { 167 while (true) {
170 // Read data from the debugger front end. 168 // Read data from the debugger front end.
171 SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_); 169 SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_);
172 170 if (*message == NULL) {
173 const char* msg = *message; 171 // Session is closed.
174 bool is_closing_session = (msg == NULL); 172 agent_->OnSessionClosed(this);
175 173 return;
176 if (msg == NULL) {
177 // If we lost the connection, then simulate a disconnect msg:
178 msg = "{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}";
179
180 } else {
181 // Check if we're getting a disconnect request:
182 const char* disconnectRequestStr =
183 "\"type\":\"request\",\"command\":\"disconnect\"}";
184 const char* result = strstr(msg, disconnectRequestStr);
185 if (result != NULL) {
186 is_closing_session = true;
187 }
188 } 174 }
189 175
190 // Convert UTF-8 to UTF-16. 176 // Convert UTF-8 to UTF-16.
191 unibrow::Utf8InputBuffer<> buf(msg, StrLength(msg)); 177 unibrow::Utf8InputBuffer<> buf(*message,
178 StrLength(*message));
192 int len = 0; 179 int len = 0;
193 while (buf.has_more()) { 180 while (buf.has_more()) {
194 buf.GetNext(); 181 buf.GetNext();
195 len++; 182 len++;
196 } 183 }
197 ScopedVector<int16_t> temp(len + 1); 184 ScopedVector<int16_t> temp(len + 1);
198 buf.Reset(msg, StrLength(msg)); 185 buf.Reset(*message, StrLength(*message));
199 for (int i = 0; i < len; i++) { 186 for (int i = 0; i < len; i++) {
200 temp[i] = buf.GetNext(); 187 temp[i] = buf.GetNext();
201 } 188 }
202 189
203 // Send the request received to the debugger. 190 // Send the request received to the debugger.
204 v8::Debug::SendCommand(reinterpret_cast<const uint16_t *>(temp.start()), 191 v8::Debug::SendCommand(reinterpret_cast<const uint16_t *>(temp.start()),
205 len); 192 len);
206
207 if (is_closing_session) {
208 // Session is closed.
209 agent_->OnSessionClosed(this);
210 return;
211 }
212 } 193 }
213 } 194 }
214 195
215 196
216 void DebuggerAgentSession::DebuggerMessage(Vector<uint16_t> message) { 197 void DebuggerAgentSession::DebuggerMessage(Vector<uint16_t> message) {
217 DebuggerAgentUtil::SendMessage(client_, message); 198 DebuggerAgentUtil::SendMessage(client_, message);
218 } 199 }
219 200
220 201
221 void DebuggerAgentSession::Shutdown() { 202 void DebuggerAgentSession::Shutdown() {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 return total_received; 418 return total_received;
438 } 419 }
439 total_received += received; 420 total_received += received;
440 } 421 }
441 return total_received; 422 return total_received;
442 } 423 }
443 424
444 } } // namespace v8::internal 425 } } // namespace v8::internal
445 426
446 #endif // ENABLE_DEBUGGER_SUPPORT 427 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/debug-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698