You are not logged in.

#1 2014-03-03 22:07:01

danielfleischman
Member
Registered: 2014-03-03
Posts: 3

gdb pretty printing (STL containers)

Hi all,

first of all, sorry if I am posting to the wrong category. My problem is: I used to be able to debug my C++ programs using gdb pretty printing. If I had a program like:

#include <vector>

int main() {
    std::vector<int> V;
    V.push_back(2);
    V.push_back(3);
    return 0;
}

And used gdb, at the "return 0;" line if I do "p V" I would receive something like (I don't remember the exact format):

$1 = {2,3}: size = 2, capacity = 5

I haven't used it for a while, and today I tried again and got:

$1 = {<std::_Vector_base<int, std::allocator<int> >> = {
    _M_impl = {<std::allocator<int>> = {<__gnu_cxx::new_allocator<int>> = {<No data fields>}, <No data fields>},
      _M_start = 0x603030, _M_finish = 0x603038, _M_end_of_storage = 0x603038}}, <No data fields>}


Which is the internal representation of the vector. While I do know how to read this, and how to obtain the actual values, I would like to know how to revert to the pretty-printing state.

I am using gcc version 4.8.2 and gdb version 7.7 on a x86_64 installation.

Thanks in advance for your help!

Offline

#2 2014-03-13 19:23:41

m0rph
Member
Registered: 2007-07-28
Posts: 26

Re: gdb pretty printing (STL containers)

Try to downgrade GDB.

Offline

#3 2014-03-13 19:56:25

danielfleischman
Member
Registered: 2014-03-03
Posts: 3

Re: gdb pretty printing (STL containers)

I fixed this problem by installing gdb-c++-pretty-svn from AUR.

As I think this shouldn't be on AUR, but in the main repository (it is pretty stable), of course I can test for you, which version do you want me to downgrade to?

Offline

#4 2014-03-14 08:43:46

m0rph
Member
Registered: 2007-07-28
Posts: 26

Re: gdb pretty printing (STL containers)

If reinstalling of gdb-c++-pretty-svn solves your issue, then there is no need to downgrade GDB.

Offline

#5 2014-03-14 13:35:31

danielfleischman
Member
Registered: 2014-03-03
Posts: 3

Re: gdb pretty printing (STL containers)

m0rph, it's not "reinstalling gdb-c++-pretty-svn". I didn't have it installed in the first place!

The pretty printers are part of the gdb package, so technically you shouldn't need to install gdb-c++-pretty-svn from AUR. Just having gdb used to be enough, and suddenly it is not anymore. This solution worked for me, but I don't think it is the desired solution.

For completeness:

daniel@dfleischman ~ $ pacman -Ql gdb | grep pretty
gdb /usr/share/gdb/python/command/pretty_printers.py

Offline

Board footer

Powered by FluxBB