Some people, especially professionals, may be tempted to skip this chapter. We suggest, though, that everyone at least skim through it. Many professionals will find some material that is new to them, and in any case it is important that all readers be familiar with the material presented here, which will be used throughout the remainder of the book. Beginners should of course read this chapter carefully.
In the first few sections of this chapter, we will present an overview of the debugging process and the role of debugging tools, and then walk through an extended example in Introductory Debugging Session.
In this book we set out the basic principles of debugging, illustrating them in the contexts of the following debugging tools:
The most commonly used debugging tool among Unix programmers is GDB, the GNU Project Debugger developed by Richard Stallman, a prominent leader of the open source software movement, which played a key role in the development of Linux.
Most Linux sytems should have GDB preinstalled. If it is not, you must download the GCC compiler package.
Due to the more recent popularity of graphical user interfaces (GUIs), a number of GUI-based debuggers have been developed that run under Unix. Most of these are GUI front ends to GDB: The user issues commands via the GUI, which in turn passes them on to GDB. One of these is DDD, the Data Display Debugger.
If your system does not already have DDD installed, you can download it. For instance, on Fedora Linux systems, the command
yum install ddd
will take care of the entire process for you. In Ubuntu Linux, a similar command, apt-get
, can be used.
Some readers may use integrated development environments (IDEs). An IDE is more than just a debugging tool; it integrates an editor, build tool, debugger, and other development aids into one package. In this book, our example IDE is the highly popular Eclipse system. As with DDD, Eclipse works on top of GDB or some other debugger.
You can install Eclipse via yum
or apt-get
as above, or simply download the .zip file and unpack it in a suitable directory, say /usr/local.
In this book, we use Eclipse version 3.3.