joyent/node — Issue #2339: Feature request: additional parameter to the debugger mode - debug-script files 
Author: osher
Created: 2011-12-15 12:00:15+00:00
State: open

**Motive**
Trying to reuse my core files on both client and server I avoid by policy using debugger statements.
However, I would still like to have them placed for me when I attend to debug a utility file.

More over - since debugging a utility file usually results in placing debugger statements in the same places, it should be supported to automate setting them without polluting source files with debugger statements.

**Proposal**

I noticed that running node in debug mode starts with an initial brakepoint, in which I can set brakepoints using debugger context functions like sb(), and so forth.

Consider the following usage:

```

$ node [path/to/debugged/file] [path/to/debugging/script]

```

where the goal of the debugging script is to mainly place brakepoints for you, but any debugger-context function should be supported.

Example:

debugged file:hello.js

```

1 var x = 0;
2 setTimeout(function () {
3 x = x + 1;
4 console.log("world " + x );
5 }, 1000);
6 console.log("hello");

```

debugger script: hello_debug_xcount.ndb

```

1 sb(3)
2 watch("x")
3 c

```

debugger command

```

$ node debug hello.js hello_debug_xcount.ndb

```

will set a break-point in line 3, add "x" to watch, start the script ... and stop on the break-point on line 3 :)

using this, you can have for every utility several debugging-scripts, that place breakpoints in different places according to the debugged logic.

**Nice to haves:**
maybe it would also be useful to support several debug scripts at once, so you can summon to your debug context several groups of debugs...

Another wild idea is to have any additional parameter passed to the last debug script, and execute debug logic there...

(P.S - ndb - I noted that the debug commands are not exacly javascript...
for example, you call ```c``` and not ```c()```.
so ndb postfix stands for = node debugger... or maybe nds = node debug script, I don't mind...)