Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@indutny
Created December 10, 2011 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indutny/1455534 to your computer and use it in GitHub Desktop.
Save indutny/1455534 to your computer and use it in GitHub Desktop.
/tmp > node debug node-debugger-example.js
< debugger listening on port 5858
connecting... ok
debug> help
Commands: run (r), cont (c), next (n), step (s), out (o), backtrace (bt), setBreakpoint (sb), clearBreakpoint (cb),
watch, unwatch, watchers, repl, restart, kill, list, scripts, breakpoints, version
debug> list()
1 var http = require('http');
2
3 http.createServer(function(req, res) {
4 if (req.url === '/') {
5 // Index page
debug> next
break in node-debugger-example.js:3
1 var http = require('http');
2
3 http.createServer(function(req, res) {
4 if (req.url === '/') {
5 // Index page
debug> list(10)
1 var http = require('http');
2
3 http.createServer(function(req, res) {
4 if (req.url === '/') {
5 // Index page
6 res.end('hello world');
7 } else {
8 // Favicon and everything else
9 res.writeHead(400);
10 res.end('not found');
11 }
12 }).listen(8080);
13 });
debug> setBreakpoint('node-debugger-example', 6)
1 var http = require('http');
2
3 http.createServer(function(req, res) {
4 if (req.url === '/') {
5 // Index page
* 6 res.end('hello world');
7 } else {
8 // Favicon and everything else
debug> cont
break in node-debugger-example.js:6
4 if (req.url === '/') {
5 // Index page
* 6 res.end('hello world');
7 } else {
8 // Favicon and everything else
debug> repl
Press Ctrl + C to leave debug repl
> res.<TAB>
res.__defineGetter__ res.__defineSetter__ res.__lookupGetter__ res.__lookupSetter__ res.constructor res.hasOwnProperty
res.isPrototypeOf res.propertyIsEnumerable res.toLocaleString res.toString res.valueOf
res._events res._hasBody res._last res._trailer res.chunkedEncoding res.connection
res.finished res.output res.outputEncodings res.shouldKeepAlive res.socket res.useChunkedEncodingByDefault
res.writable
> res.end('hahahaha')
true
>
debug> cont
break in node-debugger-example.js:6
4 if (req.url === '/') {
5 // Index page
* 6 res.end('hello world');
7 } else {
8 // Favicon and everything else
debug> watch('req.url')
debug> watchers
0: req.url = "/"
debug> n
break in node-debugger-example.js:12
Watchers:
0: req.url = "/"
10 res.end('not found');
11 }
12 }).listen(8080);
13 });
debug> unwatch('req.url')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment