GDB support: Couldn't find method

Simon Marchi simon.marchi@polymtl.ca
Mon Aug 20 15:03:00 GMT 2018


On 2018-08-08 07:14, Viesturs Veckalns wrote:
> Hello Simon,
> It turns out gdb does not know anything about class methods and nested
> classes loaded from the shared library:
> 
> (gdb) ptype GetLevel(resultcode)
> type = struct CompoundHistoUnfolding::Level {
>     <incomplete type>
> } *
> (gdb) ptype CompoundHistoUnfolding::Level
> There is no field named Level
> 
> gdb can list members of class CompoundHistoUnfolding but does not know
> about classes interfaced with the #include directive:
> 
> (gdb) ptype CompoundHistoUnfolding
> type = class CompoundHistoUnfolding : public TNamed {
>   private:
> Python Exception <class 'gdb.error'> No type named TString.:
>     std::map<TString, HistoUnfolding*, std::less<TString>,
> std::allocator<std::pair<TString const, HistoUnfolding*> > >
> aggrbackgroundMC;
> Python Exception <class 'gdb.error'> No type named HistoUnfolding*.:
>     std::vector<HistoUnfolding*, std::allocator<HistoUnfolding*> >
> _vbackgroundhistos;
> Python Exception <class 'gdb.error'> No type named SampleDescriptor*.:
>     std::vector<SampleDescriptor*, std::allocator<SampleDescriptor*> >
> _expsyssamples;
>     std::vector<SampleDescriptor*, std::allocator<SampleDescriptor*> >
> _markedsyssamples;
>     HistoUnfoldingTH2 *totalbackground;
>     char _signal_title[64];
> ...
> 
> How to proceed from this point?
> Viesturs

I tried this simple code, and everything works as expected:

---

class Outer
{
   class Inner
   {
     int foo = 2;

   public:
     int getFoo() {
       return foo;
     }
   };

public:
   Inner getBar()
   {
     return Inner();
   }
};

int main()
{
   Outer o;
   return o.getBar().getFoo();
}

---

(gdb) p o.getBar().getFoo()
$2 = 2
(gdb) ptype Outer::Inner
type = class Outer::Inner {
   private:
     int foo;

   public:
     int getFoo(void);
}


To continue investigating, I would need a minimal reproducer, because at 
this point I can only do some very wild guessing.

Simon



More information about the Gdb mailing list