Ns supports Don Libs' Tcl debugger ( see its Postscript documentation at http://expect.nist.gov/tcl-debug/tcl-debug.ps.Z and its source code at http://expect.nist.gov/tcl-debug/tcl-debug.tar.gz ). Install the program or leave the source code in a directory parallel to ns-2 and it will be built. Unlike expect, described in the tcl-debug documentation, we do not support the -D flag. To enter the debugger, add the lines "debug 1" to your script at the appropriate location. In order to build ns with the debugging flag turned on, configure ns with configuration option "-enable-debug" and incase the Tcl debugger has been installed in a directory not parallel to ns-2, provide the path with configuration option "-with-tcldebug=<give/your/path/to/tcl-debug/library>".
An useful debugging command is $ns_ gen-map which may be used to list all OTcl objects in a raw form. This is useful to correlate the position and function of an object given its name. The name of the object is the OTcl handle, usually of the form _o###. For TclObjects, this is also available in a C++ debugger, such as gdb, as this-name_.
Tom Henderson 2011-11-05