Values of std::vector not showing up in debug window

Kevin Funk kfunk at kde.org
Wed Nov 21 16:37:24 GMT 2018


On Wednesday, 7 November 2018 17:09:01 CET zb4ng wrote:
> Hi,
> 
> I am sitting on a small C++ project using the standard library
> "vector"-container and can't see the entries in a "std::vector<long>" in
> the "Variables" window while debugging.
> Even after I had installed the "DEBUG-INFO" packages (see below), they
> were missing.
> I don't know, if I've done sth wrong or if this is a known issue.
> As an alternative, it would be possible to use the "print" command in
> GDB, but it's a little too cumbersome.
> 
> 
> Distro: openSuSE Leap 15.0
> KDE: KDE Frameworks 5.45.0,
> Qt 5.9.4 (built against 5.9.4)
> KDevelop: 5.1.2
> 
> "DEBUG-INFO" packages:
> gcc7-debugsource
> libstdc++6-debuginfo
> libstdc++6-32bit-debuginfo

Heya,

what you will definitely need are the STL GDB pretty printers (a file called 
libstdcxx/v6/printers.py)

On Ubuntu they are in this package:
  libstdc++6:amd64: /usr/share/gcc-8/python/libstdcxx/v6/printers.py


# Solution A

You'll also need to load them in KDevelop, for this, edit the gdbinit file 
installed by KDevelop (for your probably somewhere in /usr/.../kdevgdb/
printers/gdbinit) and add this between "python & "end":

```
sys.path.insert(0, '/usr/share/gcc-8/python/')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
```


# Solution B

Since some version GDB also supports auto-loading them (this is what happens 
here on my Ubuntu system), cf.:
  https://stackoverflow.com/a/42896336

This file here causes gdb to auto-load the pretty printers:
  libstdc++6:amd64: /usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc+
+.so.6.0.25-gdb.py

To check whether pretty-printing STL types works at all, probably try to debug 
a simple test program creating a std::vector<> and debug it with command-line 
GDB and print the vector.


Hope that helps.

Regards,
Kevin


> I checked the release notes of later versions, but didn't find sth there
> either.
> 
> Thanks,
> zb4bg


-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20181121/ae2abac0/attachment.sig>


More information about the KDevelop mailing list