From: yangguo@chromium.org Date: Fri, 25 Apr 2014 07:03:05 +0000 (+0000) Subject: Trigger debug event on not yet caught exception in promises. X-Git-Tag: upstream/4.7.83~9439 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28f5cf398ed8752d22f28e279f04910aadd5c677;p=platform%2Fupstream%2Fv8.git Trigger debug event on not yet caught exception in promises. R=aandrey@chromium.org, rossberg@chromium.org, yurys@chromium.org BUG=v8:3093 LOG=Y Review URL: https://codereview.chromium.org/249503002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20956 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/include/v8-debug.h b/include/v8-debug.h index 49916fe..6b2c278 100644 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -43,7 +43,8 @@ enum DebugEvent { BeforeCompile = 4, AfterCompile = 5, ScriptCollected = 6, - BreakForCommand = 7 + UncaughtExceptionInPromise = 7, + BreakForCommand = 8 }; diff --git a/src/debug-debugger.js b/src/debug-debugger.js index d759fe5..aebef47 100644 --- a/src/debug-debugger.js +++ b/src/debug-debugger.js @@ -42,7 +42,8 @@ Debug.DebugEvent = { Break: 1, NewFunction: 3, BeforeCompile: 4, AfterCompile: 5, - ScriptCollected: 6 }; + ScriptCollected: 6, + PendingExceptionInPromise: 7 }; // Types of exceptions that can be broken upon. Debug.ExceptionBreak = { Caught : 0, @@ -1093,15 +1094,16 @@ BreakEvent.prototype.toJSONProtocol = function() { }; -function MakeExceptionEvent(exec_state, exception, uncaught) { - return new ExceptionEvent(exec_state, exception, uncaught); +function MakeExceptionEvent(exec_state, exception, uncaught, promise) { + return new ExceptionEvent(exec_state, exception, uncaught, promise); } -function ExceptionEvent(exec_state, exception, uncaught) { +function ExceptionEvent(exec_state, exception, uncaught, promise) { this.exec_state_ = exec_state; this.exception_ = exception; this.uncaught_ = uncaught; + this.promise_ = promise; } @@ -1125,6 +1127,11 @@ ExceptionEvent.prototype.uncaught = function() { }; +ExceptionEvent.prototype.promise = function() { + return this.promise_; +}; + + ExceptionEvent.prototype.func = function() { return this.exec_state_.frame(0).func(); }; diff --git a/src/debug.cc b/src/debug.cc index b41375b..c6a224e 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -2628,13 +2628,15 @@ MaybeHandle Debugger::MakeBreakEvent(Handle break_points_hit) { MaybeHandle Debugger::MakeExceptionEvent(Handle exception, - bool uncaught) { + bool uncaught, + Handle promise) { Handle exec_state; if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle(); // Create the new exception event object. Handle argv[] = { exec_state, exception, - isolate_->factory()->ToBoolean(uncaught) }; + isolate_->factory()->ToBoolean(uncaught), + promise }; return MakeJSObject(CStrVector("MakeExceptionEvent"), ARRAY_SIZE(argv), argv); } @@ -2664,7 +2666,9 @@ MaybeHandle Debugger::MakeScriptCollectedEvent(int id) { } -void Debugger::OnException(Handle exception, bool uncaught) { +void Debugger::OnException(Handle exception, + bool uncaught, + Handle promise) { HandleScope scope(isolate_); Debug* debug = isolate_->debug(); @@ -2688,13 +2692,21 @@ void Debugger::OnException(Handle exception, bool uncaught) { // Clear all current stepping setup. debug->ClearStepping(); + + // Determine event; + DebugEvent event = promise->IsUndefined() + ? v8::Exception : v8::UncaughtExceptionInPromise; + // Create the event data object. Handle event_data; // Bail out and don't call debugger if exception. - if (!MakeExceptionEvent(exception, uncaught).ToHandle(&event_data)) return; + if (!MakeExceptionEvent( + exception, uncaught, promise).ToHandle(&event_data)) { + return; + } // Process debug event. - ProcessDebugEvent(v8::Exception, Handle::cast(event_data), false); + ProcessDebugEvent(event, Handle::cast(event_data), false); // Return to continue execution from where the exception was thrown. } diff --git a/src/debug.h b/src/debug.h index b0a6892..b132243 100644 --- a/src/debug.h +++ b/src/debug.h @@ -793,13 +793,17 @@ class Debugger { MUST_USE_RESULT MaybeHandle MakeBreakEvent( Handle break_points_hit); MUST_USE_RESULT MaybeHandle MakeExceptionEvent( - Handle exception, bool uncaught); + Handle exception, + bool uncaught, + Handle promise); MUST_USE_RESULT MaybeHandle MakeCompileEvent( Handle