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

Unified Diff: src/debug-agent.h

Issue 27355: Add V8 debugger agent.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 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.cc ('k') | src/debug-agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-agent.h
===================================================================
--- src/debug-agent.h (revision 0)
+++ src/debug-agent.h (revision 0)
@@ -0,0 +1,109 @@
+// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef V8_V8_DEBUG_AGENT_H_
+#define V8_V8_DEBUG_AGENT_H_
+
+#include "../include/v8-debug.h"
+#include "platform.h"
+
+namespace v8 { namespace internal {
+
+
+// Forward decelrations.
+class DebuggerAgentSession;
+
+
+// Debugger agent which starts a socket listener on the debugger port and
+// handles connection from a remote debugger.
+class DebuggerAgent: public Thread {
+ public:
+ explicit DebuggerAgent(int port)
+ : port_(port), server_(OS::CreateSocket()), terminate_(false),
+ session_access_(OS::CreateMutex()), session_(NULL) {}
+ ~DebuggerAgent() {}
+
+ void Shutdown();
+
+ private:
+ void Run();
+ void CreateSession(Socket* socket);
+ void DebuggerMessage(const uint16_t* message, int length);
+ void SessionClosed(DebuggerAgentSession* session);
+
+ int port_; // Port to use for the agent.
+ Socket* server_; // Server socket for listen/accept.
+ bool terminate_; // Termination flag.
+ Mutex* session_access_; // Mutex guarging access to session_.
+ DebuggerAgentSession* session_; // Current active session if any.
+
+ friend class DebuggerAgentSession;
+ friend void DebuggerAgentMessageHandler(const uint16_t* message, int length,
+ void *data);
+
+ DISALLOW_COPY_AND_ASSIGN(DebuggerAgent);
+};
+
+
+// Debugger agent session. The session receives requests from the remote
+// debugger and sends debugger events/responses to the remote debugger.
+class DebuggerAgentSession: public Thread {
+ public:
+ DebuggerAgentSession(DebuggerAgent* agent, Socket* client)
+ : agent_(agent), client_(client) {}
+
+ void DebuggerMessage(Vector<uint16_t> message);
+
+ private:
+ void Run();
+
+ void DebuggerMessage(Vector<char> message);
+
+ DebuggerAgent* agent_;
+ const Socket* client_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebuggerAgentSession);
+};
+
+
+// Utility methods factored out to be used by the D8 shell as well.
+class DebuggerAgentUtil {
+ public:
+ static const char* kContentLength;
+ static int kContentLengthSize;
+
+ static SmartPointer<char> ReceiveMessage(const Socket* conn);
+ static bool SendMessage(const Socket* conn, const Vector<uint16_t> message);
+ static bool SendMessage(const Socket* conn,
+ const v8::Handle<v8::String> message);
+ static int ReceiveAll(const Socket* conn, char* data, int len);
+};
+
+
+} } // namespace v8::internal
+
+#endif // V8_V8_DEBUG_AGENT_H_
Property changes on: src\debug-agent.h
___________________________________________________________________
Added: svn:eol-style
+ native
« no previous file with comments | « src/debug.cc ('k') | src/debug-agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698