Documentation
Author: Alex Rakhlin

# JSDB

## Overview

JSDB is a command line debugger modeled after jdb.

## Supported Commands

### Normal State:

load <filename> | Load and run a javascript file.
suspend | Stop before first instruction is executed
stop at <filename> <line> | Set a breakpoint. File doesn't have to be loaded yet.
clear at <filename> <line> | Clear a breakpoint.
bp | List breakpoints.
list <filename> <line> | Print source code.
scripts | List loaded scripts.
quit, exit | Quit jsdb.

### Stopped State:

resume, exit | Resume execution.
stop at <filename> <line> | Set a breakpoint.
clear at <filename> <line> | Clear a breakpoint.
bp | List breakpoints.
list [<filename> <line>] | Print source code. If filename is not specified, prints the current line in the current stackframe.
up | Move up the stack.
down | Move down the stack.
where | Dump stack.
step | Execute current line.
eval <expr> | Evaluate expression in current frame. print() function is supported, so, for example, eval print(a) will print the value of variable a.

## Example

sample.js:
______________________________________________________
a=1;
for (i=0; i<10; i++){
a = inc (inc(a));
}

c = a+2;

// Increment function
function inc (b){
return b+1;
}
______________________________________________________

A sample JSDB session could be:

>stop at sample.js:6
Script not loaded. Breakpoint will be set once the script is loaded
>load sample.js
Set breakpoint at sample.js null 6
Stopped at 6
STOPPED >>list
c = a+2;
STOPPED >>eval print (a)
21
STOPPED >>resume
>

## Notes

- I didn't test JSDB much, so I'm sure that there are some bugs. If you find one, or if you have a suggestion, please e-mail me.

## Bugs and "features"

- Important: JSDB crashes when executed with jits. Use -nojit switch if you are using jre.exe.

Alex Rakhlin
rakhlin@netscape.com