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

Unified Diff: src/debug-agent.cc

Issue 52012: Extend debugger agent protocol with a connect message (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug-agent.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-agent.cc
===================================================================
--- src/debug-agent.cc (revision 1572)
+++ src/debug-agent.cc (working copy)
@@ -150,6 +150,10 @@
void DebuggerAgentSession::Run() {
+ // Send the hello message.
+ bool ok = DebuggerAgentUtil::SendConnectMessage(client_, *agent_->name_);
+ if (!ok) return;
+
while (true) {
// Read data from the debugger front end.
SmartPointer<char> message = DebuggerAgentUtil::ReceiveMessage(client_);
@@ -252,6 +256,9 @@
}
content_length = 10 * content_length + (value[i] - '0');
}
+ } else {
+ // For now just print all other headers than Content-Length.
+ PrintF("%s: %s\n", key, value);
}
// Start collecting new header.
@@ -264,6 +271,11 @@
}
}
+ // Return now if no body.
+ if (content_length == 0) {
+ return SmartPointer<char>();
+ }
+
// Read body.
char* buffer = NewArray<char>(content_length + 1);
received = ReceiveAll(conn, buffer, content_length);
@@ -277,6 +289,52 @@
}
+bool DebuggerAgentUtil::SendConnectMessage(const Socket* conn,
+ const char* embedding_host) {
+ static const int kBufferSize = 80;
+ char buffer[kBufferSize]; // Sending buffer.
+ bool ok;
+ int len;
+
+ // Send the header.
+ len = OS::SNPrintF(Vector<char>(buffer, kBufferSize),
+ "Type: connect\n");
+ ok = conn->Send(buffer, len);
+ if (!ok) return false;
+
+ len = OS::SNPrintF(Vector<char>(buffer, kBufferSize),
+ "V8-Version: %s\n", v8::V8::GetVersion());
+ ok = conn->Send(buffer, len);
+ if (!ok) return false;
+
+ len = OS::SNPrintF(Vector<char>(buffer, kBufferSize),
+ "Protocol-Version: 1\n");
+ ok = conn->Send(buffer, len);
+ if (!ok) return false;
+
+ if (embedding_host != NULL) {
+ len = OS::SNPrintF(Vector<char>(buffer, kBufferSize),
+ "Embedding-Host: %s\n", embedding_host);
+ ok = conn->Send(buffer, len);
+ if (!ok) return false;
+ }
+
+ len = OS::SNPrintF(Vector<char>(buffer, kBufferSize),
+ "%s: 0\n", kContentLength);
+ ok = conn->Send(buffer, len);
+ if (!ok) return false;
+
+ // Terminate header with empty line.
+ len = OS::SNPrintF(Vector<char>(buffer, kBufferSize), "\n");
+ ok = conn->Send(buffer, len);
+ if (!ok) return false;
+
+ // No body for connect message.
+
+ return true;
+}
+
+
bool DebuggerAgentUtil::SendMessage(const Socket* conn,
const Vector<uint16_t> message) {
static const int kBufferSize = 80;
@@ -291,7 +349,7 @@
// Send the header.
int len;
len = OS::SNPrintF(Vector<char>(buffer, kBufferSize),
- "Content-Length: %d\n", utf8_len);
+ "%s: %d\n", kContentLength, utf8_len);
conn->Send(buffer, len);
// Terminate header with empty line.
« no previous file with comments | « src/debug-agent.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698