Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,17 @@
Checks that requesting to restart a non-existant frame fails cleanly
Paused at (after evaluation):
(function foo() { #debugger; })();
Pause stack:
foo:1 (canBeRestarted = true)
Attempting to restart frame with non-existent index 2
{
error : {
code : -32000
message : Restarting frame failed
}
id : <messageId>
}

View File

@ -0,0 +1,21 @@
// Copyright 2022 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.
const {session, Protocol} =
InspectorTest.start('Checks that requesting to restart a non-existant frame fails cleanly');
session.setupScriptMap();
(async () => {
await Protocol.Debugger.enable();
await InspectorTest.evaluateAndWaitForPause(`
(function foo() { debugger; })();
`);
InspectorTest.log('Attempting to restart frame with non-existent index 2');
InspectorTest.logMessage(
await Protocol.Debugger.restartFrame({ callFrameId: '1.1.2', mode: 'StepInto' }));
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,51 @@
Checks that restart frame fails for generator or async functions.
Check that an async function cannot be restarted.
Paused at (after evaluation):
(async function asyncFn() {
#debugger;
})();
Pause stack:
asyncFn:2 (canBeRestarted = false)
Restarting function "asyncFn" ...
Failed to restart function "asyncFn":
{
code : -32000
message : Restarting frame failed
}
Check that a generator function cannot be restarted.
Paused at (after evaluation):
yield 10;
#debugger;
yield 20;
Pause stack:
generatorFn:3 (canBeRestarted = false)
Restarting function "generatorFn" ...
Failed to restart function "generatorFn":
{
code : -32000
message : Restarting frame failed
}
Check that a function cannot be restarted when a generator function is on the stack above
Paused at (after evaluation):
function breaker() { #debugger; }
function* genFn() {
Pause stack:
breaker:1 (canBeRestarted = true)
genFn:4 (canBeRestarted = false)
bar:10 (canBeRestarted = false)
Restarting function "bar" ...
Failed to restart function "bar":
{
code : -32000
message : Restarting frame failed
}

View File

@ -0,0 +1,59 @@
// Copyright 2022 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Checks that restart frame fails for generator or async functions.');
session.setupScriptMap();
async function testCase(description, snippet, restartFrameIndex) {
InspectorTest.log('');
InspectorTest.log(description);
const { callFrames, evaluatePromise } = await InspectorTest.evaluateAndWaitForPause(snippet);
// These are negative tests where the following call is expected to fail.
await InspectorTest.restartFrameAndWaitForPause(callFrames, restartFrameIndex, /*quitOnFailure*/ false);
// All snippets are written so a single resume is enough.
Protocol.Debugger.resume();
await evaluatePromise;
}
(async () => {
await Protocol.Debugger.enable();
await testCase('Check that an async function cannot be restarted.', `
(async function asyncFn() {
debugger;
})();
`, 0);
await testCase('Check that a generator function cannot be restarted.', `
function* generatorFn() {
yield 10;
debugger;
yield 20;
}
const gen1 = generatorFn();
gen1.next();
gen1.next();
`, 0);
await testCase('Check that a function cannot be restarted when a generator function is on the stack above', `
function breaker() { debugger; }
function* genFn() {
yield 10;
breaker();
yield 20;
}
const gen2 = genFn();
function bar() { // We want to restart bar.
gen2.next();
gen2.next();
}
bar();
`, 2);
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,16 @@
Checks that restart frame fails when embedder frames would be unwound
Paused at (after evaluation):
function breaker() {
#debugger;
}
Pause stack:
breaker:2 (canBeRestarted = true)
entrypoint:5 (canBeRestarted = false)
Restarting function "entrypoint" ...
Failed to restart function "entrypoint":
{
code : -32000
message : Restarting frame failed
}

View File

@ -0,0 +1,29 @@
// Copyright 2022 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Checks that restart frame fails when embedder frames would be unwound');
session.setupScriptMap();
contextGroup.addScript(`
function breaker() {
debugger;
}
function entrypoint() {
inspector.callbackForTests(breaker);
}
`, 0, 0, 'test.js');
(async () => {
await Protocol.Debugger.enable();
const { callFrames } = await InspectorTest.evaluateAndWaitForPause('entrypoint()');
// Restart the `entrypoint` frame. Inbetween is the C++ API method `callbackForTests`.
const restartFrameIndex = 1; // 0 is `breaker`, 1 is `entrypoint`.
await InspectorTest.restartFrameAndWaitForPause(callFrames, restartFrameIndex);
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,12 @@
Checks that Debugger.restartFrame returns an error
Paused at debugger:
function foo() { #debugger; }; foo();
restartFrame result:
{
error : {
code : -32000
message : Restarting frame without 'mode' not supported
}
id : <messageId>
}

View File

@ -0,0 +1,24 @@
// Copyright 2019 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.
const {session, Protocol} =
InspectorTest.start('Checks that Debugger.restartFrame returns an error');
session.setupScriptMap();
(async function test() {
Protocol.Debugger.enable();
const evalPromise = Protocol.Runtime.evaluate({
expression: 'function foo() { debugger; }; foo();'
});
InspectorTest.log('Paused at debugger:');
const { params: { callFrames: before } } =
await Protocol.Debugger.oncePaused();
await session.logSourceLocation(before[0].location);
const result = await Protocol.Debugger.restartFrame({ callFrameId: before[0].callFrameId });
InspectorTest.log('restartFrame result:');
InspectorTest.logMessage(result);
await Promise.all([Protocol.Debugger.resume(), evalPromise]);
InspectorTest.completeTest();
})()

View File

@ -0,0 +1,20 @@
Checks that restarting an inlined frame works.
Optimization status for function "h"? optimized
Paused at (after evaluation):
console.log('f');
return a + b;# // Breakpoint is set here.
}
Pause stack:
f:3 (canBeRestarted = true)
g:8 (canBeRestarted = true)
h:13 (canBeRestarted = true)
Optimization status for function "h" after we paused? optimized
Restarting function "g" ...
Paused at (after restart):
function g(a, b) { // We want to restart 'g'.
#console.log('g');
return 2 + f(a, b);
Called functions: h,g,f,g,f

View File

@ -0,0 +1,71 @@
// Copyright 2022 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.
// Flags: --allow-natives-syntax
const {session, contextGroup, Protocol} =
InspectorTest.start('Checks that restarting an inlined frame works.');
session.setupScriptMap();
contextGroup.addScript(`
function f(a, b) {
console.log('f');
return a + b; // Breakpoint is set here.
}
function g(a, b) { // We want to restart 'g'.
console.log('g');
return 2 + f(a, b);
}
function h() {
console.log('h');
return 1 + g(3, 2);
}
function isOptimized(f) {
return (%GetOptimizationStatus(f) & 16) ? "optimized" : "unoptimized";
}
%NeverOptimizeFunction(f); // Inline 'g' into 'h', but never 'f'.
%PrepareFunctionForOptimization(h);
for (let i = 0; i < 10; ++i) h();
%OptimizeFunctionOnNextCall(h);
h();
`, 0, 0, 'test.js');
(async () => {
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
const consoleMessages = [];
Protocol.Runtime.onConsoleAPICalled(({ params }) => {
consoleMessages.push(params.args[0].value);
});
let { result: { result: { value } } } = await Protocol.Runtime.evaluate({ expression: 'isOptimized(h)' });
InspectorTest.log(`Optimization status for function "h"? ${value}`);
await Protocol.Debugger.setBreakpointByUrl({ url: 'test.js', lineNumber: 4 });
const { callFrames, evaluatePromise } = await InspectorTest.evaluateAndWaitForPause('h()');
({ result: { result: { value } } } = await Protocol.Runtime.evaluate({ expression: 'isOptimized(h)' }));
InspectorTest.log(`Optimization status for function "h" after we paused? ${value}`);
await InspectorTest.restartFrameAndWaitForPause(callFrames, 1);
// Restarting the frame means we hit the breakpoint a second time.
Protocol.Debugger.resume();
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
await evaluatePromise;
InspectorTest.log(`Called functions: ${consoleMessages.join()}`);
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,15 @@
Checks that restarting the top frame hits a debugger statement twice
Paused at (after evaluation):
const x = 1;
#debugger;
const y = 2;
Pause stack:
foo:3 (canBeRestarted = true)
Restarting function "foo" ...
Paused at (after restart):
function foo() {
const x = #1;
debugger;

View File

@ -0,0 +1,31 @@
// Copyright 2022 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.
const {session, Protocol} =
InspectorTest.start('Checks that restarting the top frame hits a debugger statement twice');
session.setupScriptMap();
const source = `
function foo() {
const x = 1;
debugger;
const y = 2;
}
foo();
`;
(async () => {
await Protocol.Debugger.enable();
const { callFrames } = await InspectorTest.evaluateAndWaitForPause(source);
await InspectorTest.restartFrameAndWaitForPause(callFrames, 0);
Protocol.Debugger.resume(); // Resuming hits the 'debugger' stmt again.
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,108 @@
Checks that after restarting the top frame, local variables are reset
Paused at (after evaluation):
let z = 'some let';
#debugger;
}
Pause stack:
foo:5 (canBeRestarted = true)
Evaluating x:
{
id : <messageId>
result : {
result : {
type : string
value : some var
}
}
}
Evaluating y:
{
id : <messageId>
result : {
result : {
type : string
value : some const
}
}
}
Evaluating z:
{
id : <messageId>
result : {
result : {
type : string
value : some let
}
}
}
Restarting function "foo" ...
Paused at (after restart):
function foo() {
var x = #'some var';
const y = 'some const';
Evaluating x:
{
id : <messageId>
result : {
result : {
type : undefined
}
}
}
Evaluating y:
{
id : <messageId>
result : {
exceptionDetails : {
columnNumber : 0
exception : {
className : ReferenceError
description : ReferenceError: Cannot access 'y' from debugger at eval (eval at foo (:1:1), <anonymous>:1:1) at foo (testRestartFrame.js:3:11) at testRestartFrame.js:8:1
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
scriptId : <scriptId>
text : Uncaught
}
result : {
className : ReferenceError
description : ReferenceError: Cannot access 'y' from debugger at eval (eval at foo (:1:1), <anonymous>:1:1) at foo (testRestartFrame.js:3:11) at testRestartFrame.js:8:1
objectId : <objectId>
subtype : error
type : object
}
}
}
Evaluating z:
{
id : <messageId>
result : {
exceptionDetails : {
columnNumber : 0
exception : {
className : ReferenceError
description : ReferenceError: Cannot access 'z' from debugger at eval (eval at foo (:1:1), <anonymous>:1:1) at foo (testRestartFrame.js:3:11) at testRestartFrame.js:8:1
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
scriptId : <scriptId>
text : Uncaught
}
result : {
className : ReferenceError
description : ReferenceError: Cannot access 'z' from debugger at eval (eval at foo (:1:1), <anonymous>:1:1) at foo (testRestartFrame.js:3:11) at testRestartFrame.js:8:1
objectId : <objectId>
subtype : error
type : object
}
}
}

View File

@ -0,0 +1,52 @@
// Copyright 2022 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.
const {session, Protocol} =
InspectorTest.start('Checks that after restarting the top frame, local variables are reset');
session.setupScriptMap();
const source = `
function foo() {
var x = 'some var';
const y = 'some const';
let z = 'some let';
debugger;
}
foo();
//# sourceURL=testRestartFrame.js`;
(async () => {
await Protocol.Debugger.enable();
const { callFrames } = await InspectorTest.evaluateAndWaitForPause(source);
let { callFrameId } = callFrames[0];
InspectorTest.log('Evaluating x:');
InspectorTest.logMessage(await Protocol.Debugger.evaluateOnCallFrame({ callFrameId, expression: 'x' }));
InspectorTest.log('Evaluating y:');
InspectorTest.logMessage(await Protocol.Debugger.evaluateOnCallFrame({ callFrameId, expression: 'y' }));
InspectorTest.log('Evaluating z:');
InspectorTest.logMessage(await Protocol.Debugger.evaluateOnCallFrame({ callFrameId, expression: 'z' }));
const callFramesAfter = await InspectorTest.restartFrameAndWaitForPause(callFrames, 0);
({ callFrameId } = callFramesAfter[0]);
InspectorTest.log('Evaluating x:');
InspectorTest.logMessage(await Protocol.Debugger.evaluateOnCallFrame({ callFrameId, expression: 'x' }));
InspectorTest.log('Evaluating y:');
InspectorTest.logMessage(await Protocol.Debugger.evaluateOnCallFrame({ callFrameId, expression: 'y' }));
InspectorTest.log('Evaluating z:');
InspectorTest.logMessage(await Protocol.Debugger.evaluateOnCallFrame({ callFrameId, expression: 'z' }));
Protocol.Debugger.resume(); // Resuming hits the 'debugger' stmt again.
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,15 @@
Checks that restarting the top frame works with breakpoints
Paused at (after evaluation):
const x = 1;
const y = #2;
}
Pause stack:
foo:3 (canBeRestarted = true)
Restarting function "foo" ...
Paused at (after restart):
function foo() {
const x = #1;
const y = 2;

View File

@ -0,0 +1,35 @@
// Copyright 2022 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.
const {session, Protocol} =
InspectorTest.start('Checks that restarting the top frame works with breakpoints');
session.setupScriptMap();
const source = `
function foo() {
const x = 1;
const y = 2;
}
//# sourceURL=testRestartFrame.js`;
(async () => {
await Protocol.Debugger.enable();
await Protocol.Runtime.evaluate({ expression: source });
await Protocol.Debugger.setBreakpointByUrl({
lineNumber: 3,
url: 'testRestartFrame.js',
});
const { callFrames } = await InspectorTest.evaluateAndWaitForPause('foo()');
await InspectorTest.restartFrameAndWaitForPause(callFrames, 0);
Protocol.Debugger.resume(); // Resuming hits the breakpoint again.
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,139 @@
Checks that restarting every frame on the stack works.
---- Restarting at frame index 0 ----
Paused at (after evaluation):
console.log('A');
#debugger;
return 'Magic value';
Pause stack:
A:3 (canBeRestarted = true)
B:8 (canBeRestarted = true)
C:13 (canBeRestarted = true)
D:18 (canBeRestarted = true)
E:22 (canBeRestarted = true)
F:26 (canBeRestarted = true)
Restarting function "A" ...
Paused at (after restart):
function A() {
#console.log('A');
debugger;
Evaluating to: Magic value
Called functions: F,E,D,C,B,A,A
---- Restarting at frame index 1 ----
Paused at (after evaluation):
console.log('A');
#debugger;
return 'Magic value';
Pause stack:
A:3 (canBeRestarted = true)
B:8 (canBeRestarted = true)
C:13 (canBeRestarted = true)
D:18 (canBeRestarted = true)
E:22 (canBeRestarted = true)
F:26 (canBeRestarted = true)
Restarting function "B" ...
Paused at (after restart):
function B(param1, param2) {
#console.log('B');
return A();
Evaluating to: Magic value
Called functions: F,E,D,C,B,A,B,A
---- Restarting at frame index 2 ----
Paused at (after evaluation):
console.log('A');
#debugger;
return 'Magic value';
Pause stack:
A:3 (canBeRestarted = true)
B:8 (canBeRestarted = true)
C:13 (canBeRestarted = true)
D:18 (canBeRestarted = true)
E:22 (canBeRestarted = true)
F:26 (canBeRestarted = true)
Restarting function "C" ...
Paused at (after restart):
function C() {
#console.log('C');
// Function call with argument adapter is intentional.
Evaluating to: Magic value
Called functions: F,E,D,C,B,A,C,B,A
---- Restarting at frame index 3 ----
Paused at (after evaluation):
console.log('A');
#debugger;
return 'Magic value';
Pause stack:
A:3 (canBeRestarted = true)
B:8 (canBeRestarted = true)
C:13 (canBeRestarted = true)
D:18 (canBeRestarted = true)
E:22 (canBeRestarted = true)
F:26 (canBeRestarted = true)
Restarting function "D" ...
Paused at (after restart):
function D() {
#console.log('D');
// Function call with argument adapter is intentional.
Evaluating to: Magic value
Called functions: F,E,D,C,B,A,D,C,B,A
---- Restarting at frame index 4 ----
Paused at (after evaluation):
console.log('A');
#debugger;
return 'Magic value';
Pause stack:
A:3 (canBeRestarted = true)
B:8 (canBeRestarted = true)
C:13 (canBeRestarted = true)
D:18 (canBeRestarted = true)
E:22 (canBeRestarted = true)
F:26 (canBeRestarted = true)
Restarting function "E" ...
Paused at (after restart):
function E() {
#console.log('E');
return D();
Evaluating to: Magic value
Called functions: F,E,D,C,B,A,E,D,C,B,A
---- Restarting at frame index 5 ----
Paused at (after evaluation):
console.log('A');
#debugger;
return 'Magic value';
Pause stack:
A:3 (canBeRestarted = true)
B:8 (canBeRestarted = true)
C:13 (canBeRestarted = true)
D:18 (canBeRestarted = true)
E:22 (canBeRestarted = true)
F:26 (canBeRestarted = true)
Restarting function "F" ...
Paused at (after restart):
function F() {
#console.log('F');
return E();
Evaluating to: Magic value
Called functions: F,E,D,C,B,A,F,E,D,C,B,A

View File

@ -0,0 +1,69 @@
// Copyright 2022 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Checks that restarting every frame on the stack works.');
session.setupScriptMap();
contextGroup.addScript(`
function A() {
console.log('A');
debugger;
return 'Magic value';
}
function B(param1, param2) {
console.log('B');
return A();
}
function C() {
console.log('C');
// Function call with argument adapter is intentional.
return B();
}
function D() {
console.log('D');
// Function call with argument adapter is intentional.
return C(42, 'foo');
}
function E() {
console.log('E');
return D();
}
function F() {
console.log('F');
return E();
}
`, 0, 0, 'test.js');
async function testCase(frameIndex) {
const { callFrames, evaluatePromise } = await InspectorTest.evaluateAndWaitForPause('F()');
await InspectorTest.restartFrameAndWaitForPause(callFrames, frameIndex);
Protocol.Debugger.resume(); // Resuming hits the 'debugger' stmt again.
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
const { result: { result: { value } } } = await evaluatePromise;
InspectorTest.log(`Evaluating to: ${value}`);
}
(async () => {
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
const consoleMessages = [];
Protocol.Runtime.onConsoleAPICalled(({ params }) => {
consoleMessages.push(params.args[0].value);
});
for (let index = 0; index < 6; ++index) {
InspectorTest.log(`\n---- Restarting at frame index ${index} ----`);
await testCase(index);
InspectorTest.log(`Called functions: ${consoleMessages.join()}`);
consoleMessages.splice(0);
}
InspectorTest.completeTest();
})();