view · edit · history · print

Notes for C/C++ Devellopment



Memory Debugging Tools

There seem to be losts of C debugging tools (for malloc(), free(), etc..) but limmited C++ ones (for new(), delete(), etc..). C tools are fairly easy to write yourself, therefore i will only list C++ capable ones.

Valgrind

I use AMD64 for devellopment and can unfortuanlly not use Valgrind becouse its only for i386 binary's. But there is a sparkle of hope as explained in this newsgoup article.
For the moment Debian offers only the pure64-bit option for AMD64. You can however install a chrooted 32-bit environment and use valgrind inthere.

mpatrol

Installation notes:
  
$ cp config.sub config.sub.orig
$ cp /usr/share/misc/config.sub ./config.sub
$ cp libtool libtool.orig
$ cp /usr/bin/libtool ./libtool
# binutils-dev - The GNU binary utilities (BFD development files)
$ apt-get install binutils-dev

The make is successful now but i will try the Deb package mpatrolc102 which also seems to be version 1.4.8-9.
Hmm.. error during usage on AMD64
  
homy07:/tmp# gcc -include /usr/include/mpatrol.h -g test3.c 
/tmp/ccIlD63Y.o(.text+0x59): In function `main':
/tmp/test3.c:10: undefined reference to `__mp_alloc'
collect2: ld returned 1 exit status

YAMD

Does not compile on AMD64
  
homy07:/var/sw/yamd-0.32# make
gcc -c -Wall -W -O2 -DYAMD_VERSION=\"0.32\" -DUSE_LIBC_HOOKS -o yamd.o yamd.c
yamd.c: In function `print_footer':
yamd.c:1672: warning: implicit declaration of function `time'
yamd.c:1674: warning: implicit declaration of function `ctime'
yamd.c: In function `startup':
yamd.c:1861: error: `sigsegv_handler' undeclared (first use in this function)
yamd.c:1861: error: (Each undeclared identifier is reported only once
yamd.c:1861: error: for each function it appears in.)
yamd.c: At top level:
yamd.c:1527: warning: `handle_page_fault' defined but not used
make: *** [yamd.o] Error 1

It compiles on i386 chrooted but coredumps during usage.

Linux Kernel debugger

  • Don't know if this is a good idea to further analyze what's still hanging around in memory but here is an intro into the Linux KBD.

Leaktracer

  • Leaktracer. This tool does the reverse of what most memory tracing tools do. It traces only new/new[] and delete calls - it does not look at malloc/free/realloc.

Note: I guess these tools are not all ideal. Choosing one and getting them to work on AMD64 is harder then i tought - but i'm not giving up.


Compilers i use...

  • GCC Compiler (gcc, g++, etc..) => Free
  • IBM's Visual Age C++ Compiler for RS/6000 (doc) => Commercial :-(
  • Intel C++ for Linux (i386) => Free for personal use and evaluation. It also works nicely on AMD systems but on 64-bit platforms it only generates i386 code!

Other tools and Devellopment software


The obligatory "Hello world(s)"

 
/* a pure C sample */
#include <stdio.h>
main()
{
    printf ("Hello World!\n")
    return 0;
}

  
// a C++ sample
#include <iostream>
using namespace std;
int main(int argc, char *argv[], char *envp[])
{
    cout << "Hello world \n";
    return 0;
}


  
// Another C++ sample
#include <iostream>
int main()
{
    std::cout << "Hello world" << endl;
    return 0;
}

admin · attr · attach · edit · history · print
Page last modified on March 30, 2006, at 01:55 PM