mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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>
41 lines
980 B
JavaScript
41 lines
980 B
JavaScript
// This tests probe session timeout behavior and teardown.
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const { spawnSyncAndExit } = require('../common/child_process');
|
|
const { assertProbeJson } = require('../common/debugger-probe');
|
|
const cwd = fixtures.path('debugger');
|
|
|
|
spawnSyncAndExit(process.execPath, [
|
|
'inspect',
|
|
'--json',
|
|
'--timeout=200',
|
|
'--probe', 'probe-timeout.js:99',
|
|
'--expr', '1',
|
|
'probe-timeout.js',
|
|
], { cwd }, {
|
|
signal: null,
|
|
status: 1,
|
|
stdout(output) {
|
|
assertProbeJson(output, {
|
|
v: 2,
|
|
probes: [{
|
|
expr: '1',
|
|
target: { suffix: 'probe-timeout.js', line: 99 },
|
|
}],
|
|
results: [{
|
|
event: 'timeout',
|
|
pending: [0],
|
|
error: {
|
|
code: 'probe_timeout',
|
|
message: 'Timed out after 200ms waiting for probes: probe-timeout.js:99',
|
|
},
|
|
}],
|
|
});
|
|
},
|
|
trim: true,
|
|
});
|