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:

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)


Comment actions Permalink

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

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, which involves editing the 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.


Please sign in to leave a comment.