libcwd: The C++ Debugging Support Library - Reference Manual
Author: Carlo Wood
Description: C++ debugging support library with ostream debug output
Keywords: libcwd, debug output, debug facility, debug channel, object orientation, OO, C++, nested debug output, ostream, memory allocation, debugging, source file and line number

Main Page Reference Manual Namespace List Compound List Namespace Members Compound Members File Members

# Memory Allocation Debugging And Locations
[Configuration, Installation And Getting Started]

Collaboration diagram for Memory Allocation Debugging And Locations:

## The BFD library

Libcwd attempts to determine the source file and line number where memory is allocated. It does this by directly reading the .debug_line (DWARF2) or .stabs (STABS) section of the ELF32 object files. If you are using an Operating System that isn't ELF32 then you need to enable the use of GNU libbfd for this to work by configuring libcwd with --enable-libbfd . If you don't have an ELF32 system and you don't have GNU libbfd installed and are not able to install it yourself (note: you also need libiberty and libdl) then you can disable it using --disable-location . There is a seperate page that deals with libcwd and location support. This paragraph describes the effect of disabling source file and line number location support in relation to the memory allocation debugging support.

## With location support

With --enable-location , libcwd will write the source file and line number information about where memory allocations are done to the debug channels dc::bfd .

For example,

    MALLOC  : operator new (size = 4) = <unfinished>
    BFD     :     0x804bc9b is at (deb.cc:179)
    MALLOC  : <continued> 0x8137220

which means that `operator new` was called at address 0x804bc9b corresponding to line 179 of source file `deb.cc`.

Source file and line number information is also shown in the overview of allocated memory and when a memory block is freed.

## Without location support

Without support the source file and line number information will not be available. Debug channel dc::bfd doesn't exist and the Allocated memory Overview will lack the source file location in column three. Finally, there will be no alloc_ct::location() method.