Debuggers

The standard debugger on Linux systems is gdb, with DDD as a graphical user frontend. To enable full debugging in your programs, you must run the compiler with the -g option to write a symbol table and other debugging information into the executable. To start gdb on an executable named program, run this command:

gdb program

You should get a (gdb) prompt. To run program with the command-line arguments options, type this at the (gdb) prompt:

run options

If the program works, it should start, run, and exit as normal. However, if there's a problem,gdb stops, prints a stack trace and the failed source code, and throws you back to the (gdb) prompt. Because the source code fragment often gives you a hint about the problem, you often want to ...

Get How Linux Works now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.