Re: How to load C++ pretty-printers

Philippe Waroquiers <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On Sun, 2019-03-17 at 07:03 -0400, Joel Brobecker wrote:
> Hello Asmwarrior,
> 
> On Sun, Mar 17, 2019 at 09:47:35AM +0800, asmwarrior wrote:
> > On Sun Mar 17 2019 00:00:29 GMT+0800, Eli Zaretskii wrote:
> > > So, for the record, I now have this in my ~/.gdbinit
> > > 
> > >   python import sys
> > >   python sys.path.insert(0, 'd:/usr/share/gcc-7.3.0/python')
> > >   source d:/usr/lib/gcc/mingw32/7.3.0/libstdc++.dll.a-gdb.py
> > > 
> > > (The last line both imports the function register_libstdcxx_printers,
> > > and calls that function.)
> > 
> > Thanks Eli and Simon.
> > 
> > I think I have followed this wiki page: https://sourceware.org/gdb/wiki/STLSupport
> > And I just the svn command to check-out the latest Python libstdc++
> > printers in GCC trunk.  So, that page should be updated, at least we
> > can teach people how to use the python printer bundled with their GCC
> > release.
> 
> It is a fair comment. Would you volunteer to help us update it?
Note that even with pretty printers working, c++ debugging stays a mystery
for me (probably highly linked to my poor knowledge of C++):

E.g.  p current_program_space->added_solibs
 pretty printing works and gives:
      $11 = std::vector of length 13, capacity 16 = {0x56275a765a60,  ...

But then:
    p current_program_space->added_solibs[0]
    One of the arguments you tried to pass to operator[] could not be converted to what
    the function wants.
(why is then GDB not telling me what the function wants ?).
I am finally doing
   p (*(struct so_list*)0x56275a765a60)

But that all looks like a 'backward' user experience:
  I have to explain to GDB what to do, instead of GDB just working,
  or at least GDB explaining me more clearly what I am doing wrong.

Philippe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.