Node:C++ classes in GDB,
Next:Included source,
Previous:GDB and C++ source,
Up:Debugging
Q: It seems that GDB doesn't recognize C++ class members by their
original, unmangled names. Do I really need to figure out the mangled
names of all my class variables and methods to be able to debug them?
A: No, you don't. GDB does allow you to use the original
names, it's just that it usually treats the ::
in their names as
word delimiters. Include the name of the method or a class static
variable in single quotes, and GDB will recognize them as a single word.
For example, if your class CMPForward
has a method named
go
which you need to put a breakpoint in, use the following
command:
breakpoint 'CMPForward::go'
Other GDB
features that might be useful in this context are the
various demangling options, like set print demangle
, set
demangle-style
etc.; look them up in the GDB on-line docs.
However, there are some cases where you won't be able to get GDB to
demangle C++ function names no matter how hard you try. This is due
to a lack of sufficient debugging information in the COFF debug data
format. There's simply not enough info there for GDB to detect the
source language and support some C++-specific features. So, in some
case, you will need to use mangled names. If you need a
description of the GNU style of mangling C++ names (so you could
mangle them yourself), look in the GDB or Libg++ source distribution, in
the libiberty directory, for a file named cplus-demangle.c
. You
can also use the cxxfilt
utility, supplied as part of the GNU
Binutils package, to demangle the names and verify that your mangling is
correct. Note that, as the debugger built into RHIDE uses GDB
code, it will also sometimes have such problems with debugging C++
programs.
If you really need full C++ support in DJGPP, you will have to use
the stabs debugging support. GCC 2.8.0 and later are distributed with
built-in stabs support, so, if you need this, upgrade and compile your
C++ programs with -gstabs+
. Caveat emptor: FSDB
,
EDEBUG32
and SYMIFY
don't understand the stabs format,
so you will have to compile with -gcoff
option to use these
utilities (RHIDE distribution includes a utility called
gsymify
that can be used instead of SYMIFY
with stabs
debugging info).