From: sgjesse@chromium.org Date: Thu, 30 Oct 2008 10:27:28 +0000 (+0000) Subject: Added some missing initialization checks to the debugger API. X-Git-Tag: upstream/4.7.83~25074 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=52b2a126842e04171f109a9dc79526a7c8a03309;p=platform%2Fupstream%2Fv8.git Added some missing initialization checks to the debugger API. BUG=3723 (Chromium) Review URL: http://codereview.chromium.org/8909 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@648 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/api.cc b/src/api.cc index cdf0ed6d1..f17be0178 100644 --- a/src/api.cc +++ b/src/api.cc @@ -2800,8 +2800,8 @@ Local Exception::Error(v8::Handle raw_message) { bool Debug::AddDebugEventListener(DebugEventCallback that, Handle data) { - EnsureInitialized("v8::V8::AddDebugEventListener()"); - ON_BAILOUT("v8::V8::AddDebugEventListener()", return false); + EnsureInitialized("v8::Debug::AddDebugEventListener()"); + ON_BAILOUT("v8::Debug::AddDebugEventListener()", return false); HandleScope scope; NeanderArray listeners(i::Factory::debug_event_listeners()); NeanderObject obj(2); @@ -2817,7 +2817,7 @@ bool Debug::AddDebugEventListener(DebugEventCallback that, Handle data) { bool Debug::AddDebugEventListener(v8::Handle that, Handle data) { - ON_BAILOUT("v8::V8::AddDebugEventListener()", return false); + ON_BAILOUT("v8::Debug::AddDebugEventListener()", return false); HandleScope scope; NeanderArray listeners(i::Factory::debug_event_listeners()); NeanderObject obj(2); @@ -2832,8 +2832,8 @@ bool Debug::AddDebugEventListener(v8::Handle that, void Debug::RemoveDebugEventListener(DebugEventCallback that) { - EnsureInitialized("v8::V8::RemoveDebugEventListener()"); - ON_BAILOUT("v8::V8::RemoveDebugEventListener()", return); + EnsureInitialized("v8::Debug::RemoveDebugEventListener()"); + ON_BAILOUT("v8::Debug::RemoveDebugEventListener()", return); HandleScope scope; NeanderArray listeners(i::Factory::debug_event_listeners()); for (int i = 0; i < listeners.length(); i++) { @@ -2853,7 +2853,7 @@ void Debug::RemoveDebugEventListener(DebugEventCallback that) { void Debug::RemoveDebugEventListener(v8::Handle that) { - ON_BAILOUT("v8::V8::RemoveDebugEventListener()", return); + ON_BAILOUT("v8::Debug::RemoveDebugEventListener()", return); HandleScope scope; NeanderArray listeners(i::Factory::debug_event_listeners()); for (int i = 0; i < listeners.length(); i++) { @@ -2875,16 +2875,19 @@ void Debug::RemoveDebugEventListener(v8::Handle that) { void Debug::DebugBreak() { + if (!i::V8::HasBeenSetup()) return; i::StackGuard::DebugBreak(); } void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data) { + EnsureInitialized("v8::Debug::SetMessageHandler"); i::Debugger::SetMessageHandler(handler, data); } void Debug::SendCommand(const uint16_t* command, int length) { + if (!i::V8::HasBeenSetup()) return; i::Debugger::ProcessCommand(i::Vector(command, length)); } diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 2ad3347fb..ea819e0da 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -3131,3 +3131,38 @@ TEST(RecursiveBreakpoints) { breakpoints_v8_thread.Join(); breakpoints_debugger_thread.Join(); } + + +static void DummyDebugEventListener(v8::DebugEvent event, + v8::Handle exec_state, + v8::Handle event_data, + v8::Handle data) { +} + + +TEST(AddDebugEventListenerOnUninitializedVM) { + v8::Debug::AddDebugEventListener(DummyDebugEventListener); +} + + +static void DummyMessageHandler(const uint16_t* message, + int length, void *data) { +} + + +TEST(SetMessageHandlerOnUninitializedVM) { + v8::Debug::SetMessageHandler(DummyMessageHandler); +} + + +TEST(DebugBreakOnUninitializedVM) { + v8::Debug::DebugBreak(); +} + + +TEST(SendCommandToUninitializedVM) { + const char* dummy_command = "{}"; + uint16_t dummy_buffer[80]; + int dummy_length = AsciiToUtf16(dummy_command, dummy_buffer); + v8::Debug::SendCommand(dummy_buffer, dummy_length); +}