0

I am trying to Get gdb pretty-print working in eclipse, it seems to be working for all stl elements and containers baring std::string

basically if i have a vector like:

std::vector<std::string> m_vec = {"hello" , "world"};

each element of the vector shows a string and it shows the contents like "hello" and "world".

but if i have a code like

std::string m_string = "hello world";

m_string shows up empty, even though i can do string operations on the contents. Not sure why only strings alone is causing as issue with pretty print.

Any help/pointers would be much appreciated.

Edited:

Few more details regarding the setup:
    IDE: Eclipse Luna 4.4.2
    Compiler: Cygwin g++ 5.4.0
    Debugger: Cygwin gdb 7.10.1
    phython : Cygwin phython 3.6

Update: Don't know how exactly, but windows restart solved it, can see string now in preety-print.

  • gdb **pretty-print** was deprecated in later versions of gdb. Please check the support – Chandrayya G K Jul 13 '17 at 08:12
  • @ChandrayyaGK Where do you get the info that the gdb pretty print support is deprecated? – AmeyaVS Jul 13 '17 at 10:10
  • Have a look [here](https://stackoverflow.com/a/43937052/4690576). See if this helps. – AmeyaVS Jul 13 '17 at 10:12
  • @AmeyaVS In CDT source code. I use Ubuntu, am not aware of the package to be installed. I encountered a similar problem when I tried to do remote debugging an c application I am not getting the control back(Similar to going to infinite loop) when investigated I am using older gdb configuration for newer version of gdb. Sorry not getting exact link for the information source, once I have will update. Thanks – Chandrayya G K Jul 14 '17 at 03:32
  • @ChandrayyaGK Please have a look [here](https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing) GDB Pretty printing is quite available in GDB 8.x version releases. – AmeyaVS Jul 14 '17 at 04:34
  • Can you update the question about the environment you are using e.g.: compiler version and the system (Windows: MinGW/Cygwin or Linux or macOS) you are using? – AmeyaVS Jul 14 '17 at 05:50

1 Answers1

1

For adding support for gdb pretty-printing in cygwin you need the following file available: /usr/share/gdb/auto-load/usr/bin/cygstdc++-6.dll-gdb.py

It is available in gcc-debuginfo-5.4.0-1 package in cygwin package installer.

Note: This might break once packages get updated in Cygwin repository. So you will need to again locate this file in the Cygwin package search.

Update: Check the version of python interpreter supported by gdb by running the following commands in the gdb console:

(cygwin console) $ gdb
(gdb) python
>import sys
>print(sys.version)
>end

You should see output something like this(in my case it defaults to python2.7 interpreter):

2.7.13 (default, Mar 13 2017, 20:56:15)
[GCC 5.4.0]
AmeyaVS
  • 814
  • 10
  • 26
  • This solved a similar problem for me, pretty print not working for STL containers when debugging with Visual Studio Code and Cygwin. Python 3.8 works fine for me, though. – Joshua Jurgensmeier Oct 08 '20 at 15:14