Using ctrace to debug
ctrace is a program on gl that will help you debug simple projects.
It is easier to learn than dbx or gdb, but it is less useful
for complex projects. ctrace will add comments to your program that
highlight on the screen the steps your program takes during execution. the
best way to learn about ctrace is by reading the ctrace man page
First, run ctrace on your program
ctrace proj2.c >proj2trace.c
Second, compile the ctrace-ized version of your program
cc proj2trace.c
Third, run this new version of your program, and hopefully it will show you what's happening to your variables and control code as your program is running
a.out
CAVEATS
Do NOT submit ctraced versions of your code. Once you figure out what is
wrong, make corrections to your ORIGINAL code, run it to make sure it works, and submit YOUR code.
If you are using multiple files, you will have to run ctrace on ALL of them, or at least the ones you want to trace.
Don't try to learn any debugger on the day a project is due. You will get confused, frustrated, and depressed. Play with the debuggers several days before the due date, so you can actually learn something.
dbx and gdb are more useful, but harder to learn than ctrace. To use dbx or gdb, you have to compile your program with the -g option, to insert debugging codes. for more information, man dbx