I am trying to make pretty printing to work on Ubuntu 18.04 from visual studio code 1.64.2.
I tried to follow instructions initially from
Additionally, I tried to check which pretty-printer is configured or set up by typing info pretty-printer
from within (gdb). But it appears that the appropriate pretty printer is not configured.
I tried reinstalling gcc 11.2 from the source by configuring with python using both python 2.7 and python 3.6.9 using the command ./configure --with-python
and ./configure --with-python3
. But nothing worked!
Can anyone please help me out?
CodePudding user response:
I found a solution as posted here. The gdb was not able to find the location where the python printers.py was located. The file was located under /usr/share/gcc/python/libstdcxx/v6/printers.py
.
What I needed to do is create a .gdbinit file on my home directory including the following lines of code
python
import sys
sys.path.insert(0, '/usr/share/gcc/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
Next source the file with source .gdbinit
and then try again the info pretty-print
. All the alternate options are now available. Subsequently, gdb debugging and vscode was able to show the contents of the C STL containers.