User forums > Help
Pretty Printers working only for global variables
Sab:
Windows 7-64 bit
C::B 13.12
gdb 7.7
g++ 4.9.2
For me if I use vector as a local variable, not able to see value of vectors during debugging but if I declare vector as global variable pretty printers are working. Same is happening for std::strings.
And when I tried std::queue, std::map pretty printers are not working. I have attached screenshots of configuration and debugging window.
How can I view other STL containers?
ollydbg:
I don't have such issue.
One suggestion: you need to uncheck the "Enable watch scripts" option.
Sab:
I uncheck the "Enable watch scripts" option and the pretty printers are not working then I noticed the
--- Code: ---Error while executing Python code.
--- End code ---
, googled and tried the following.
My stl.gdb
--- Code: ---python
import sys
sys.path.insert(0, '')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
--- End code ---
I am getting following error while executing while debugging in Code Block
--- Code: ---source C:\MinGW\bin\stl.gdb
Traceback (most recent call last):
File "<string>", line 3, in <module>
ImportError: No module named libstdcxx.v6.printers
C:\MinGW\bin\stl.gdb:5: Error in sourced command file:
Error while executing Python code.
--- End code ---
and following error from command prompt
--- Code: ---(gdb) source C:\MinGW\bin\stl.gdb
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "c:\mingw\share\gdb/python/../../gcc-4.9.2/python/libstdcxx/v6/printers.p
y", line 1023, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "c:\mingw\share\gdb/python/gdb/printing.py", line 146, in register_pretty
_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
C:\MinGW\bin\stl.gdb:6: Error in sourced command file:
Error while executing Python code.
(gdb)
--- End code ---
then I removed
--- Code: ---register_libstdcxx_printers (None)
--- End code ---
from my stl.gdb and I didn't get any error in command prompt but getting same error in code block
What should I do?
Edit:My gdb version 7.8.1
I tried to debug in command line:
--- Code: ---Breakpoint 1, main ()
at D:\Program\Practice Program\PrettyPrinterCheck\main.cpp:41
41 cout<<s;
(gdb) print p
$1 = {first = 13, second = 14}
(gdb) print m
$2 = std::map with 1 elements = {[2] = 1}
(gdb) print v
$3 = std::vector of length 1, capacity 1 = {10}
(gdb) print q
$4 = std::queue wrapping: std::deque with 2 elements = {10, 11}
(gdb) print s
$5 = "Hello"
--- End code ---
ollydbg:
--- Quote from: Sab on May 16, 2015, 05:05:03 pm ---
--- Code: ---(gdb) source C:\MinGW\bin\stl.gdb
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "c:\mingw\share\gdb/python/../../gcc-4.9.2/python/libstdcxx/v6/printers.p
y", line 1023, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "c:\mingw\share\gdb/python/gdb/printing.py", line 146, in register_pretty
_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
C:\MinGW\bin\stl.gdb:6: Error in sourced command file:
Error while executing Python code.
(gdb)
--- End code ---
then I removed
--- Code: ---register_libstdcxx_printers (None)
--- End code ---
from my stl.gdb and I didn't get any error in command prompt
--- End quote ---
Yes, you should remove that line, because the std pretty printer is registered when it is imported, see my answer here:
http://stackoverflow.com/a/28404772/154911
--- Quote ---but getting same error in code block
What should I do?
Edit:My gdb version 7.8.1
I tried to debug in command line:
--- Code: ---Breakpoint 1, main ()
at D:\Program\Practice Program\PrettyPrinterCheck\main.cpp:41
41 cout<<s;
(gdb) print p
$1 = {first = 13, second = 14}
(gdb) print m
$2 = std::map with 1 elements = {[2] = 1}
(gdb) print v
$3 = std::vector of length 1, capacity 1 = {10}
(gdb) print q
$4 = std::queue wrapping: std::deque with 2 elements = {10, 11}
(gdb) print s
$5 = "Hello"
--- End code ---
--- End quote ---
From the command line, I see it works OK, but you should get the same result in C::B, I have no idea, do you have two different version of GDBs in your system?
Sab:
I have only one GDB. I have attached my settings->compiler->toolchain config.
my current stl.gdb file
--- Code: ---python
import sys
sys.path.insert(0, 'C:\MinGW\share\gcc-4.9.2\python')
from libstdcxx.v6.printers import register_libstdcxx_printers
end
--- End code ---
after this I am not getting any error in C::B debugger prompt but still pretty printers are not working in C:B while in command prompt it is working.
Navigation
[0] Message Index
[#] Next page
Go to full version