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

# Starting A gdb Session From A Running Program

A running program can initiate a gdb session by calling the function `attach_gdb()`.

For example,

      Debug(
        if (counter == 31523 && ptr == (void*)0x40013fa0)   // When to start debugging?
          attach_gdb();
      );

      ptr->foobar++;        // The debugging will start at this line.

The function `attach_gdb()` opens an xterm (or whatever is configured in the rcfile) and starts the gdb session inside it.

After exiting gdb the application will continue running.

In order for `attach_gdb()` to work, you will need to call `read_rcfile()` at the start of your application.