Debugging Tools for C on Linux Platform



Introduction

This article talks about debugging tools for applications in C on Linux platforms. Most of the tools are freely available on all major platforms with very wide user support. The tools help in static analysis of code as well as assist in dynamic evaluation of code.

Please note that tools listed here are suggestions of the Author. This list is not a standard one. Changes have to be done in it depending upon the nature, scope and details of the application to be developed.


Debugging Tools


  1. Dmalloc

    The debug memory allocation or dmalloc library is a freeware debugging tool which has been specially designed as a drop in replacement for the system's malloc, realloc, calloc, free and other memory management routines while providing powerful debugging facilities configurable at runtime. It makes changes during compile time and donot add runtime changes in binary. These facilities include such things as memory-leak tracking, fence-post write detection, file/line number reporting, and general logging of statistics. The library is reasonably portable having been run successfully on at least the following operating systems: AIX, BSD/OS, DG/UX, Free/Net/OpenBSD, GNU/Hurd, HPUX, Irix, Linux, MS-DOG, NeXT, OSF, SCO, Solaris, SunOS, Ultrix, Unixware, Windoze, and even Unicos on a Cray T3E. It has full support for programs the debugging of POSIX threads.

    The package includes the library, configuration scripts, debug utility application, test program, and documentation.

  2. Valgrind

    Valgrind is a GPL distributed system for debugging and profiling x86-Linux programs. I can also be helpful for programs for platforms other than x86 since behavior of x86 binary is similar to other binaries. The accompanying tools with Valgrind automatically detect many memory management and threading bugs, avoiding hours of frustrating bug-hunting, making programs more stable. It supports a through detailed profiling to help speed up the programs.

    The Valgrind distribution includes four tools: two memory error detectors, a thread error detector, and a cache profiler.

  3. Electricfence

    Electric Fence is a freeware library that can be used for C programming and debugging. It can be linked at compile time and it will warn about possible problems such as freeing memory that doesn't exist, etc. It is basically a memory profiling tool. However currently it is available only on HP-Unix platform (I am not very sure though).

  4. GDB

    This is the Gnome Debugger which comes as a freeware support package with freeware Linux distribution like Red Hat, Slacware, and Debian etc. It has full support of many languages like C, C++, and Perl etc. It helps to debug the binaries of these languages in modes like single step, multiple step or complete run. It also has provisions of setting break points and trace value.

    It is helpful for stub testing, functional flow checking and bound checking. Further this is readily available with all flavours of Linux andUnix platforms and is amply supported in user community.

  5. Insight

    Insight is a graphical user interface to GDB, the GNU Debugger written in Tcl/Tk by at Red Hat, Inc. and Cygnus Solutions Insight provides all features provided by GDB along with Graphical debugging interface replacing traditional command based interface.

  6. Memprof

    MemProf is a free ware memory Profiling and memory leak detection tool which comes as an addendum to common Linux distributions. It can generate a profile how much memory was allocated by each function in the program. It can scan memory and find blocks that have been allocated but are no longer referenced anywhere (dead code).

    MemProf works by pre-loading a library to override the C library's memory allocation functions and does not require recompiling the program. One advantage MemProf has over some other similar tools that are available is that it has a nice GUI front-end and is relatively easy to use.

 
I am Nikhil Bhargava from Delhi, India. I am a Computer Engineer curently working in C-DOT, India for past one year. Comments and Suggestions are always welcome.

Copyright © 2003, Nikhil Bhargava.

Hosted by www.Geocities.ws

1