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

Kevin Funk <[email protected]>
Newsgroups gmane.comp.kde.users.kdevelop
Message-ID <11027044.ImNLMqR1Vo@kerberos>
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 | [email protected] | http://kfunk.org
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQQ2TvpfY5VykH05KZnGTPVrE8rOXQUCW/WJxAAKCRDGTPVrE8rO
XZHeAJ0YrB9HHrebpkRRiaMok8UTUu8WJwCfdvroCsqm8b4Un8eZ7kM6Jh6AQik=
=uKzP
-----END PGP SIGNATURE-----
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.