4
4
5
5
<!-- type=misc -->
6
6
7
- V8 comes with an extensive debugger which is accessible out-of-process via a
8
- simple [ TCP protocol] [ ] . Node.js has a built-in client for this debugger. To
9
- use this, start Node.js with the ` debug ` argument; a prompt will appear:
7
+ Node.js includes a full-featured out-of-process debugging utility accessible
8
+ via a simple [ TCP-based protocol] [ ] and built-in debugging client. To use it,
9
+ start Node.js with the ` debug ` argument followed by the path to the script to
10
+ debug; a prompt will be displayed indicating successful launch of the debugger:
10
11
11
12
% node debug myscript.js
12
13
< debugger listening on port 5858
@@ -17,11 +18,13 @@ use this, start Node.js with the `debug` argument; a prompt will appear:
17
18
3 debugger;
18
19
debug>
19
20
20
- Node.js's debugger client doesn't support the full range of commands, but
21
- simple step and inspection is possible. By putting the statement ` debugger; `
22
- into the source code of your script, you will enable a breakpoint.
21
+ Node.js's debugger client does not yet support the full range of commands, but
22
+ simple step and inspection are possible.
23
23
24
- For example, suppose ` myscript.js ` looked like this:
24
+ Inserting the statement ` debugger; ` into the source code of a script will
25
+ enable a breakpoint at that position in the code.
26
+
27
+ For example, suppose ` myscript.js ` is written as:
25
28
26
29
// myscript.js
27
30
x = 5;
@@ -31,7 +34,7 @@ For example, suppose `myscript.js` looked like this:
31
34
}, 1000);
32
35
console.log('hello');
33
36
34
- Then once the debugger is run, it will break on line 4.
37
+ Once the debugger is run, a breakpoint will occur at line 4:
35
38
36
39
% node debug myscript.js
37
40
< debugger listening on port 5858
@@ -73,20 +76,20 @@ Then once the debugger is run, it will break on line 4.
73
76
%
74
77
75
78
76
- The ` repl ` command allows you to evaluate code remotely. The ` next ` command
77
- steps over to the next line. There are a few other commands available and more
78
- to come. Type ` help ` to see others .
79
+ The ` repl ` command allows code to be evaluated remotely. The ` next ` command
80
+ steps over to the next line. Type ` help ` to see what other commands are
81
+ available .
79
82
80
83
## Watchers
81
84
82
- You can watch expression and variable values while debugging your code.
83
- On every breakpoint each expression from the watchers list will be evaluated
84
- in the current context and displayed just before the breakpoint's source code
85
- listing.
85
+ It is possible to watch expression and variable values while debugging. On
86
+ every breakpoint, each expression from the watchers list will be evaluated
87
+ in the current context and displayed immediately before the breakpoint's
88
+ source code listing.
86
89
87
- To start watching an expression, type ` watch(" my_expression" ) ` . ` watchers `
88
- prints the active watchers. To remove a watcher, type
89
- ` unwatch(" my_expression" ) ` .
90
+ To begin watching an expression, type ` watch(' my_expression' ) ` . The command
91
+ ` watchers ` will print the active watchers. To remove a watcher, type
92
+ ` unwatch(' my_expression' ) ` .
90
93
91
94
## Commands reference
92
95
@@ -154,19 +157,20 @@ breakpoint)
154
157
### Various
155
158
156
159
* ` scripts ` - List all loaded scripts
157
- * ` version ` - Display v8 's version
160
+ * ` version ` - Display V8 's version
158
161
159
162
## Advanced Usage
160
163
161
- The V8 debugger can be enabled and accessed either by starting Node.js with
162
- the ` --debug ` command-line flag or by signaling an existing Node.js process
163
- with ` SIGUSR1 ` .
164
+ An alternative way of enabling and accessing the debugger is to start
165
+ Node.js with the ` --debug ` command-line flag or by signaling an existing
166
+ Node.js process with ` SIGUSR1 ` .
164
167
165
- Once a process has been set in debug mode with this it can be connected to
166
- with the Node.js debugger. Either connect to the ` pid ` or the URI to the
167
- debugger. The syntax is :
168
+ Once a process has been set in debug mode this way, it can be connected to
169
+ using the Node.js debugger by either connecting to the ` pid ` of the running
170
+ process or via URI reference to the listening debugger :
168
171
169
172
* ` node debug -p <pid> ` - Connects to the process via the ` pid `
170
- * ` node debug <URI> ` - Connects to the process via the URI such as localhost:5858
173
+ * ` node debug <URI> ` - Connects to the process via the URI such as
174
+ localhost:5858
171
175
172
- [ TCP protocol ] : https://github.com/v8/v8/wiki/Debugging-Protocol
176
+ [ TCP-based protocol ] : https://github.com/v8/v8/wiki/Debugging-Protocol
0 commit comments