GeezerVison is showing github.com — debugger: add debugger alias for exec(expr) · nodejs/node@e4f0d95
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/debugger.md +2-1Lines changed: 2 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -197,7 +197,8 @@ debug> | 197 | 197 | * `watchers`: List all watchers and their values (automatically listed on each | 198 | 198 | breakpoint) | 199 | 199 | * `repl`: Open debugger's repl for evaluation in debugging script's context | 200 | | -* `exec expr`: Execute an expression in debugging script's context | | 200 | +* `exec expr`, `p expr`: Execute an expression in debugging script's context and | | 201 | + print its value | 201 | 202 |
| 202 | 203 | ### Execution control | 203 | 204 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/debugger/inspect_repl.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -68,6 +68,7 @@ const SHORTCUTS = { | 68 | 68 | setBreakpoint: 'sb', | 69 | 69 | clearBreakpoint: 'cb', | 70 | 70 | run: 'r', | | 71 | + exec: 'p' | 71 | 72 | }; | 72 | 73 |
| 73 | 74 | const HELP = StringPrototypeTrim(` | @@ -93,7 +94,8 @@ watch(expr) Start watching the given expression | 93 | 94 | unwatch(expr) Stop watching an expression | 94 | 95 | watchers Print all watched expressions and their current values | 95 | 96 |
| 96 | | -exec(expr) Evaluate the expression and print the value | | 97 | +exec(expr), p(expr), exec expr, p expr | | 98 | + Evaluate the expression and print the value | 97 | 99 | repl Enter a debug repl that works like exec | 98 | 100 |
| 99 | 101 | scripts List application scripts that are currently loaded | @@ -530,7 +532,7 @@ function createRepl(inspector) { | 530 | 532 | function prepareControlCode(input) { | 531 | 533 | if (input === '\n') return lastCommand; | 532 | 534 | // Add parentheses: exec process.title => exec("process.title"); | 533 | | - const match = RegExpPrototypeSymbolMatch(/^\s*exec\s+([^\n]*)/, input); | | 535 | + const match = RegExpPrototypeSymbolMatch(/^\s*(?:exec|p)\s+([^\n]*)/, input); | 534 | 536 | if (match) { | 535 | 537 | lastCommand = `exec(${JSONStringify(match[1])})`; | 536 | 538 | } else { | |
Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-debugger-exec.js +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,6 +27,14 @@ const assert = require('assert'); | 27 | 27 | 'works w/o paren' | 28 | 28 | ); | 29 | 29 | }) | | 30 | + .then(() => cli.command('p [typeof heartbeat, typeof process.exit]')) | | 31 | + .then(() => { | | 32 | + assert.match( | | 33 | + cli.output, | | 34 | + /\[ 'function', 'function' \]/, | | 35 | + 'works w/o paren, short' | | 36 | + ); | | 37 | + }) | 30 | 38 | .then(() => cli.command('repl')) | 31 | 39 | .then(() => { | 32 | 40 | assert.match( | @@ -54,6 +62,14 @@ const assert = require('assert'); | 54 | 62 | 'works w/ paren' | 55 | 63 | ); | 56 | 64 | }) | | 65 | + .then(() => cli.command('p("[typeof heartbeat, typeof process.exit]")')) | | 66 | + .then(() => { | | 67 | + assert.match( | | 68 | + cli.output, | | 69 | + /\[ 'function', 'function' \]/, | | 70 | + 'works w/ paren, short' | | 71 | + ); | | 72 | + }) | 57 | 73 | .then(() => cli.command('cont')) | 58 | 74 | .then(() => cli.command('exec [typeof heartbeat, typeof process.exit]')) | 59 | 75 | .then(() => { | |
|