Commit 9c40b865 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by V8 LUCI CQ

Fix monitor for arrow functions

Our current logic for the console API's monitor implementation relies on
JavaScript's arguments array. In arrow functions, this results in an
error, resulting missing print statements from monitor.

This CL at least re-enables the print statements, but does not print the
arguments in the case of arrow functions.

Change-Id: Ibf6c2a0fb5e0cc911c257520a59a875992fe3777
Bug: chromium:1206137
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2880216Reviewed-by: 's avatarPhilip Pfaffe <pfaffe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74437}
parent 3709ce4c
......@@ -557,8 +557,9 @@ void V8Console::monitorFunctionCallback(
else
builder.append(functionName);
builder.append(
" called\" + (arguments.length > 0 ? \" with arguments: \" + "
"Array.prototype.join.call(arguments, \", \") : \"\")) && false");
" called\" + (typeof arguments !== \"undefined\" && arguments.length > 0 "
"? \" with arguments: \" + Array.prototype.join.call(arguments, \", \") "
": \"\")) && false");
setFunctionBreakpoint(helper, sessionId, function,
V8DebuggerAgentImpl::MonitorCommandBreakpointSource,
toV8String(info.GetIsolate(), builder.toString()),
......
Check that debug and monitor methods from Command Line API works with bound function.
> debug foo and bar
> call foo and bar
paused in foo
paused in bar
> undebug foo and bar
> call foo and bar
> monitor foo and bar
> call foo and bar
function foo called
function bar called
> unmonitor foo and bar
> call foo and bar
> monitor and debug bar
> call bar
function bar called
paused in bar
> undebug bar
> call bar
function bar called
> debug and unmonitor bar
> call bar
paused in bar
// Copyright 2016 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(
'Check that debug and monitor methods from Command Line API works with bound function.');
contextGroup.addScript(`
function foo() {}
function boo() {}
var bar = () => boo();
function testFunction() {
console.log("> debug foo and bar");
debug(foo);
debug(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> undebug foo and bar");
undebug(foo);
undebug(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> monitor foo and bar");
monitor(foo);
monitor(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> unmonitor foo and bar");
unmonitor(foo);
unmonitor(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> monitor and debug bar");
monitor(bar);
debug(bar);
console.log("> call bar");
bar();
console.log("> undebug bar");
undebug(bar);
console.log("> call bar");
bar();
console.log("> debug and unmonitor bar");
debug(bar);
unmonitor(bar);
console.log("> call bar");
bar();
}`);
Protocol.Runtime.enable();
Protocol.Debugger.enable();
Protocol.Debugger.onPaused(message => {
var functionName = message.params.callFrames[0].functionName;
InspectorTest.log(`paused in ${functionName}`);
Protocol.Debugger.resume();
});
Protocol.Runtime.onConsoleAPICalled(
message => InspectorTest.log(message.params.args[0].value));
Protocol.Runtime
.evaluate({expression: 'testFunction()', includeCommandLineAPI: true})
.then(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