mirror of https://github.com/nodejs/node.git
doc: update output examples in debugger.md
PR-URL: https://github.com/nodejs/node/pull/10944 Reviewed-By: Josh Gavant <joshgavant@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
05be62307d
commit
ca8c30a35c
|
@ -11,10 +11,10 @@ will be displayed indicating successful launch of the debugger:
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
$ node debug myscript.js
|
$ node debug myscript.js
|
||||||
< debugger listening on port 5858
|
< Debugger listening on 127.0.0.1:5858
|
||||||
connecting... ok
|
connecting to 127.0.0.1:5858 ... ok
|
||||||
break in /home/indutny/Code/git/indutny/myscript.js:1
|
break in /home/indutny/Code/git/indutny/myscript.js:1
|
||||||
1 x = 5;
|
> 1 global.x = 5;
|
||||||
2 setTimeout(() => {
|
2 setTimeout(() => {
|
||||||
3 debugger;
|
3 debugger;
|
||||||
debug>
|
debug>
|
||||||
|
@ -28,7 +28,7 @@ enable a breakpoint at that position in the code:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// myscript.js
|
// myscript.js
|
||||||
x = 5;
|
global.x = 5;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
debugger;
|
debugger;
|
||||||
console.log('world');
|
console.log('world');
|
||||||
|
@ -36,29 +36,29 @@ setTimeout(() => {
|
||||||
console.log('hello');
|
console.log('hello');
|
||||||
```
|
```
|
||||||
|
|
||||||
Once the debugger is run, a breakpoint will occur at line 4:
|
Once the debugger is run, a breakpoint will occur at line 3:
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
$ node debug myscript.js
|
$ node debug myscript.js
|
||||||
< debugger listening on port 5858
|
< Debugger listening on 127.0.0.1:5858
|
||||||
connecting... ok
|
connecting to 127.0.0.1:5858 ... ok
|
||||||
break in /home/indutny/Code/git/indutny/myscript.js:1
|
break in /home/indutny/Code/git/indutny/myscript.js:1
|
||||||
1 x = 5;
|
> 1 global.x = 5;
|
||||||
2 setTimeout(() => {
|
2 setTimeout(() => {
|
||||||
3 debugger;
|
3 debugger;
|
||||||
debug> cont
|
debug> cont
|
||||||
< hello
|
< hello
|
||||||
break in /home/indutny/Code/git/indutny/myscript.js:3
|
break in /home/indutny/Code/git/indutny/myscript.js:3
|
||||||
1 x = 5;
|
1 global.x = 5;
|
||||||
2 setTimeout(() => {
|
2 setTimeout(() => {
|
||||||
3 debugger;
|
> 3 debugger;
|
||||||
4 console.log('world');
|
4 console.log('world');
|
||||||
5 }, 1000);
|
5 }, 1000);
|
||||||
debug> next
|
debug> next
|
||||||
break in /home/indutny/Code/git/indutny/myscript.js:4
|
break in /home/indutny/Code/git/indutny/myscript.js:4
|
||||||
2 setTimeout(() => {
|
2 setTimeout(() => {
|
||||||
3 debugger;
|
3 debugger;
|
||||||
4 console.log('world');
|
> 4 console.log('world');
|
||||||
5 }, 1000);
|
5 }, 1000);
|
||||||
6 console.log('hello');
|
6 console.log('hello');
|
||||||
debug> repl
|
debug> repl
|
||||||
|
@ -68,11 +68,11 @@ Press Ctrl + C to leave debug repl
|
||||||
> 2+2
|
> 2+2
|
||||||
4
|
4
|
||||||
debug> next
|
debug> next
|
||||||
< world
|
|
||||||
break in /home/indutny/Code/git/indutny/myscript.js:5
|
break in /home/indutny/Code/git/indutny/myscript.js:5
|
||||||
|
< world
|
||||||
3 debugger;
|
3 debugger;
|
||||||
4 console.log('world');
|
4 console.log('world');
|
||||||
5 }, 1000);
|
> 5 }, 1000);
|
||||||
6 console.log('hello');
|
6 console.log('hello');
|
||||||
7
|
7
|
||||||
debug> quit
|
debug> quit
|
||||||
|
@ -121,24 +121,26 @@ is not loaded yet:
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
$ node debug test/fixtures/break-in-module/main.js
|
$ node debug test/fixtures/break-in-module/main.js
|
||||||
< debugger listening on port 5858
|
< Debugger listening on 127.0.0.1:5858
|
||||||
connecting to port 5858... ok
|
connecting to 127.0.0.1:5858 ... ok
|
||||||
break in test/fixtures/break-in-module/main.js:1
|
break in test/fixtures/break-in-module/main.js:1
|
||||||
1 var mod = require('./mod.js');
|
> 1 const mod = require('./mod.js');
|
||||||
2 mod.hello();
|
2 mod.hello();
|
||||||
3 mod.hello();
|
3 mod.hello();
|
||||||
debug> setBreakpoint('mod.js', 23)
|
debug> setBreakpoint('mod.js', 2)
|
||||||
Warning: script 'mod.js' was not loaded yet.
|
Warning: script 'mod.js' was not loaded yet.
|
||||||
1 var mod = require('./mod.js');
|
> 1 const mod = require('./mod.js');
|
||||||
2 mod.hello();
|
2 mod.hello();
|
||||||
3 mod.hello();
|
3 mod.hello();
|
||||||
|
4 debugger;
|
||||||
|
5
|
||||||
|
6 });
|
||||||
debug> c
|
debug> c
|
||||||
break in test/fixtures/break-in-module/mod.js:23
|
break in test/fixtures/break-in-module/mod.js:2
|
||||||
21
|
1 exports.hello = function() {
|
||||||
22 exports.hello = () => {
|
> 2 return 'hello from module';
|
||||||
23 return 'hello from module';
|
3 };
|
||||||
24 };
|
4
|
||||||
25
|
|
||||||
debug>
|
debug>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ breakpoint)
|
||||||
|
|
||||||
### TCP-based protocol
|
### TCP-based protocol
|
||||||
|
|
||||||
> Stability: 0 - Deprecated: Use [V8 Inspector Integration][] instead. The debug protocol used by the `--debug` flag was removed from V8.
|
> Stability: 0 - Deprecated: Use [V8 Inspector Integration][] instead.
|
||||||
|
The debug protocol used by the `--debug` flag was removed from V8.
|
||||||
|
|
||||||
An alternative way of enabling and accessing the debugger is to start
|
An alternative way of enabling and accessing the debugger is to start
|
||||||
Node.js with the `--debug` command-line flag or by signaling an existing
|
Node.js with the `--debug` command-line flag or by signaling an existing
|
||||||
|
@ -188,8 +191,7 @@ localhost:5858
|
||||||
**NOTE: This is an experimental feature.**
|
**NOTE: This is an experimental feature.**
|
||||||
|
|
||||||
V8 Inspector integration allows attaching Chrome DevTools to Node.js
|
V8 Inspector integration allows attaching Chrome DevTools to Node.js
|
||||||
instances for debugging and profiling.
|
instances for debugging and profiling. It uses the [Chrome Debugging Protocol][].
|
||||||
It uses the [Chrome Debugging Protocol][].
|
|
||||||
|
|
||||||
V8 Inspector can be enabled by passing the `--inspect` flag when starting a
|
V8 Inspector can be enabled by passing the `--inspect` flag when starting a
|
||||||
Node.js application. It is also possible to supply a custom port with that flag,
|
Node.js application. It is also possible to supply a custom port with that flag,
|
||||||
|
@ -203,9 +205,13 @@ $ node --inspect index.js
|
||||||
Debugger listening on port 9229.
|
Debugger listening on port 9229.
|
||||||
Warning: This is an experimental feature and could change at any time.
|
Warning: This is an experimental feature and could change at any time.
|
||||||
To start debugging, open the following URL in Chrome:
|
To start debugging, open the following URL in Chrome:
|
||||||
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node
|
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
|
||||||
```
|
```
|
||||||
|
|
||||||
|
(In the example above, the UUID dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
|
||||||
|
at the end of the URL is generated on the fly, it varies in different
|
||||||
|
debugging sessions.)
|
||||||
|
|
||||||
[Chrome Debugging Protocol]: https://chromedevtools.github.io/debugger-protocol-viewer/
|
[Chrome Debugging Protocol]: https://chromedevtools.github.io/debugger-protocol-viewer/
|
||||||
[TCP-based protocol]: #debugger_tcp_based_protocol
|
[TCP-based protocol]: #debugger_tcp_based_protocol
|
||||||
[V8 Inspector Integration]: #debugger_v8_inspector_integration_for_node_js
|
[V8 Inspector Integration]: #debugger_v8_inspector_integration_for_node_js
|
||||||
|
|
Loading…
Reference in New Issue