Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: src/debug.cc

Issue 264333007: Add OnCompileError handler and v8::CompileError debug event (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index dadaa915d48e0fb17467097156c89047e57edf98..ac4d1217792ced9e12746af1a8c90ecf412973fe 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -2685,6 +2685,67 @@ void Debugger::OnException(Handle<Object> exception,
}
+void Debugger::OnSyntaxError(Handle<Script> script) {
+ HandleScope scope(isolate_);
+ Debug* debug = isolate_->debug();
+
+ // No more to do if not debugging.
+ if (!IsDebuggerActive()) return;
+
+ // No compile events while compiling natives.
+ if (compiling_natives()) return;
+
+ // Store whether in debugger before entering debugger.
+ bool in_debugger = debug->InDebugger();
+
+ // Enter the debugger.
+ EnterDebugger debugger(isolate_);
+ if (debugger.FailedToEnter()) return;
+
+ // Save breakpoints or not, if SyntaxError ocured?
vsevik 2014/06/06 16:12:01 I don't think we should care about breakpoints in
+
+ // If debugging there might be script break points registered for this
+ // script. Make sure that these break points are set.
+
+ // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js).
+ Handle<String> update_script_break_points_string =
+ isolate_->factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
+ Handle<GlobalObject> debug_global(debug->debug_context()->global_object());
+ Handle<Object> update_script_break_points =
+ Object::GetProperty(
+ debug_global, update_script_break_points_string).ToHandleChecked();
+ if (!update_script_break_points->IsJSFunction()) {
+ return;
+ }
+ ASSERT(update_script_break_points->IsJSFunction());
+
+ // Wrap the script object in a proper JS object before passing it
+ // to JavaScript.
+ Handle<Object> wrapper = Script::GetWrapper(script);
+
+ // Call UpdateScriptBreakPoints expect no exceptions.
+ Handle<Object> argv[] = { wrapper };
+ if (Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points),
+ isolate_->js_builtins_object(),
+ ARRAY_SIZE(argv),
+ argv).is_null()) {
+ return;
+ }
+ // Bail out based on state or if there is no listener for this event
+ if (!Debugger::EventActive(v8::AfterCompile)) return;
+
+ // Create the compile state object.
+ Handle<Object> event_data;
+ // Bail out and don't call debugger if exception.
+ if (!MakeCompileEvent(script, false).ToHandle(&event_data)) return;
+
+ // Process debug event.
+ ProcessDebugEvent(v8::ScriptFailedToParse,
+ Handle<JSObject>::cast(event_data), true);
+}
+
+
void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
bool auto_continue) {
HandleScope scope(isolate_);

Powered by Google App Engine
This is Rietveld 408576698