MCPcopy
hub / github.com/microsoft/vscode-js-debug / evaluateAtReturn

Function evaluateAtReturn

src/test/evaluate/evaluate.ts:503–526  ·  view source on GitHub ↗
(returnValue: string, expression = '$returnValue')

Source from the content-addressed store, hash-verified

501 const p = await r.launchAndLoad('blank');
502
503 const evaluateAtReturn = async (returnValue: string, expression = '$returnValue') => {
504 p.dap.evaluate({
505 expression: `(function () {
506 debugger;
507 return ${returnValue};
508 })();`,
509 });
510
511 const { threadId } = await p.dap.once('stopped');
512 await p.dap.next({ threadId: threadId! }); // step past debugger;
513 await p.dap.once('stopped');
514 await p.dap.next({ threadId: threadId! }); // step past return;
515 await p.dap.once('stopped');
516
517 const frameId = (
518 await p.dap.stackTrace({
519 threadId: threadId!,
520 })
521 ).stackFrames[0].id;
522
523 p.log(`return ${returnValue}:\n`);
524 await p.logger.evaluateAndLog(expression, { params: { frameId } });
525 await p.dap.continue({ threadId: threadId! });
526 };
527
528 await evaluateAtReturn('42');
529 await evaluateAtReturn('{ a: { b: true } }');

Callers 1

evaluate.tsFile · 0.85

Calls 7

evaluateAndLogMethod · 0.80
continueMethod · 0.80
evaluateMethod · 0.65
onceMethod · 0.65
nextMethod · 0.65
stackTraceMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected