Free Programming Books
Free download ebooks on computer and programming

Free Ebook Computer Programming

Free Ebook Computer Programming :
Debugging C and C++ code in a Unix environment.pdf
Publisher :
Unknown
Pages :29
Format :pdf
Size :0.2 MB
Upload date :01-12-06

Table of content

Coming soon

Other HOT and Free ebooks!!

Coming Soon

This document describes several techniques and tools for debugging code in C-like languages in a Unix environment.

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.

Free Ebook C, C++ Computer Programming: J.H.M. Dassen--Debugging C and C++ code in a Unix environment.pdf

C and C++ specific problems

There are some features of the C and C++ languages and the associated build process that often lead to problems..........more

Download free ebook : Debugging_C_and_C++_code_in_a_Unix_environment.pdf
This book describes several techniques and tools for debugging code in C-like languages in a Unix environment.

Preprocessor

C and C++ use a preprocessor to expand macro's, declare dependencies and import declarations and to do conditional compilation. In itself, this is quite reasonable. You should realise however that all of these are done on a textual level. The C/C++ preprocessor does not This can make it difficult to track down missing declarations, it can lead to semantic problems because of macro expansion and it can cause subtle problems.

If you suspect a problem due to preprocessing, check out the preprocessor's manual (e.g. [CPP]) and let it expand your file for examination.

Strong systems dependency

C was developed for use as a systems programming language. C and also C++ can give you access to a lot of operating system functionality. Unfortunately, there are a lot of small but significant differences among various Unix systems:

  • Some system calls are not available on all systems.
  • Some system calls and library functions are defined in different header files on different systems.
  • There may be differing semantics for particular routines. For example, on Sys V-like systems, a signal handler reinstalled. On BSD-like systems, a signal handler stays in place until explicitly removed.

Also, the size and representation of some of C's and C++'s basic types is dependent on the underlying system. As a C or C++ programmer, you should be aware of what things are explicitly undefined in the C or C++ standard, and thus are implementation (system or compiler) dependent. There are standard ways to overcome some of these problems, like using sizeof instead of the concrete size of the variable on the current system.

Top