Skip to content

Commit b1827e9

Browse files
alexkozyCommit Bot
authored andcommitted
Reland "[inspector] breakpoint after last break position should not jump to first line"
This is a reland of 61292f0 Original change's description: > [inspector] breakpoint after last break position should not jump to first line > > R=jgruber@chromium.org > > Bug: chromium:730177 > Change-Id: I0f3666a333604cb80bb51410c5edf2aceb0c6ef5 > Reviewed-on: https://chromium-review.googlesource.com/717717 > Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#48556} TBR=jgruber@chromium.org Bug: chromium:730177 Change-Id: I564cc5d7778f9d79780eae9dbe2d9aafaad4f466 Reviewed-on: https://chromium-review.googlesource.com/721468 Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Cr-Commit-Position: refs/heads/master@{#48615}
1 parent fb71512 commit b1827e9

4 files changed

Lines changed: 52 additions & 3 deletions

File tree

src/debug/debug.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,13 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
603603

604604
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
605605

606-
// Find the break point and change it.
607-
*source_position = FindBreakablePosition(debug_info, *source_position);
606+
// Find breakable position returns first breakable position after
607+
// *source_position, it can return 0 if no break location is found after
608+
// *source_position.
609+
int breakable_position = FindBreakablePosition(debug_info, *source_position);
610+
if (breakable_position < *source_position) return false;
611+
*source_position = breakable_position;
612+
608613
DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object);
609614
// At least one active break point now.
610615
DCHECK_LT(0, debug_info->GetBreakPointCount());

test/debugger/debug/regress/regress-crbug-517592.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
var source =
66
"var foo = function foo() {\n" +
7-
" return 1;\n" +
7+
" var a = 1;\n" +
88
"}\n" +
99
"//@ sourceURL=test";
1010

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Tests breakpoint at last line.
2+
{
3+
breakpointId : <breakpointId>
4+
locations : [
5+
[0] : {
6+
columnNumber : 12
7+
lineNumber : 3
8+
scriptId : <scriptId>
9+
}
10+
]
11+
}
12+
{
13+
breakpointId : <breakpointId>
14+
locations : [
15+
]
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2017 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
let {session, contextGroup, Protocol} = InspectorTest.start('Tests breakpoint at last line.');
6+
7+
let source = `
8+
let a = 1;
9+
//# sourceURL=foo.js
10+
let b = 2;
11+
`;
12+
13+
(async function test() {
14+
Protocol.Debugger.enable();
15+
Protocol.Runtime.evaluate({expression: source});
16+
let {result} = await Protocol.Debugger.setBreakpointByUrl({
17+
url: 'foo.js',
18+
lineNumber: 3,
19+
columnNumber: 12
20+
});
21+
InspectorTest.logMessage(result);
22+
({result} = await Protocol.Debugger.setBreakpointByUrl({
23+
url: 'foo.js',
24+
lineNumber: 4
25+
}));
26+
InspectorTest.logMessage(result);
27+
InspectorTest.completeTest();
28+
})();

0 commit comments

Comments
 (0)