debugger: disambiguate probe location binding

In probe mode, `--probe utils.js:10` can match multiple scripts
(e.g. `src/utils.js` and `lib/utils.js`) because the matcher uses
a path-separator-anchored URL suffix (similar to how e.g. gdb/lldb
behaves). Previously the report echoed only the user's request in
hit events, so a user seeing two hits at `utils.js:10` could not
tell which script each hit came from. In addition, previously
when the column was omitted we bound to 1 which was technically
different from how CDP binds omitted columns (to the first
executable column on the line).

This patch clarifies the semantics by tracking the scripts via
`Debugger.scriptParsed`, as recommended in the CDP docs, and
reports the actual execution location as `results[i].location`.
The same shape can be reused in the future for source maps or
additional events in attach mode.

This bumps the schema version because `target` is now
`{ suffix, line, column? }` instead of a positional array for
clarity. We picked `suffix` as the field name in case we
introduce other matching modes in the future. `column` is
omitted when the user did not supply one, and the actual
resolved column is reported in the hit event instead.

This patch also adds more tests for column-specific bindings,
multi-location resolution via require(cjs), and late script
binding via dynamic import(cjs) and require(esm).

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63286
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Joyee Cheung authored and Antoine du Hamel committed 2026-07-30 13:51:49 +02:00
1 parent eaebeb8b88
commit 2922290eae
31 files changed
+706 -207

No files matched your search

@@ -4,14 +4,16 @@
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const { spawnSyncAndExit } = require('../common/child_process');
const { probeScript } = require('../common/debugger-probe');
const cwd = fixtures.path('debugger');
spawnSyncAndExit(process.execPath, [
'inspect',
'--probe', `${probeScript}:12`,
probeScript,
], {
'--probe', 'probe.js:12',
'probe.js',
], { cwd }, {
signal: null,
status: 9,
stderr: /Each --probe must be followed immediately by --expr/,