-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GDB pretty-printers for some types. #147
Conversation
Codecov Report
@@ Coverage Diff @@
## master #147 +/- ##
=======================================
Coverage 97.92% 97.92%
=======================================
Files 132 132
Lines 10750 10750
=======================================
Hits 10527 10527
Misses 223 223 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thank you! I looked over the code and everything seems fine, even the coding style is exactly as I'd do it myself, haha. I don't really use gdb myself so I can't prove it actually works, but I think I can trust you after all these years :) Two questions before I merge:
That's fine. It can be always added later if someone figures out how.
This is fine as well, I don't see this type being too important. Besides that, the type usually just takes a value/variable that's stored somewhere else already, so the user can print the other one instead.
Ah, sigh. So I suppose the Magnum math types all need the same workaround as well. |
Oh, boy... :D To be honest, once again, there's no easy way of loading pretty-printers. It's possible to do this:
The scripts themselves tend to be a bit convoluted and a bit "WTF". Here's what GDB on MinGW-w64/MSYS2 does when loading the libstc++ pretty-printers (
Loading the Corrade pretty-printers might look like this (skipping the import sys
sys.path.insert(0, '/path/to/share/') # not pointing to the debuggers subfolder here because it could conflict with the built-in gdb module
from corrade.debuggers.gdb import register_corrade_printers
register_corrade_printers(gdb.current_objfile()) Initialisation scripts for an "objfile" (aka a binary or dynamic library) can be directly a Python script, as per GDB's docs, in which case the It's also possible to register printers to a "progspace" (aka the entire inferior, including loaded libraries) using That's all I could think of at the moment. If I missed anything that could be of use, don't hesitate to mention it.
MinGW being pretty much GCC, I don't think this should be an issue. In the case of Clang, it depends on whether GDB or LLDB is used to debug, and LLDB uses its own API according to the official docs, meaning the GDB scripts are useless in this case. IIRC, clang-cl generates PDB debug info, meaning only VS (and LLDB, thanks to MS being more open about the format) can be used. GDB can't work with PDB files yet, but it's possible the option might come in the future, like with LLDB above. |
Awesome, that's quite an exhaustive info. Will merge tomorrow or later this week, thank you! |
Merged as 43d8fa0, finally. Sorry for the extreme delay and thanks! |
As mentioned on Gitter, here's the PR adding adding GDB pretty-printers
Most types in
Containers
, as well as mostUtility::Configuration*
types (except values, since the default printing for them is adequate), are supported.For multi-dimensional
StridedArrayView
, since I couldn't manage to get nested printing working, flattened printing is used instead.The only
Containers
type to not be supported isScopeGuard
, because type erasure makes it hard to pretty-print its contents.Note: because the
gdb.Type.template_argument()
method chokes on non-type arguments (such as the size used byStaticArray(View)
, orStridedArrayView
's dimensions) despite this bug supposedly being fixed in GDB 7.2, I had to rely on string manipulation to extract those arguments.