Commit 0ac7970a authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] don't ignore uncaught exception if at least 1 frame isn't blackboxed

- and fixed test.

BUG=v8:5842, chromium:583193
R=yangguo@chromium.org,dgozman@chromium.org,alph@chromium.org

Review-Url: https://codereview.chromium.org/2651683005
Cr-Commit-Position: refs/heads/master@{#42714}
parent 7be3b4c9
......@@ -1737,6 +1737,38 @@ v8::Local<v8::Context> GetDebugEventContext(Isolate* isolate) {
}
} // anonymous namespace
bool Debug::IsExceptionBlackboxed(bool uncaught) {
JavaScriptFrameIterator it(isolate_);
if (it.done()) return false;
// Uncaught exception is blackboxed if all current frames are blackboxed,
// caught exception if top frame is blackboxed.
bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame());
if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed;
it.Advance();
while (!it.done()) {
if (!IsFrameBlackboxed(it.frame())) return false;
it.Advance();
}
return true;
}
bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) {
HandleScope scope(isolate_);
if (!frame->HasInlinedFrames()) {
return IsBlackboxed(frame->function()->shared());
}
List<SharedFunctionInfo*> raw_shareds;
frame->GetFunctions(&raw_shareds);
List<Handle<SharedFunctionInfo>> shareds;
for (int i = 0; i < raw_shareds.length(); ++i) {
shareds.Add(handle(raw_shareds[i]));
}
for (int i = 0; i < shareds.length(); ++i) {
if (!IsBlackboxed(shareds[i])) return false;
}
return true;
}
void Debug::OnException(Handle<Object> exception, Handle<Object> promise) {
// We cannot generate debug events when JS execution is disallowed.
// TODO(5530): Reenable debug events within DisallowJSScopes once relevant
......@@ -1769,8 +1801,8 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) {
{
JavaScriptFrameIterator it(isolate_);
// Check whether the top frame is blackboxed or the break location is muted.
if (!it.done() && (IsBlackboxed(it.frame()->function()->shared()) ||
IsMutedAtCurrentLocation(it.frame()))) {
if (!it.done() && (IsMutedAtCurrentLocation(it.frame()) ||
IsExceptionBlackboxed(uncaught))) {
return;
}
}
......
......@@ -495,6 +495,8 @@ class Debug {
}
bool IsBlackboxed(SharedFunctionInfo* shared);
bool IsExceptionBlackboxed(bool uncaught);
bool IsFrameBlackboxed(JavaScriptFrame* frame);
void OnException(Handle<Object> exception, Handle<Object> promise);
......
......@@ -3,7 +3,7 @@ Checks that breaks in framework code correctly processed.
Running test: testConsoleAssert
> all frames in framework:
> mixed, top frame in framework:
frameworkAssert (framework.js:9:10)
frameworkAssert (framework.js:10:10)
(anonymous) (user.js:0:0)
......@@ -14,14 +14,25 @@ Running test: testCaughtException
Running test: testUncaughtException
> all frames in framework:
> mixed, top frame in framework:
throwUncaughtError (framework.js:21:2)
(anonymous) (user.js:0:0)
Running test: testUncaughtExceptionWithInlinedFrame
> mixed top frame in framework:
throwUserException (user.js:66:2)
inlinedWrapper (framework.js:56:4)
throwInlinedUncaughtError (framework.js:59:2)
(anonymous) (framework.js:0:0)
Running test: testBreakpoint
> all frames in framework:
breakpoint (framework.js:24:2)
breakpoint (framework.js:25:2)
(anonymous) (framework.js:0:0)
> mixed, top frame in framework:
breakpoint (framework.js:24:2)
breakpoint (framework.js:25:2)
(anonymous) (user.js:0:0)
......@@ -32,7 +43,7 @@ Running test: testDebuggerStatement
Running test: testSyncDOMBreakpoint
> all frames in framework:
> mixed, top frame in framework:
syncDOMBreakpoint (framework.js:32:2)
syncDOMBreakpoint (framework.js:33:2)
(anonymous) (user.js:0:0)
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
print('Checks that breaks in framework code correctly processed.');
InspectorTest.addScript(
`
InspectorTest.addScript(`
function frameworkAssert() {
console.assert(false);
}
......@@ -51,8 +51,21 @@ function throwFromJSONParse() {
}
}
//# sourceURL=framework.js`,
7, 26);
function throwInlinedUncaughtError() {
function inlinedWrapper() {
throwUserException();
}
%OptimizeFunctionOnNextCall(inlinedWrapper);
inlinedWrapper();
}
//# sourceURL=framework.js`, 8, 26);
InspectorTest.addScript(`
function throwUserException() {
throw new Error();
}
//# sourceURL=user.js`, 64, 26)
InspectorTest.setupScriptMap();
Protocol.Debugger.onPaused(message => {
......@@ -98,17 +111,29 @@ InspectorTest.runTestSuite([
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwUncaughtError()//# sourceURL=framework.js'}))
{expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'}))
.then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true}))
.then(() => InspectorTest.log('> mixed, top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'throwUncaughtError()//# sourceURL=user.js'}))
{expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=user.js\', 0)'}))
.then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true}))
.then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'}))
.then(next);
},
function testUncaughtExceptionWithInlinedFrame(next) {
Protocol.Debugger.setPauseOnExceptions({state: 'all'})
.then(() => InspectorTest.log('> mixed top frame in framework:'))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'setTimeout(\'throwInlinedUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'}))
.then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true}))
.then(next);
},
function testBreakpoint(next) {
Protocol.Debugger.setBreakpointByUrl({lineNumber: 24, url: 'framework.js'})
Protocol.Debugger.setBreakpointByUrl({lineNumber: 25, url: 'framework.js'})
.then(() => InspectorTest.log('> all frames in framework:'))
.then(
() => Protocol.Runtime.evaluate(
......
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