[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: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47895}
This commit is contained in:
Alexey Kozyatinskiy 2017-09-01 10:27:11 -07:00 committed by Commit Bot
parent e98edd16fd
commit d63594b684
5 changed files with 63 additions and 22 deletions

View File

@ -457,6 +457,7 @@
{ "name": "functionName", "type": "string", "description": "Name of the JavaScript function called on this call frame." }, { "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": "functionLocation", "$ref": "Location", "optional": true, "experimental": true, "description": "Location in the source code." },
{ "name": "location", "$ref": "Location", "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": "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": "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." } { "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "description": "The value being returned, if the function is at return point." }

View File

@ -64,19 +64,13 @@ static const intptr_t kBreakpointHintMaxSearchOffset = 80 * 10;
namespace { namespace {
void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, void TranslateLocation(protocol::Debugger::Location* location,
WasmTranslation* wasmTranslation) { WasmTranslation* wasmTranslation) {
for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { String16 scriptId = location->getScriptId();
protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); int lineNumber = location->getLineNumber();
String16 scriptId = location->getScriptId(); int columnNumber = location->getColumnNumber(-1);
int lineNumber = location->getLineNumber(); if (wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
int columnNumber = location->getColumnNumber(-1); &scriptId, &lineNumber, &columnNumber)) {
if (!wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
&scriptId, &lineNumber, &columnNumber)) {
continue;
}
location->setScriptId(std::move(scriptId)); location->setScriptId(std::move(scriptId));
location->setLineNumber(lineNumber); location->setLineNumber(lineNumber);
location->setColumnNumber(columnNumber); location->setColumnNumber(columnNumber);
@ -1107,8 +1101,6 @@ Response V8DebuggerAgentImpl::currentCallFrames(
String16 callFrameId = String16 callFrameId =
RemoteCallFrameId::serialize(contextId, frameOrdinal); RemoteCallFrameId::serialize(contextId, frameOrdinal);
v8::Local<v8::debug::Script> script = iterator->GetScript();
DCHECK(!script.IsEmpty());
v8::debug::Location loc = iterator->GetSourceLocation(); v8::debug::Location loc = iterator->GetSourceLocation();
std::unique_ptr<Array<Scope>> scopes; std::unique_ptr<Array<Scope>> scopes;
@ -1128,15 +1120,29 @@ Response V8DebuggerAgentImpl::currentCallFrames(
.build(); .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 = auto frame =
CallFrame::create() CallFrame::create()
.setCallFrameId(callFrameId) .setCallFrameId(callFrameId)
.setFunctionName(toProtocolString(iterator->GetFunctionName())) .setFunctionName(toProtocolString(iterator->GetFunctionName()))
.setLocation(protocol::Debugger::Location::create() .setLocation(std::move(location))
.setScriptId(String16::fromInteger(script->Id())) .setUrl(url)
.setLineNumber(loc.GetLineNumber())
.setColumnNumber(loc.GetColumnNumber())
.build())
.setScopeChain(std::move(scopes)) .setScopeChain(std::move(scopes))
.setThis(std::move(receiver)) .setThis(std::move(receiver))
.build(); .build();
@ -1161,8 +1167,6 @@ Response V8DebuggerAgentImpl::currentCallFrames(
} }
(*result)->addItem(std::move(frame)); (*result)->addItem(std::move(frame));
} }
TranslateWasmStackTraceLocations(result->get(),
m_debugger->wasmTranslation());
return Response::OK(); return Response::OK();
} }

View File

@ -0,0 +1,15 @@
Tests url in Debugger.CallFrame.
[
[0] : {
url :
}
[1] : {
url : source-url.js
}
[2] : {
url : test.js
}
[3] : {
url : expr.js
}
]

View File

@ -0,0 +1,20 @@
// 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();
})();

View File

@ -117,6 +117,7 @@ console.log(239)
this : { this : {
type : undefined type : undefined
} }
url : module3
} }
] ]
hitBreakpoints : [ hitBreakpoints : [