Chapter 1. Introduction

Debugging is the art of removing bugs from software. The software may be code, documentation, or any other intellectual product. Here, we will look at the debugging of computer programs (or libraries) written in C or C++ in a Unix environment. Most of it is also applicable to other compiled procedural and object oriented languages like Pascal, Modula and Objective C.

We will mostly focus on techniques and tools to assist in debugging. Of course, it is better to prevent bugs from slipping into your code in the first place. Sometimes it is difficult to distinguish between good coding practices and good debugging practices, because good debugging practices often involve preparation and prevention. So, we will also discuss some good coding practices that you should consider adopting. These practices will not make your programs bug-free, but they will diminish the occurrence of certain types of bugs, while preparing you better for dealing with the remaining ones.

It is our experience that many people waste large amounts of time on localising bugs that are quite easy to fix once they are found, because they are not aware of, or do not know how to use, the tools, techniques and practices available to them.

Our goal is to help you prevent wasting your time in this fashion. We hope you will invest time to study the material covered here; we are convinced this investment will pay off.