Files
node/test/parallel/test-debugger-probe-max-hit-text.js
Joyee Cheung 8c4ec8a674 debugger: add --max-hit option to probe mode
This option provides a new way of terminating the probing by
specifying a limit for the per-probe hit evaluation. When any
probe reaches the limit, the session removes the V8 breakpoints
and finishes with a `completed` terminal event rather than waiting
for the target to exit or timeout. This would be useful when we
provide a way to attach to and probe a running process in the future.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63704
Refs: https://github.com/nodejs/node/issues/63646
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-06-13 20:50:15 +00:00

31 lines
883 B
JavaScript

// This tests that --max-hit works with the text report.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const { spawnSyncAndAssert } = require('../common/child_process');
const { assertProbeText } = require('../common/debugger-probe');
const cwd = fixtures.path('debugger');
const probeUrl = fixtures.fileURL('debugger', 'probe-max-hit.js').href;
spawnSyncAndAssert(process.execPath, [
'inspect',
'--probe', 'probe-max-hit.js:5',
'--expr', 'index',
'--max-hit', '2',
'probe-max-hit.js',
], { cwd }, {
stdout(output) {
assertProbeText(output,
`Hit 1 at ${probeUrl}:5:3\n` +
' index = 0\n' +
`Hit 2 at ${probeUrl}:5:3\n` +
' index = 1\n' +
'Completed');
},
trim: true,
});