[V8] Report v8::AfterCompile and v8::CompileError to listener on pause
V8 didn't report compile events on pause before this patch. These events can be important for listener. For example, DevTools allows user to execute some JS code on pause and needs to show correct stack trace in message from it. BUG=396013 R=yurys@chromium.org Review URL: https://codereview.chromium.org/781623004 Cr-Commit-Position: refs/heads/master@{#25767}
This commit is contained in:
parent
1b316ed0ad
commit
affe4c03b6
37
src/debug.cc
37
src/debug.cc
@ -2630,8 +2630,12 @@ void Debug::OnException(Handle<Object> exception, bool uncaught,
|
||||
|
||||
|
||||
void Debug::OnCompileError(Handle<Script> script) {
|
||||
// No more to do if not debugging.
|
||||
if (in_debug_scope() || ignore_events()) return;
|
||||
if (ignore_events()) return;
|
||||
|
||||
if (in_debug_scope()) {
|
||||
ProcessCompileEventInDebugScope(v8::CompileError, script);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleScope scope(isolate_);
|
||||
DebugScope debug_scope(this);
|
||||
@ -2692,8 +2696,12 @@ void Debug::OnAfterCompile(Handle<Script> script) {
|
||||
// Add the newly compiled script to the script cache.
|
||||
if (script_cache_ != NULL) script_cache_->Add(script);
|
||||
|
||||
// No more to do if not debugging.
|
||||
if (in_debug_scope() || ignore_events()) return;
|
||||
if (ignore_events()) return;
|
||||
|
||||
if (in_debug_scope()) {
|
||||
ProcessCompileEventInDebugScope(v8::AfterCompile, script);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleScope scope(isolate_);
|
||||
DebugScope debug_scope(this);
|
||||
@ -2848,6 +2856,27 @@ void Debug::CallEventCallback(v8::DebugEvent event,
|
||||
}
|
||||
|
||||
|
||||
void Debug::ProcessCompileEventInDebugScope(v8::DebugEvent event,
|
||||
Handle<Script> script) {
|
||||
if (event_listener_.is_null()) return;
|
||||
|
||||
SuppressDebug while_processing(this);
|
||||
DebugScope debug_scope(this);
|
||||
if (debug_scope.failed()) return;
|
||||
|
||||
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;
|
||||
|
||||
CallEventCallback(event, exec_state, event_data, NULL);
|
||||
}
|
||||
|
||||
|
||||
Handle<Context> Debug::GetDebugContext() {
|
||||
DebugScope debug_scope(this);
|
||||
// The global handle may be destroyed soon after. Return it reboxed.
|
||||
|
@ -553,6 +553,8 @@ class Debug {
|
||||
Handle<Object> exec_state,
|
||||
Handle<Object> event_data,
|
||||
v8::Debug::ClientData* client_data);
|
||||
void ProcessCompileEventInDebugScope(v8::DebugEvent event,
|
||||
Handle<Script> script);
|
||||
void ProcessDebugEvent(v8::DebugEvent event,
|
||||
Handle<JSObject> event_data,
|
||||
bool auto_continue);
|
||||
|
@ -36,13 +36,17 @@ var exception = false;
|
||||
|
||||
var base_request = '"seq":0,"type":"request","command":"clearbreakpointgroup"';
|
||||
var scriptId = null;
|
||||
var muteListener = false;
|
||||
|
||||
function safeEval(code) {
|
||||
try {
|
||||
muteListener = true;
|
||||
return eval('(' + code + ')');
|
||||
} catch (e) {
|
||||
assertEquals(void 0, e);
|
||||
return undefined;
|
||||
} finally {
|
||||
muteListener = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +62,7 @@ function testArguments(dcp, arguments, success) {
|
||||
}
|
||||
|
||||
function listener(event, exec_state, event_data, data) {
|
||||
if (muteListener) return;
|
||||
try {
|
||||
if (event == Debug.DebugEvent.Break) {
|
||||
// Get the debug command processor.
|
||||
|
@ -37,7 +37,7 @@ var current_source = ''; // Current source being compiled.
|
||||
var source_count = 0; // Total number of scources compiled.
|
||||
var host_compilations = 0; // Number of scources compiled through the API.
|
||||
var eval_compilations = 0; // Number of scources compiled through eval.
|
||||
|
||||
var mute_listener = false;
|
||||
|
||||
function compileSource(source) {
|
||||
current_source = source;
|
||||
@ -45,8 +45,20 @@ function compileSource(source) {
|
||||
source_count++;
|
||||
}
|
||||
|
||||
function safeEval(code) {
|
||||
try {
|
||||
mute_listener = true;
|
||||
return eval('(' + code + ')');
|
||||
} catch (e) {
|
||||
assertEquals(void 0, e);
|
||||
return undefined;
|
||||
} finally {
|
||||
mute_listener = false;
|
||||
}
|
||||
}
|
||||
|
||||
function listener(event, exec_state, event_data, data) {
|
||||
if (mute_listener) return;
|
||||
try {
|
||||
if (event == Debug.DebugEvent.BeforeCompile ||
|
||||
event == Debug.DebugEvent.AfterCompile ||
|
||||
@ -81,7 +93,7 @@ function listener(event, exec_state, event_data, data) {
|
||||
}
|
||||
// Check that script context is included into the event message.
|
||||
var json = event_data.toJSONProtocol();
|
||||
var msg = eval('(' + json + ')');
|
||||
var msg = safeEval(json);
|
||||
assertTrue('context' in msg.body.script);
|
||||
|
||||
// Check that we pick script name from //# sourceURL, iff present
|
||||
|
@ -32,6 +32,7 @@ Debug = debug.Debug
|
||||
var evaluate_callback;
|
||||
|
||||
function listener(event, exec_state, event_data, data) {
|
||||
if (event !== Debug.DebugEvent.Break) return;
|
||||
try {
|
||||
var context = { what_is_capybara: "a fish" };
|
||||
var context2 = { what_is_capybara: "a fish", what_is_parrot: "a beard" };
|
||||
|
Loading…
Reference in New Issue
Block a user