Commit 6cd471fa authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] allow negative line and column in Location

As long as we have scripts with negative source offset (see inline event listeners) we should not crash a browser when get negative offset.

R=jgruber@chromium.org

Bug: chromium:750592
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ic3138e7c61ec0a5133c56de9970acdffa5536d8e
Reviewed-on: https://chromium-review.googlesource.com/611613Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47318}
parent a7c7e8f6
......@@ -9757,29 +9757,26 @@ debug::WasmDisassembly debug::WasmScript::DisassembleFunction(
}
debug::Location::Location(int line_number, int column_number)
: line_number_(line_number), column_number_(column_number) {
CHECK(line_number >= 0);
CHECK(column_number >= 0);
}
: line_number_(line_number),
column_number_(column_number),
is_empty_(false) {}
debug::Location::Location()
: line_number_(v8::Function::kLineOffsetNotFound),
column_number_(v8::Function::kLineOffsetNotFound) {}
column_number_(v8::Function::kLineOffsetNotFound),
is_empty_(true) {}
int debug::Location::GetLineNumber() const {
CHECK(line_number_ >= 0);
DCHECK(!IsEmpty());
return line_number_;
}
int debug::Location::GetColumnNumber() const {
CHECK(column_number_ >= 0);
DCHECK(!IsEmpty());
return column_number_;
}
bool debug::Location::IsEmpty() const {
return line_number_ == v8::Function::kLineOffsetNotFound &&
column_number_ == v8::Function::kLineOffsetNotFound;
}
bool debug::Location::IsEmpty() const { return is_empty_; }
void debug::GetLoadedScripts(v8::Isolate* v8_isolate,
PersistentValueVector<debug::Script>& scripts) {
......
......@@ -39,6 +39,7 @@ class V8_EXPORT_PRIVATE Location {
private:
int line_number_;
int column_number_;
bool is_empty_;
};
/**
......
Tests that we dont crash on pause at negative offset
(anonymous) (test.js:-3:-3)
// 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.
let {session, contextGroup, Protocol} =
InspectorTest.start('Tests that we dont crash on pause at negative offset');
(async function test() {
session.setupScriptMap();
await Protocol.Debugger.enable();
contextGroup.addScript(`debugger;//# sourceURL=test.js`, -3, -3);
let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
InspectorTest.completeTest();
})();
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