Debugger: remove debug command API.

Instead, please use v8::Isolate::RequestInterrupt to synchronize
to the main thread.

R=yurys@chromium.org
API=Removed v8::Debug::DebugBreakForCommand
LOG=Y

Review URL: https://codereview.chromium.org/1036863002

Cr-Commit-Position: refs/heads/master@{#27625}
This commit is contained in:
yangguo 2015-04-07 05:21:34 -07:00 committed by Commit bot
parent 8e846a6166
commit 8e723e9892
6 changed files with 20 additions and 113 deletions

View File

@ -170,13 +170,6 @@ class V8_EXPORT Debug {
// Check if a debugger break is scheduled in the given isolate.
static bool CheckDebugBreak(Isolate* isolate);
// Break execution of JavaScript in the given isolate (this method
// can be invoked from a non-VM thread) for further client command
// execution on a VM thread. Client data is then passed in
// EventDetails to EventCallback2 at the moment when the VM actually
// stops.
static void DebugBreakForCommand(Isolate* isolate, ClientData* data);
// Message based interface. The message protocol is JSON.
static void SetMessageHandler(MessageHandler handler);

View File

@ -7359,12 +7359,6 @@ bool Debug::CheckDebugBreak(Isolate* isolate) {
}
void Debug::DebugBreakForCommand(Isolate* isolate, ClientData* data) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->EnqueueDebugCommand(data);
}
void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) {
i::Isolate* isolate = i::Isolate::Current();
ENTER_V8(isolate);

View File

@ -34,7 +34,6 @@ Debug::Debug(Isolate* isolate)
message_handler_(NULL),
command_received_(0),
command_queue_(isolate->logger(), kQueueInitialSize),
event_command_queue_(isolate->logger(), kQueueInitialSize),
is_active_(false),
is_suppressed_(false),
live_edit_enabled_(true), // TODO(yangguo): set to false by default.
@ -2746,19 +2745,6 @@ void Debug::ProcessDebugEvent(v8::DebugEvent event,
if ((event != v8::Break || !auto_continue) && !event_listener_.is_null()) {
CallEventCallback(event, exec_state, event_data, NULL);
}
// Process pending debug commands.
if (event == v8::Break) {
while (!event_command_queue_.IsEmpty()) {
CommandMessage command = event_command_queue_.Get();
if (!event_listener_.is_null()) {
CallEventCallback(v8::BreakForCommand,
exec_state,
event_data,
command.client_data());
}
command.Dispose();
}
}
}
@ -3033,15 +3019,6 @@ void Debug::EnqueueCommandMessage(Vector<const uint16_t> command,
}
void Debug::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
CommandMessage message = CommandMessage::New(Vector<uint16_t>(), client_data);
event_command_queue_.Put(message);
// Set the debug command break flag to have the command processed.
if (!in_debug_scope()) isolate_->stack_guard()->RequestDebugCommand();
}
MaybeHandle<Object> Debug::Call(Handle<JSFunction> fun, Handle<Object> data) {
DebugScope debug_scope(this);
if (debug_scope.failed()) return isolate_->factory()->undefined_value();

View File

@ -440,8 +440,6 @@ class Debug {
void SetMessageHandler(v8::Debug::MessageHandler handler);
void EnqueueCommandMessage(Vector<const uint16_t> command,
v8::Debug::ClientData* client_data = NULL);
// Enqueue a debugger command to the command queue for event listeners.
void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL);
MUST_USE_RESULT MaybeHandle<Object> Call(Handle<JSFunction> fun,
Handle<Object> data);
Handle<Context> GetDebugContext();
@ -669,7 +667,6 @@ class Debug {
static const int kQueueInitialSize = 4;
base::Semaphore command_received_; // Signaled for each command received.
LockingCommandMessageQueue command_queue_;
LockingCommandMessageQueue event_command_queue_;
bool is_active_;
bool is_suppressed_;

View File

@ -20247,6 +20247,26 @@ class RequestMultipleInterrupts : public RequestInterruptTestBase {
TEST(RequestMultipleInterrupts) { RequestMultipleInterrupts().RunTest(); }
static bool interrupt_was_called = false;
void SmallScriptsInterruptCallback(v8::Isolate* isolate, void* data) {
interrupt_was_called = true;
}
TEST(RequestInterruptSmallScripts) {
LocalContext env;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
interrupt_was_called = false;
isolate->RequestInterrupt(&SmallScriptsInterruptCallback, NULL);
CompileRun("(function(x){return x;})(1);");
CHECK(interrupt_was_called);
}
static Local<Value> function_new_expected_env;
static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) {
CHECK(function_new_expected_env->Equals(info.Data()));

View File

@ -6943,80 +6943,6 @@ TEST(DebugEventContext) {
}
static void* expected_break_data;
static bool was_debug_break_called;
static bool was_debug_event_called;
static void DebugEventBreakDataChecker(const v8::Debug::EventDetails& details) {
if (details.GetEvent() == v8::BreakForCommand) {
CHECK_EQ(expected_break_data, details.GetClientData());
was_debug_event_called = true;
} else if (details.GetEvent() == v8::Break) {
was_debug_break_called = true;
}
}
// Check that event details contain context where debug event occured.
TEST(DebugEventBreakData) {
DebugLocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::Debug::SetDebugEventListener(DebugEventBreakDataChecker);
TestClientData::constructor_call_counter = 0;
TestClientData::destructor_call_counter = 0;
expected_break_data = NULL;
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreakForCommand(isolate, NULL);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x;})(1);"))
->Run();
CHECK(was_debug_event_called);
CHECK(!was_debug_break_called);
TestClientData* data1 = new TestClientData();
expected_break_data = data1;
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreakForCommand(isolate, data1);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x+1;})(1);"))
->Run();
CHECK(was_debug_event_called);
CHECK(!was_debug_break_called);
expected_break_data = NULL;
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreak(isolate);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x+2;})(1);"))
->Run();
CHECK(!was_debug_event_called);
CHECK(was_debug_break_called);
TestClientData* data2 = new TestClientData();
expected_break_data = data2;
was_debug_event_called = false;
was_debug_break_called = false;
v8::Debug::DebugBreak(isolate);
v8::Debug::DebugBreakForCommand(isolate, data2);
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"(function(x){return x+3;})(1);"))
->Run();
CHECK(was_debug_event_called);
CHECK(was_debug_break_called);
CHECK_EQ(2, TestClientData::constructor_call_counter);
CHECK_EQ(TestClientData::constructor_call_counter,
TestClientData::destructor_call_counter);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
static bool debug_event_break_deoptimize_done = false;
static void DebugEventBreakDeoptimize(