| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eaebeb8 commit 2922290
31 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,6 +235,13 @@ debug> | |||
| 235 | 235 | <!-- YAML | |
| 236 | 236 | added: | |
| 237 | 237 | - v24.16.0 | |
| 238 | + changes: | ||
| 239 | + - version: REPLACEME | ||
| 240 | + pr-url: https://github.com/nodejs/node/pull/63286 | ||
| 241 | + description: JSON report schema bumped to v2. Probe `target` is now | ||
| 242 | + `{ suffix, line, column? }` instead of an array. Each "hit" event carries a | ||
| 243 | + `location` field reporting the actual evaluation location. When the probe does not | ||
| 244 | + specify a column, it binds to the first executable column instead of defaulting to 1. | ||
| 238 | 245 | --> | |
| 239 | 246 | ||
| 240 | 247 | > Stability: 1 - Experimental | |
@@ -261,7 +268,9 @@ $ node inspect --probe <file>:<line>[:<col>] --expr <expr> | |||
| 261 | 268 | ||
| 262 | 269 | * `--probe <file>:<line>[:<col>]`: Source location of the probe. When execution | |
| 263 | 270 | reaches the location, the provided expressions are evaluated and printed in | |
| 264 | - the output. Line and column numbers are 1-based. When omitted, column defaults to 1. | ||
| 271 | + the output. `<file>` matches the URL suffix of the script to probe. | ||
| 272 | + `<line>` and `<col>` numbers are 1-based. When `<col>` is omitted, the probe | ||
| 273 | + binds to the first executable column on the line. | ||
| 265 | 274 | * `--expr <expr>`: JavaScript expression to evaluate whenever execution reaches | |
| 266 | 275 | the location specified by the preceding `--probe`. | |
| 267 | 276 | Must immediately follow the `--probe` it belongs to. | |
@@ -313,13 +322,17 @@ Without `--json`, by default the output is printed in a human-readable text form | |||
| 313 | 322 | ||
| 314 | 323 | ```console | |
| 315 | 324 | $ node inspect --probe cli.js:5 --expr 'rss' cli.js | |
| 316 | - Hit 1 at cli.js:5 | ||
| 325 | + Hit 1 at file:///path/to/cli.js:5:3 | ||
| 317 | 326 | rss = 54935552 | |
| 318 | - Hit 2 at cli.js:5 | ||
| 327 | + Hit 2 at file:///path/to/cli.js:5:3 | ||
| 319 | 328 | rss = 55083008 | |
| 320 | 329 | Completed | |
| 321 | 330 | ``` | |
| 322 | 331 | ||
| 332 | + The original `<file>:<line>[:<col>]` passed to `--probe` may be resolved to a different | ||
| 333 | + location to ensure it's pausable, or it can match multiple loaded scripts, so the actual | ||
| 334 | + evaluation location helps disambiguate the results. | ||
| 335 | + | ||
| 323 | 336 | Primitive results are printed directly, while objects and arrays use Chrome | |
| 324 | 337 | DevTools Protocol preview data when available. Other non-primitive values | |
| 325 | 338 | fall back to the Chrome DevTools Protocol `description` string. | |
@@ -331,23 +344,39 @@ When `--json` is used, the output shape looks like this: | |||
| 331 | 344 | ||
| 332 | 345 | ```console | |
| 333 | 346 | $ node inspect --json --probe cli.js:5 --expr 'rss' cli.js | |
| 334 | - {"v":1,"probes":[{"expr":"rss","target":["cli.js",5]}],"results":[{"probe":0,"event":"hit","hit":1,"result":{"type":"number","value":55443456,"description":"55443456"}},{"probe":0,"event":"hit","hit":2,"result":{"type":"number","value":55574528,"description":"55574528"}},{"event":"completed"}]} | ||
| 347 | + {"v":2,"probes":[{"expr":"rss","target":{"suffix":"cli.js","line":5}}],"results":[{"probe":0,"event":"hit","hit":1,"location":{"url":"file:///path/to/cli.js","line":5,"column":3},"result":{"type":"number","value":55443456,"description":"55443456"}},{"probe":0,"event":"hit","hit":2,"location":{"url":"file:///path/to/cli.js","line":5,"column":3},"result":{"type":"number","value":55574528,"description":"55574528"}},{"event":"completed"}]} | ||
| 335 | 348 | ``` | |
| 336 | 349 | ||
| 337 | 350 | ```json | |
| 338 | 351 | { | |
| 339 | - "v": 1, // Probe JSON schema version. | ||
| 352 | + "v": 2, // Probe JSON schema version. | ||
| 340 | 353 | "probes": [ | |
| 341 | 354 | { | |
| 342 | 355 | "expr": "rss", // The expression paired with --probe. | |
| 343 | - "target": ["cli.js", 5] // [file, line] or [file, line, col]. | ||
| 356 | + "target": { | ||
| 357 | + // The user's probe specification. `suffix` is the raw <file> passed | ||
| 358 | + // to --probe and is matched as a path-separator-anchored suffix | ||
| 359 | + // against every loaded script's URL. `column` is present only if the | ||
| 360 | + // user supplied `:col`. The actual evaluation location may differ | ||
| 361 | + // from the target and will be reported in each hit's `location` field. | ||
| 362 | + "suffix": "cli.js", | ||
| 363 | + "line": 5 | ||
| 364 | + } | ||
| 344 | 365 | } | |
| 345 | 366 | ], | |
| 346 | 367 | "results": [ | |
| 347 | 368 | { | |
| 348 | 369 | "probe": 0, // Index into probes[]. | |
| 349 | 370 | "event": "hit", // Hit events are recorded in observation order. | |
| 350 | 371 | "hit": 1, // 1-based hit count for this probe. | |
| 372 | + "location": { | ||
| 373 | + // The actual location where the execution is paused to evaluate | ||
| 374 | + // the expression of the probe. This may differ from the probe's | ||
| 375 | + // target due to pausability adjustments or multiple matches. | ||
| 376 | + "url": "file:///path/to/cli.js", | ||
| 377 | + "line": 5, | ||
| 378 | + "column": 3 | ||
| 379 | + }, | ||
| 351 | 380 | "result": { | |
| 352 | 381 | "type": "number", | |
| 353 | 382 | "value": 55443456, | |
@@ -359,6 +388,7 @@ $ node inspect --json --probe cli.js:5 --expr 'rss' cli.js | |||
| 359 | 388 | "probe": 0, | |
| 360 | 389 | "event": "hit", | |
| 361 | 390 | "hit": 2, | |
| 391 | + "location": { "url": "file:///path/to/cli.js", "line": 5, "column": 3 }, | ||
| 362 | 392 | "result": { | |
| 363 | 393 | "type": "number", | |
| 364 | 394 | "value": 55574528, | |
@@ -427,9 +457,9 @@ $ node inspect --probe app.js:4 --expr 'x' --probe app.js:4 --expr 'y' -- app.js | |||
| 427 | 457 | Prints | |
| 428 | 458 | ||
| 429 | 459 | ```text | |
| 430 | - Hit 1 at app.js:4 | ||
| 460 | + Hit 1 at file:///path/to/app.js:4:1 | ||
| 431 | 461 | x = {x: 42} | |
| 432 | - Hit 1 at app.js:4 | ||
| 462 | + Hit 1 at file:///path/to/app.js:4:1 | ||
| 433 | 463 | y = {y: 35} | |
| 434 | 464 | Completed | |
| 435 | 465 | ``` | |
@@ -441,7 +471,7 @@ $ node inspect --probe app.js:4 --expr 'x' --probe app.js:4 --expr 'y' --json -- | |||
| 441 | 471 | Prints | |
| 442 | 472 | ||
| 443 | 473 | ```json | |
| 444 | - {"v":1,"probes":[{"expr":"x","target":["app.js",4]},{"expr":"y","target":["app.js",4]}],"results":[{"probe":0,"event":"hit","hit":1,"result":{"type":"object","description":"Object","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"x","type":"number","value":"42"}]}}},{"probe":1,"event":"hit","hit":1,"result":{"type":"object","description":"Object","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"y","type":"number","value":"35"}]}}},{"event":"completed"}]} | ||
| 474 | + {"v":2,"probes":[{"expr":"x","target":{"suffix":"app.js","line":4}},{"expr":"y","target":{"suffix":"app.js","line":4}}],"results":[{"probe":0,"event":"hit","hit":1,"location":{"url":"file:///path/to/app.js","line":4,"column":1},"result":{"type":"object","description":"Object","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"x","type":"number","value":"42"}]}}},{"probe":1,"event":"hit","hit":1,"location":{"url":"file:///path/to/app.js","line":4,"column":1},"result":{"type":"object","description":"Object","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"y","type":"number","value":"35"}]}}},{"event":"completed"}]} | ||
| 445 | 475 | ``` | |
| 446 | 476 | ||
| 447 | 477 | ### Selecting the probe location | |
@@ -459,7 +489,7 @@ console.log(x); // line 3 | |||
| 459 | 489 | ||
| 460 | 490 | ```console | |
| 461 | 491 | $ node inspect --probe app.js:1 --expr 'x' app.js | |
| 462 | - Hit 1 at app.js:1 | ||
| 492 | + Hit 1 at file:///path/to/app.js:1:1 | ||
| 463 | 493 | [error] x = ReferenceError: Cannot access 'x' from debugger | |
| 464 | 494 | ... | |
| 465 | 495 | Completed | |
@@ -469,13 +499,16 @@ Instead, probe at a location where the variable is already initialized: | |||
| 469 | 499 | ||
| 470 | 500 | ```console | |
| 471 | 501 | $ node inspect --probe app.js:3 --expr 'x' app.js | |
| 472 | - Hit 1 at app.js:3 | ||
| 502 | + Hit 1 at file:///path/to/app.js:3:1 | ||
| 473 | 503 | x = 42 | |
| 474 | 504 | Completed | |
| 475 | 505 | ``` | |
| 476 | 506 | ||
| 477 | - Probe paths are matched against loaded script URLs by basename, similar to how | ||
| 478 | - native debuggers typically match breakpoints. Given: | ||
| 507 | + The `<file>` argument is matched as a path suffix of every loaded | ||
| 508 | + script URL, anchored on a path separator. Passing only a basename | ||
| 509 | + matches every loaded script with that basename, similar to how native | ||
| 510 | + debuggers typically match breakpoints, while passing a partial path | ||
| 511 | + narrows the match. Given: | ||
| 479 | 512 | ||
| 480 | 513 | ```text | |
| 481 | 514 | project/ | |
@@ -484,7 +517,10 @@ project/ | |||
| 484 | 517 | ``` | |
| 485 | 518 | ||
| 486 | 519 | `--probe utils.js:10` binds to _both_ files and produces one hit per match. | |
| 487 | - To disambiguate, specify a fuller path that only matches the intended file: | ||
| 520 | + Each hit carries its own `location` field identifying where the expression | ||
| 521 | + was actually executed, so consumers can attribute the result to one of the | ||
| 522 | + two files accurately. To disambiguate at bind time, specify a fuller path | ||
| 523 | + that only matches the intended file: | ||
| 488 | 524 | ||
| 489 | 525 | ```console | |
| 490 | 526 | $ node inspect --probe src/utils.js:10 --expr 'x' main.js # matches only src/utils.js | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -99,9 +99,12 @@ Example: | |||
| 99 | 99 | ||
| 100 | 100 | Options: | |
| 101 | 101 | --probe <file>:<line>[:<col>] | |
| 102 | - Source location of the probe (1-based, col defaults | ||
| 103 | - to 1). Matches by file basename, use a fuller path to | ||
| 104 | - disambiguate. Must be immediately followed by --expr. | ||
| 102 | + Source location of the probe. <file> is matched as a | ||
| 103 | + path suffix of every loaded script URL, anchored on | ||
| 104 | + a path separator. <line> and the optional <col> are | ||
| 105 | + 1-based. If <col> is omitted, the probe binds to | ||
| 106 | + the first executable column on the line. This option | ||
| 107 | + must be immediately followed by a pairing --expr. | ||
| 105 | 108 | --expr <expr> Expression to evaluate in the lexical scope of the | |
| 106 | 109 | preceding --probe each time execution reaches it. | |
| 107 | 110 | Avoid probing let/const-bound variables at their | |
@@ -114,6 +117,8 @@ Options: | |||
| 114 | 117 | Semantics: | |
| 115 | 118 | * Multiple --probe/--expr pairs are allowed. Same-location --probes share | |
| 116 | 119 | a pause and scope, their --exprs are evaluated in command-line order. | |
| 120 | + * --probe utils.js:<line>[:<col>] matches every loaded utils.js. Pass a | ||
| 121 | + fuller path e.g. src/utils.js to narrow the match. | ||
| 117 | 122 | * Use -- before any Node.js flags intended for the child process. | |
| 118 | 123 | * Target errors are surfaced in the report as a terminal 'error' event. | |
| 119 | 124 | The probing process exits 0 unless it encounters an error itself. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments