Commit d63594b6 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] added url to Debugger.CallFrame

Runtime.CallFrame has url already. It allows to show stack traces on pause
without tacking all parsed scripts.

R=alph@chromium.org,pfeldman@chromium.org

Bug: chromium:762982
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ic4f096ade1cb6c9de42fec77280dcc3007c6a5cf
Reviewed-on: https://chromium-review.googlesource.com/648068
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarPavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47895}
parent e98edd16
......@@ -457,6 +457,7 @@
{ "name": "functionName", "type": "string", "description": "Name of the JavaScript function called on this call frame." },
{ "name": "functionLocation", "$ref": "Location", "optional": true, "experimental": true, "description": "Location in the source code." },
{ "name": "location", "$ref": "Location", "description": "Location in the source code." },
{ "name": "url", "type": "string", "description": "JavaScript script name or url." },
{ "name": "scopeChain", "type": "array", "items": { "$ref": "Scope" }, "description": "Scope chain for this call frame." },
{ "name": "this", "$ref": "Runtime.RemoteObject", "description": "<code>this</code> object for this call frame." },
{ "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "description": "The value being returned, if the function is at return point." }
......
......@@ -64,19 +64,13 @@ static const intptr_t kBreakpointHintMaxSearchOffset = 80 * 10;
namespace {
void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace,
WasmTranslation* wasmTranslation) {
for (size_t i = 0, e = stackTrace->length(); i != e; ++i) {
protocol::Debugger::Location* location = stackTrace->get(i)->getLocation();
String16 scriptId = location->getScriptId();
int lineNumber = location->getLineNumber();
int columnNumber = location->getColumnNumber(-1);
if (!wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
&scriptId, &lineNumber, &columnNumber)) {
continue;
}
void TranslateLocation(protocol::Debugger::Location* location,
WasmTranslation* wasmTranslation) {
String16 scriptId = location->getScriptId();
int lineNumber = location->getLineNumber();
int columnNumber = location->getColumnNumber(-1);
if (wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
&scriptId, &lineNumber, &columnNumber)) {
location->setScriptId(std::move(scriptId));
location->setLineNumber(lineNumber);
location->setColumnNumber(columnNumber);
......@@ -1107,8 +1101,6 @@ Response V8DebuggerAgentImpl::currentCallFrames(
String16 callFrameId =
RemoteCallFrameId::serialize(contextId, frameOrdinal);
v8::Local<v8::debug::Script> script = iterator->GetScript();
DCHECK(!script.IsEmpty());
v8::debug::Location loc = iterator->GetSourceLocation();
std::unique_ptr<Array<Scope>> scopes;
......@@ -1128,15 +1120,29 @@ Response V8DebuggerAgentImpl::currentCallFrames(
.build();
}
v8::Local<v8::debug::Script> script = iterator->GetScript();
DCHECK(!script.IsEmpty());
std::unique_ptr<protocol::Debugger::Location> location =
protocol::Debugger::Location::create()
.setScriptId(String16::fromInteger(script->Id()))
.setLineNumber(loc.GetLineNumber())
.setColumnNumber(loc.GetColumnNumber())
.build();
TranslateLocation(location.get(), m_debugger->wasmTranslation());
String16 scriptId = String16::fromInteger(script->Id());
ScriptsMap::iterator scriptIterator =
m_scripts.find(location->getScriptId());
String16 url;
if (scriptIterator != m_scripts.end()) {
url = scriptIterator->second->sourceURL();
}
auto frame =
CallFrame::create()
.setCallFrameId(callFrameId)
.setFunctionName(toProtocolString(iterator->GetFunctionName()))
.setLocation(protocol::Debugger::Location::create()
.setScriptId(String16::fromInteger(script->Id()))
.setLineNumber(loc.GetLineNumber())
.setColumnNumber(loc.GetColumnNumber())
.build())
.setLocation(std::move(location))
.setUrl(url)
.setScopeChain(std::move(scopes))
.setThis(std::move(receiver))
.build();
......@@ -1161,8 +1167,6 @@ Response V8DebuggerAgentImpl::currentCallFrames(
}
(*result)->addItem(std::move(frame));
}
TranslateWasmStackTraceLocations(result->get(),
m_debugger->wasmTranslation());
return Response::OK();
}
......
Tests url in Debugger.CallFrame.
[
[0] : {
url :
}
[1] : {
url : source-url.js
}
[2] : {
url : test.js
}
[3] : {
url : expr.js
}
]
// 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 url in Debugger.CallFrame.');
contextGroup.addScript(`
eval('function foo1() { debugger; }');
eval('function foo2() { foo1() } //# sourceURL=source-url.js');
function foo3() { foo2(); }
`, 0, 0, 'test.js');
(async function test() {
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: 'foo3()//# sourceURL=expr.js'});
let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
InspectorTest.logMessage(callFrames.map(frame => ({url: frame.url})));
InspectorTest.completeTest();
})();
......@@ -117,6 +117,7 @@ console.log(239)
this : {
type : undefined
}
url : module3
}
]
hitBreakpoints : [
......
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