MCPcopy Create free account
hub / github.com/Snapchat/Valdi / evaluateAtReturn

Function evaluateAtReturn

valdi/vscode_debugger/src/test/evaluate/evaluate.ts:461–484  ·  view source on GitHub ↗
(returnValue: string, expression = '$returnValue')

Source from the content-addressed store, hash-verified

459 const p = await r.launchAndLoad('blank');
460
461 const evaluateAtReturn = async (returnValue: string, expression = '$returnValue') => {
462 p.dap.evaluate({
463 expression: `(function () {
464 debugger;
465 return ${returnValue};
466 })();`,
467 });
468
469 const { threadId } = await p.dap.once('stopped');
470 await p.dap.next({ threadId: threadId! }); // step past debugger;
471 await p.dap.once('stopped');
472 await p.dap.next({ threadId: threadId! }); // step past return;
473 await p.dap.once('stopped');
474
475 const frameId = (
476 await p.dap.stackTrace({
477 threadId: threadId!,
478 })
479 ).stackFrames[0].id;
480
481 p.log(`return ${returnValue}:\n`);
482 await p.logger.evaluateAndLog(expression, { params: { frameId } });
483 await p.dap.continue({ threadId: threadId! });
484 };
485
486 await evaluateAtReturn('42');
487 await evaluateAtReturn('{ a: { b: true } }');

Callers 1

evaluate.tsFile · 0.85

Calls 7

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

Tested by

no test coverage detected