4

I am using CDT for C++ development which uses gdb for debugging purposes. The debug variables view only shows the declared type of the variables - not the actual type based on vtable information. Since I am heavily relying on dynamic subclassing, the declared type often does not contain the information I need. I must also inpsect the values of the actual subclass. I have found this question: vtable in polymorphic class of C++ using gdb and it is said that gdb is able to print the actual type based on vtable information using the following command:

set print object on

But how to do this in Eclipse CDT?

Btw: Isn't this a quite common use case so that it should be enabled by default? As soon as someone uses inheritance and virtual stuff, it is extremely important to see the real object type during debugging. Showing only the declared type feels for me like coming from the stone age.

Community
  • 1
  • 1
gexicide
  • 38,535
  • 21
  • 92
  • 152

1 Answers1

2

This has supposed to work since CDT 8.1 which was the CDT version when Eclipse Juno was released. It requires GDB 7.5.1 or higher to work.

On Linux Distributions with up-to-date GDB

I've tried with the Juno Release and Luna M6 Release versions of CDT packaged Eclipse on Ubuntu 14.04 (comes with GDB-7.7 and it worked straight away out of the box.

On Linux Distributions with GDB versions older than 7.5.1

If your distribution does not provide GDB it is fortunately easy to build. You can download the source: from http://www.gnu.org/software/gdb/download/ and just need to follow the instructions in the README files. It took less than 20 min to build for me.

When that is done you can configure Eclipse to use your new GDB version by going to:

Window -> Preferecnes

from the menu bar.

Then navigating to the GDB entry as shown below and setting the "GDB debugger:" entry to the path the the new GDB executable.

enter image description here

PeterSW
  • 4,921
  • 1
  • 24
  • 35