First download and install ddd
Second, make and install ns-2 with debug information after making the changes as follows:
In the file ns-allinone/install, look for, and change the line :
# Build Tcl8.4.5 (should be around line 406)
./configure --enable-gcc --disable-shared --prefix=$CUR_PATH || ....
so it becomes:
./configure --enable-gcc --enable-symbols --disable-shared --prefix=$CUR_PATH || ....
Still in the ns-allinone/install file, look for the tclcl section.
# Build tclcl (should be around line 497)
in this section, you need to add –enable-debug to your configure line, such that:
./configure || ...
./configure --enable-debug || ...
Then save and close the ns-allinone/install file. Open the ns-allinone/ns/Makefile.in, and search for CFLAGS (should be around line 82). Change it from
CFLAGS = $(CCOPT) $(DEFINE)
CFLAGS = -g $(CCOPT) $(DEFINE)
Now we’re done with the editing. To clean up the old object files in the ns-allinone/ns folder, execute the command
Now go to your ns-allinone folder and type
after everything is done, debugging symbols should be enabled. For convenience the command
sudo make install
can be executed in the directory ns-allinone/ns to make ns available outside the ns directory.
Finally ddd can be started by writing
In the debugger the ns-2 source code should now be shown. Find the source file where you would like to set a breakpoint using the menu File->Open Source. Next choose to run a simulation by selecting Program->Run from the menu, or just press F2. In the “Run with Arguments” field, enter the complete path and filename of the script file and necessary script file parameters, and then press Run.