GCC 7.2: Getting "warning: RTTI symbol not found for class" warnings in GDB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.  I'm working on upgrading my version of GCC from 6.2/binutils
2.27, to GCC 7.2/binutils 2.29.  I've built GCC and binutils myself
locally.  I'm compiling my code with -ggdb3 -O2 if it matters.

Everything seems to except: when I try to use some GDB python macros
I've created to print details of one of my local classes I'm getting
warnings and cannot obtain the appropriate information:

  warning: RTTI symbol not found for class 'TreeVector<Pod, 2u>::Tree'

This same operation works fine when my code is compiled with GCC 6.2. 
Note I've tried this with GDB 7.11 and GDB 8.0 and see the same behavior
for both: the only thing changing here is the version of GCC/binutils.

I've filed a bug about this FYI:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81932

After a lot of debugging the problem appears to be related to the
numeric type in the template definition: specifically whether it's
signed or unsigned.

My template is complex but it's basically:

  template<typename T, unsigned int LEAF_SIZE_POW = 6>
  class TreeVector
  {
    ...
      class Tree
      {
    ...
      private:
          uint const _depth;
      };
    ...
      Tree* tree;
      uint64 _maxIndex;
    ...
  };

When I compile with GCC 6.2, I'm able to see the type of my object via
GDB Python macros:

  (gdb) ptype tv
  type = class TreeVector<Pod, 2u> [with T = Pod] {
    private:
      TreeVector<T, 2u>::Tree *tree;
      volatile uint64 _maxIndex;
    ...

  (gdb) ptype tv.tree
  type = class TreeVector<Pod, 2u>::Tree {
    private:
      const uint _depth;
    ...

  (gdb) python
  >class tv(gdb.Function):
  >    def __init__(self):
  >        gdb.Function.__init__(self, "tv")
  >    def invoke(self, vector):
  >        gdb.write("vector: %s\n" % (str(vector.type)))
  >        gdb.write("tree: %s\n" % (str(vector['tree'].type)))
  >        gdb.write("depth: %d\n" % (vector['tree']['_depth']))
  >        tt = gdb.lookup_type("TreeVector<Pod, 2u>::Tree")
  >        return 0
  >tv()
  >^D

  (gdb) p $tv(tv)
  vector: TreeVector<Pod, 2u>
  tree: TreeVector<Pod, 2u>::Tree *
  depth: 3
  $1 = 0

Note here how the value for the template is "2u" and everything works.

Now I compile this same code with GCC 7.2/binutils 2.29 and use the same
GDB, and my results are different:

  (gdb) ptype tv
  type = class TreeVector<Pod, 2> [with T = Pod] {
    private:
      TreeVector<T, 2>::Tree *tree;
      volatile uint64 _maxIndex;
    ...

  (gdb) ptype tv.tree
  type = class TreeVector<Pod, 2>::Tree {
    private:
      const uint _depth;
    ...

  (gdb) p $tv(tv)
  vector: TreeVector<Pod, 2>
  tree: TreeVector<Pod, 2>::Tree *
  warning: RTTI symbol not found for class 'TreeVector<Pod, 2u>::Tree'
  depth: 3
  Python Exception <class 'gdb.error'> No type named TreeVector<Pod, 2u>::Tree.: 
  Error occurred in Python convenience function: No type named TreeVector<Pod, 2u>::Tree.

Note how now, the value in the template is just "2", not "2u".  But,
when GDB shows the RTTI warning it's still looking for the "2u" in the
type.  However that type definitely doesn't exist (we get an error
trying to look it up).

If I change my template to use "int" instead of "unsigned int", then
everything works in both versions of GCC:

  (gdb) p $tv(tv)
  vector: TreeVector<Pod, 2>
  tree: TreeVector<Pod, 2>::Tree *
  depth: 3
  $1 = 0



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux