Tkcon Latest Version 2.5.
Debug the Tcl/OTCL script in NS2. To set a breakpoint, add debug 1 directly to the corresponding position in the script file. Some basic commands are as follows:
S one-step execution (entering the process)
N single-step execution (do not enter the process)
C continue
R continues execution until it returns
U to upper-level scope
D. Go to the lower-level scope.
W. List call stacks
B. Set, clear, or display breakpoints.
H help
When you run the script, it stops at the corresponding breakpoint. You can use the puts command to print the values of various variables. Info is also a common command.
Info exists <variable>
<Variable> info class // query the class name of an object
<Variable> info instances // query all instances of a class
<Variable> info instprocs // query all instance processes of a class
<Variable> info vars
<Variable> info superclass/subclass // query the superclass/subclasses of A Class
If you think that the error lies in the C/C ++ code (usually this is the case), you need to use GDB for debugging. Generally, GDB is available in both UNIX and Linux and can be used directly. However, you must modify the MAKEFILE file, recompile the code, and generate a program containing debugging information before debugging. The method is to add the-G option on the ccopt macro. The debugging process is as follows:
First, input the gdb NS (for debugging), and the display should be (GDB)
Set breakpoint: B file name (XXXX. cc or XXX. h): number of rows
Run the Tcl Script: R file name (XXX. TCL)
DEBUG command: N, S
Show variable: P variable name
Delete the breakpoint D Checkpoint number
View breakpoint information: I B
There are many other commands that can be viewed with the help of H.
For example:
. GDB NS
. (GDB) set ARGs myscript. TCL
. (GDB) B myclass: myfunction
# This line set breakpoint
. Run
Reference: http://hi.baidu.com/cxh198412/blog/item/08f5342fc1eaab3d1e308917.html