Linux Today: Linux News On Internet Time.

IBM developerWorks: Linux software debugging with GDB

Mar 17, 2001, 20:30 (6 Talkback[s])
(Other stories by David Seager)

[ Thanks to Frank for this link. ]

"Most flavours of Linux come with the GNU debugger, or gdb to the shell. Gdb lets you see the internal structure of a program, print out variable values, set breakpoints and single step through source code. It makes an extremely powerful tool for fixing problems in program code. In this article I'll try to show how cool and useful gdb is."

"Before you can get started, the program you want to debug has to be compiled with debugging information in it. This is so gdb can work out the variables, lines and functions being used. To do this, compile your program under gcc (or g++) with an extra '-g' option..."

"Gdb is run from the shell with the command 'gdb' with the program name as a parameter, for example 'gdb eg', or you can use the file command once inside gdb to load a program for debugging, for example 'file eg'. Both of these assume you execute the commands from the same directory as the program. Once loaded, the program can be started with the gdb command 'run'."

Complete Story

Related Stories: