From 9f7ccacf865c598e9f6707bc7bb792a2726166f6 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Wed, 15 Apr 2009 19:09:38 +0000 Subject: [PATCH] Add debug command break flag for debugger host dispatch. Ensure that debugger host dispatch is processed even though there are no debugger commands in the queue. Review URL: http://codereview.chromium.org/67180 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1718 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/debug.cc | 12 +++++++++++- test/cctest/test-debug.cc | 24 +++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index 1374c15..a4bb04d 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1825,6 +1825,9 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event, Debugger::host_dispatch_handler_(reinterpret_cast(dispatch), Debugger::host_dispatch_handler_data_); } + if (auto_continue && !HasCommands()) { + return; + } continue; } @@ -2030,6 +2033,8 @@ void Debugger::ProcessCommand(Vector command) { Logger::DebugTag("Put command on command_queue."); command_queue_.Put(command_copy); command_received_->Signal(); + + // Set the debug command break flag to have the command processed. if (!Debug::InDebugger()) { StackGuard::DebugCommand(); } @@ -2042,7 +2047,7 @@ bool Debugger::HasCommands() { void Debugger::ProcessHostDispatch(void* dispatch) { -// Puts a host dispatch comming from the public API on the queue. + // Puts a host dispatch comming from the public API on the queue. uint16_t hack[3]; hack[0] = 0; hack[1] = reinterpret_cast(dispatch) >> 16; @@ -2050,6 +2055,11 @@ void Debugger::ProcessHostDispatch(void* dispatch) { Logger::DebugTag("Put dispatch on command_queue."); command_queue_.Put(Vector(hack, 3).Clone()); command_received_->Signal(); + + // Set the debug command break flag to have the host dispatch processed. + if (!Debug::InDebugger()) { + StackGuard::DebugCommand(); + } } diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 03ef70d..e482c7f 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -4025,19 +4025,33 @@ TEST(DebuggerHostDispatch) { "\"type\":\"request\"," "\"command\":\"continue\"}"; + // Create an empty function to call for processing debug commands + v8::Local empty = + CompileFunction(&env, "function empty(){}", "empty"); + // Setup message and host dispatch handlers. v8::Debug::SetMessageHandler(DummyMessageHandler); v8::Debug::SetHostDispatchHandler(HostDispatchHandlerHitCount, NULL); - // Fill a host dispatch and a continue command on the command queue before - // running some code. + // Send a host dispatch by itself. + v8::Debug::SendHostDispatch(NULL); + empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. + CHECK_EQ(1, host_dispatch_hit_count); + + // Fill a host dispatch and a continue command on the command queue. v8::Debug::SendHostDispatch(NULL); v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); - CompileRun("void 0"); + empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. - // The host dispatch callback should be called. - CHECK_EQ(1, host_dispatch_hit_count); + // Fill a continue command and a host dispatch on the command queue. + v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); + v8::Debug::SendHostDispatch(NULL); + empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. + empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. + + // All the host dispatch callback should be called. + CHECK_EQ(3, host_dispatch_hit_count); } -- 2.7.4