This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB 7.11/8.0: <incomplete type> for templated type


Hi all.  We've been seeing this error in one or two of our types for a
very long time.  Note I'm using GCC 6.2 (built myself from source) and
GDB 7.11, but I just tried with GDB 8 and got the same results.  I
compile with "-ggdb3 -O2".  I'm on GNU/Linux building for 64bit.

When I try to print variables of this type I get an error:

(gdb) p groups
$1 = {
    <boost::noncopyable_::noncopyable> = {<No data fields>},
    members of TreeVector<GroupElement, 6u>:
    tree = 0x7f0196033f00,
    _maxIndex = 11
  },

(gdb) ptype groups.tree
type = class TreeVector<GroupElement, 6u>::Tree {
    <incomplete type>
} *

Because of this <incomplete type>, my Python code to print the members
of this tree vector are not printed, I get an error:

  Python Exception <class 'gdb.error'> There is no member named _depth.

Sometimes, variables of this type (e.g., TreeVector<Other> foo) are
printable.  But this particular type (TreeVector<GroupElement, 6>)
never seems to be printable.

After looking at some stackoverflow answers I've discovered that if I
disassemble a method that works with this type, often (but maybe not
always?) that will fix the problem and magically it starts to work. 
Then the type of the tree variable will be recognized and no longer
incomplete.

It seems like this sort of problem has been happening on and off for
many years based on my perusal of SO, the archives for this list, etc.,
and I wanted to know if there's a bug filed for it already, or if one
should be filed.


The type in question is a templated class:

  template<typename T, uint LEAF_SIZE_POW = 6>
  class TreeVector : public boost::noncopyable
  {
     ...
  private:
    class Tree
    {
       ...
    private:
        uint32_t const _depth;
    };

    template<typename E>
    class TreePart : public Tree
    {
      ...
    private:
        E elements[ELEMENT_ARRAY_SIZE];
    };
    typedef TreePart<T> Leaf;

    ...

    Tree* tree;
    volatile uint64 _maxIndex;
 };

The Python printer tries to use var['tree']['_depth'] and throws the
above error, when things are not working.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]