Commit f987e30a authored by yurys's avatar yurys Committed by Commit bot

Extract common debugger code for processing compile events

BUG=chromium:520702
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#30517}
parent e7027442
......@@ -1814,29 +1814,6 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) {
}
void Debug::OnCompileError(Handle<Script> script) {
if (ignore_events()) return;
SuppressDebug while_processing(this);
if (in_debug_scope()) {
ProcessCompileEventInDebugScope(v8::CompileError, script);
return;
}
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
// Create the compile state object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
if (!MakeCompileEvent(script, v8::CompileError).ToHandle(&event_data)) return;
// Process debug event.
ProcessDebugEvent(v8::CompileError, Handle<JSObject>::cast(event_data), true);
}
void Debug::OnDebugBreak(Handle<Object> break_points_hit,
bool auto_continue) {
// The caller provided for DebugScope.
......@@ -1857,56 +1834,19 @@ void Debug::OnDebugBreak(Handle<Object> break_points_hit,
}
void Debug::OnBeforeCompile(Handle<Script> script) {
if (in_debug_scope() || ignore_events()) return;
SuppressDebug while_processing(this);
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
void Debug::OnCompileError(Handle<Script> script) {
ProcessCompileEvent(v8::CompileError, script);
}
// Create the event data object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
if (!MakeCompileEvent(script, v8::BeforeCompile).ToHandle(&event_data))
return;
// Process debug event.
ProcessDebugEvent(v8::BeforeCompile,
Handle<JSObject>::cast(event_data),
true);
void Debug::OnBeforeCompile(Handle<Script> script) {
ProcessCompileEvent(v8::BeforeCompile, script);
}
// Handle debugger actions when a new script is compiled.
void Debug::OnAfterCompile(Handle<Script> script) {
if (ignore_events()) return;
SuppressDebug while_processing(this);
if (in_debug_scope()) {
ProcessCompileEventInDebugScope(v8::AfterCompile, script);
return;
}
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
// If debugging there might be script break points registered for this
// script. Make sure that these break points are set.
Handle<Object> argv[] = {Script::GetWrapper(script)};
if (CallFunction("UpdateScriptBreakPoints", arraysize(argv), argv)
.is_null()) {
return;
}
// Create the compile state object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
if (!MakeCompileEvent(script, v8::AfterCompile).ToHandle(&event_data)) return;
// Process debug event.
ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true);
ProcessCompileEvent(v8::AfterCompile, script);
}
......@@ -2010,23 +1950,44 @@ void Debug::CallEventCallback(v8::DebugEvent event,
}
void Debug::ProcessCompileEventInDebugScope(v8::DebugEvent event,
Handle<Script> script) {
if (event_listener_.is_null()) return;
void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
if (ignore_events()) return;
SuppressDebug while_processing(this);
bool in_nested_debug_scope = in_debug_scope();
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
if (event == v8::AfterCompile) {
// If debugging there might be script break points registered for this
// script. Make sure that these break points are set.
Handle<Object> argv[] = {Script::GetWrapper(script)};
if (CallFunction("UpdateScriptBreakPoints", arraysize(argv), argv)
.is_null()) {
return;
}
}
// Create the compile state object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
if (!MakeCompileEvent(script, event).ToHandle(&event_data)) return;
// Create the execution state.
Handle<Object> exec_state;
// Bail out and don't call debugger if exception.
if (!MakeExecutionState().ToHandle(&exec_state)) return;
// Don't call NotifyMessageHandler if already in debug scope to avoid running
// nested command loop.
if (in_nested_debug_scope) {
if (event_listener_.is_null()) return;
// Create the execution state.
Handle<Object> exec_state;
// Bail out and don't call debugger if exception.
if (!MakeExecutionState().ToHandle(&exec_state)) return;
CallEventCallback(event, exec_state, event_data, NULL);
CallEventCallback(event, exec_state, event_data, NULL);
} else {
// Process debug event.
ProcessDebugEvent(event, Handle<JSObject>::cast(event_data), true);
}
}
......
......@@ -550,8 +550,7 @@ class Debug {
Handle<Object> exec_state,
Handle<Object> event_data,
v8::Debug::ClientData* client_data);
void ProcessCompileEventInDebugScope(v8::DebugEvent event,
Handle<Script> script);
void ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script);
void ProcessDebugEvent(v8::DebugEvent event,
Handle<JSObject> event_data,
bool auto_continue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment