Debugging C and C++ code in a Unix environment

J.H.M. Dassen

jdassen@wi.LeidenUniv.nl

I.G. Sprinkhuizen-Kuyper

kuyper@wi.LeidenUniv.nl

Copyright and Permission Notice

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice, may be included in translations approved by the Free Software Foundation [1] instead of in the original English.


Table of Contents
Abstract
1. Introduction
2. Conventions
3. Aspects of debugging C and C++ code
Noticing and localising a bug
Understanding a bug
Repairing a bug
Types of bugs
C and C++ specific problems
Preprocessor
Strong systems dependency
Weak type system
Explicit storage allocation and deallocation
Name space pollution
Incremental building/linking
The build process
Core dumps
Debugging techniques
Using the compiler's features
The RTFM technique
printf() debugging
Assertions: defensive programming
ANWB debugging
Code grinding (code walk through)
Tools
The editor
A version management system
The debugger
Memory allocation debugging tools
System call tracers
Profilers
Conclusions
Bibliography
A.
An example makefile
Documentation formats
Manual pages
Info documentation
HTML and PDF
Flat ASCII, DVI, PostScript etc.

Notes

[1]

Free Software Foundation, Inc.
            59 Temple Place, Suite 330
            Boston
            MA
            02111-1307
            USA