From 41f30cac90b873042e32446c1339319b5be07fe9 Mon Sep 17 00:00:00 2001 From: "podivilov@chromium.org" Date: Tue, 22 Mar 2011 18:02:23 +0000 Subject: [PATCH] Fix crash in Debug::SendCommand. R=vitalyr@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/6715029 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7310 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8-debug.h | 6 +++++- src/api.cc | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/v8-debug.h b/include/v8-debug.h index 10e8bef..0bdff84 100755 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -276,8 +276,12 @@ class EXPORT Debug { static void SetMessageHandler(MessageHandler handler, bool message_handler_thread = false); static void SetMessageHandler2(MessageHandler2 handler); + + // If no isolate is provided the default isolate is + // used. static void SendCommand(const uint16_t* command, int length, - ClientData* client_data = NULL); + ClientData* client_data = NULL, + Isolate* isolate = NULL); // Dispatch interface. static void SetHostDispatchHandler(HostDispatchHandler handler, diff --git a/src/api.cc b/src/api.cc index 20d3f39..e705237 100644 --- a/src/api.cc +++ b/src/api.cc @@ -4904,10 +4904,17 @@ void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { void Debug::SendCommand(const uint16_t* command, int length, - ClientData* client_data) { - if (!i::Isolate::Current()->IsInitialized()) return; - i::Isolate::Current()->debugger()->ProcessCommand( - i::Vector(command, length), client_data); + ClientData* client_data, + Isolate* isolate) { + // If no isolate is supplied, use the default isolate. + if (isolate != NULL) { + i::Isolate* internal_isolate = reinterpret_cast(isolate); + internal_isolate->debugger()->ProcessCommand( + i::Vector(command, length), client_data); + } else { + i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand( + i::Vector(command, length), client_data); + } } -- 2.7.4