DDD is a visual debugger that allows one to step through a program and follow its execution. It is based on and runs the same as the gdb debugger.
To run a program with ddd, just do:
ddd program name
It helps if the program is compiled with debugging symbols (-g flag to gcc) and to be in the directory where the source code is.
Once started you will get two different windows:
one with the following prompt:
(gdb) and the other with the .c file:
Usually you will want to start off by setting a break point at the main function and actually start running the program:
To set a break point:
Place the cursor on the line, in the machine code window, where you want to find information and then click the stop sign on the ddd tool bar.
To pass command line arguments to the program, before running it do:
(gdb) set args arguments
Where arguments are the arguments.
in the gdb display window. (important)
To step through a program, you can use the "next" and "step" buttons. "next" will not step into functions while "step" will.
Use the stepi button to step through the program, instruction by instruction.
Break points can be set using the "break" button on the ddd tool bar. Click on the line for where you want the break point set.
You can cause the program to execute until the next break point using the "continue" button.
To view a memory location click on data and then click on memory. Type what type of data structures (words, bytes, etc.) you would like to view and how you would like to view them (hex, dec, octal, etc.) and where you would like to start. I suggest the format of hex and words.
To see what instruction the debugger is currently on click on view and then click on machine code. This will give you access to the ($esp)stack pointer and the ($ebp)base pointer.
To view data inside a pointer or a register move the mouse over the appropriate name (i.e. $esp) and a small box will pop up with the current value of what you are looking at.
Go to the GDB webpage.