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

Unified Diff: src/debug-agent.cc

Issue 5980006: Misc debugger enhancements and bug fixes.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: src/debug-agent.cc
===================================================================
--- src/debug-agent.cc (revision 6117)
+++ src/debug-agent.cc (working copy)
@@ -27,9 +27,11 @@
#include "v8.h"
+#include "debug.h"
#include "debug-agent.h"
#ifdef ENABLE_DEBUGGER_SUPPORT
+
namespace v8 {
namespace internal {
@@ -167,22 +169,46 @@
while (true) {
// Read data from the debugger front end.
SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_);
- if (*message == NULL) {
- // Session is closed.
- agent_->OnSessionClosed(this);
- return;
+
+ const char *msg = *message;
Søren Thygesen Gjesse 2011/01/03 08:56:07 Please avoid mixed case variables, see http://goog
marklam 2011/01/04 20:12:13 Done.
+ bool isBreakRequest = false;
+ bool isClosingSession = (msg == NULL);
+
+ if (msg == NULL) {
+ // If we lost the connection, then simulate a disconnect msg:
+ msg = "{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}";
+
+ } else {
+ // Check if we're getting a break request:
Søren Thygesen Gjesse 2011/01/03 08:56:07 These checks seems pretty fragile, and depends on
marklam 2011/01/04 20:12:13 I see what you mean. But yes, at least as a first
+ const char *breakRequestStr =
+ "\"type\":\"request\",\"command\":\"break\"}";
+ const char *result = strstr(msg, breakRequestStr);
+ if (result != NULL) {
+ isBreakRequest = true;
+ } else {
+ // Check if we're getting a disconnect request:
+ const char *disconnectRequestStr =
+ "\"type\":\"request\",\"command\":\"disconnect\"}";
+ result = strstr(msg, disconnectRequestStr);
+ if (result != NULL) {
+ isClosingSession = true;
+ }
+ }
}
+ if (isBreakRequest && !Debug::InDebugger()) {
Søren Thygesen Gjesse 2011/01/03 08:56:07 Is this required? Sending the command using v8::De
marklam 2011/01/04 20:12:13 Hmmm. This used to be needed, but I just re-teste
+ v8::Debug::DebugBreak();
+ }
+
// Convert UTF-8 to UTF-16.
- unibrow::Utf8InputBuffer<> buf(*message,
- StrLength(*message));
+ unibrow::Utf8InputBuffer<> buf(msg, StrLength(msg));
int len = 0;
while (buf.has_more()) {
buf.GetNext();
len++;
}
ScopedVector<int16_t> temp(len + 1);
- buf.Reset(*message, StrLength(*message));
+ buf.Reset(msg, StrLength(msg));
for (int i = 0; i < len; i++) {
temp[i] = buf.GetNext();
}
@@ -190,6 +216,12 @@
// Send the request received to the debugger.
v8::Debug::SendCommand(reinterpret_cast<const uint16_t *>(temp.start()),
len);
+
+ if (isClosingSession) {
+ // Session is closed.
+ agent_->OnSessionClosed(this);
+ return;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698