GDB Pretty Print on El Capitan

Has anyone successfully gotten gdb pretty printing to work on El Capitan? I've tried both g++-mp-4.9 and g++-mp-5. I've also tried the bundled gdb and gdb 7.9  from MacPorts. 

My ~/.gdbinit looks like:

python
import sys
sys.path.insert(0, '/opt/local/share/gcc-4.9/gcc-4.9.3/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

 

2 comments
Comment actions Permalink

OS X requires some additional compiler settings, please check the instructions. Do they help?

0
Comment actions Permalink

Thanks for the suggestion.

I believe these instructions are for using gdb with a clang compiled binary. I'm using gcc 5 (which uses libstdc++ by default), because I need some c++14/17 features.

I found the problem, but haven't figured out a complete solution yet. When I run ptype on a std::vector variable I get "type = class vector< ..." when I should be getting "type = class std::vector< ...". 

I found a partial fix at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59075, which involves editing the printers.py script that ships with gcc. This fixes most containers but raises a python exception when trying to print std::string. Since std::string is a very commonly used type, this fix makes things worse by preventing me from inspecting strings at all.

0

Please sign in to leave a comment.