From 416e09f56d93dc478304436a682ef1940692f155 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 29 May 2026 17:05:18 +0200 Subject: [PATCH] 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 --- doc/api/debugger.md | 18 +++++- lib/internal/debugger/inspect.js | 19 +++--- lib/internal/debugger/inspect_helpers.js | 8 ++- lib/internal/debugger/inspect_probe.js | 42 +++++++++++++- test/common/debugger-probe.js | 11 ++++ test/fixtures/debugger/probe-max-hit.js | 7 +++ .../test-debugger-probe-max-hit-invalid.js | 40 +++++++++++++ .../test-debugger-probe-max-hit-miss.js | 36 ++++++++++++ .../test-debugger-probe-max-hit-partial.js | 58 +++++++++++++++++++ .../test-debugger-probe-max-hit-shared.js | 53 +++++++++++++++++ .../test-debugger-probe-max-hit-text.js | 30 ++++++++++ test/parallel/test-debugger-probe-max-hit.js | 51 ++++++++++++++++ 12 files changed, 358 insertions(+), 15 deletions(-) create mode 100644 test/fixtures/debugger/probe-max-hit.js create mode 100644 test/parallel/test-debugger-probe-max-hit-invalid.js create mode 100644 test/parallel/test-debugger-probe-max-hit-miss.js create mode 100644 test/parallel/test-debugger-probe-max-hit-partial.js create mode 100644 test/parallel/test-debugger-probe-max-hit-shared.js create mode 100644 test/parallel/test-debugger-probe-max-hit-text.js create mode 100644 test/parallel/test-debugger-probe-max-hit.js diff --git a/doc/api/debugger.md b/doc/api/debugger.md index 965c9a5d2a4117..56f36cb133aa08 100644 --- a/doc/api/debugger.md +++ b/doc/api/debugger.md @@ -237,6 +237,10 @@ added: - v26.1.0 - v24.16.0 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/63704 + description: Add per-probe `--max-hit ` option to limit evaluated hits and finish + with a `completed` terminal event as soon as any probe reaches its limit. - version: v26.3.0 pr-url: https://github.com/nodejs/node/pull/63437 description: Add `probe_failure` terminal `error` event for inspector-side mid-session @@ -265,8 +269,8 @@ printf-style debugging without having to modify the application code and clean up afterwards. It also supports structured JSON output for tool use. ```console -$ node inspect --probe :[:] --expr - [--probe :[:] --expr ...] +$ node inspect --probe :[:] --expr [--max-hit ] + [--probe :[:] --expr [--max-hit ] ...] [--json] [--preview] [--timeout=] [--port=] [--] [ ...]