Reviewers: Søren Gjesse, Message: Hi Soren
I'm putting "wait for connection" feature separately into this CL. > I am not sure what happens here when the wait for debugger connection > flag is > set. I think this should disable "autocontinue" behavior of V8 when there is not message handler. So that once V8 paused, it simply stays paused. > Isn't V8 execution supposed to wait until a debugger comes along and > processes the first debugger message? Probably we should support both options: V8 is waiting for debugger connection and V8 starts without connection. Currently we support only second scenario. > Should the debug break flag be raised to > ensure that a break will happen as soon as any code is executed? I didn't think about this. I though about manually putting "debugger;" statement in the beginning of program. Probably I should try to with this runtime flag. > You will need to provide some test which uses and tests this new flag. > There are > some tests covering the DebugAgent, but they probably needs to be > extended. I'm working on this. Description: Implement "wait for connection" feature Please review this at http://codereview.chromium.org/489005 Affected files: M include/v8-debug.h M src/api.cc M src/debug.h M src/debug.cc Index: include/v8-debug.h diff --git a/include/v8-debug.h b/include/v8-debug.h index b27bacc1080123b11f6a93c3302147aac3013b0d..fec813a3e3fb80e44156f19f03c9f869ee802f01 100644 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -258,8 +258,10 @@ class EXPORT Debug { * supplied TCP/IP port for remote debugger connection. * \param name the name of the embedding application * \param port the TCP/IP port to listen on + * \param wait_for_connection whether V8 should pause on a first breakpoint + * allowing remote debugger to connect before anything interesting happened */ - static bool EnableAgent(const char* name, int port); + static bool EnableAgent(const char* name, int port, bool wait_for_connection); }; Index: src/api.cc diff --git a/src/api.cc b/src/api.cc index 93807a7c72c1401f7c7b5faa92b560aae07f640b..46a034ec2bb5cc15df52ac61b36aced8a4d8a637 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3827,8 +3827,8 @@ Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { } -bool Debug::EnableAgent(const char* name, int port) { - return i::Debugger::StartAgent(name, port); +bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { + return i::Debugger::StartAgent(name, port, wait_for_connection); } #endif // ENABLE_DEBUGGER_SUPPORT Index: src/debug.cc diff --git a/src/debug.cc b/src/debug.cc index 2c4552effeabb5ab42abea5f91d97a9c7fe99329..4ef3597e43fde5e15a51daf1d3b1cb3a2f38a156 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -2483,7 +2483,20 @@ Handle<Object> Debugger::Call(Handle<JSFunction> fun, } -bool Debugger::StartAgent(const char* name, int port) { +static void StubMessageHandler2(const v8::Debug::Message& message) { + // Simply ignore message. +} + + +bool Debugger::StartAgent(const char* name, int port, + bool wait_for_connection) { + if (wait_for_connection) { + // Ignore all events until remote debugger has connected. + // Should V8 suspend on breakpoint, it will wait indefinitely long + // until somebody connects and sends "resume" command. + Debugger::message_handler_ = StubMessageHandler2; + } + if (Socket::Setup()) { agent_ = new DebuggerAgent(name, port); agent_->Start(); Index: src/debug.h diff --git a/src/debug.h b/src/debug.h index 24f0db4133d26986c0823d0f624c63fdf82ece5b..096916ed995f4ddca99f47b491aad3a78abe7294 100644 --- a/src/debug.h +++ b/src/debug.h @@ -636,7 +636,7 @@ class Debugger { bool* pending_exception); // Start the debugger agent listening on the provided port. - static bool StartAgent(const char* name, int port); + static bool StartAgent(const char* name, int port, bool wait_for_connection); // Stop the debugger agent. static void StopAgent(); -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
