delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq100.html   search  

| Previous | Next | Up | Top |

12.7 Can GDB print class members?

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:
       b '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 files with SDB debug data. There's simply not enough info there for GDB to detect the source language and use C++-specific support. If you need a description of the GNU style of mangling C++ names (so you could demangle them yourself), look in the GDB or Libg++ source distribution, in the libiberty directory, for a file named cplus-demangle.c. 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 upgrade if you need this. Caveat emptor: FSDB, EDEBUG32 and SYMIFY don't understand stabs, 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).

Note that, as the debugger built into RHIDE uses GDB code, it will also sometimes have such problems with debugging C++ programs.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright ⌐ 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)