GDB is a nice tool but in the way I have been using it so far, it turns pretty useless as soon as one is working with more complex data structures because simply using print
on them just fills then entire screen with unreadable details about that class.
However I usually have a custom operator<<
defined for my classes for the purpose of creating a (more or less) readable String representation of my class.
Therefore I would much prefer if GDB would always use that (if available) instead of its default print behavior.
I have found this question from 2010 which describes how one can call operator<<
manually. Besides being a bit tedious to do, I have failed to get these to work for me (I always get No symbol "operator<<" in current context.
).
However it appears to me as if there must be a more convenient way of getting GDB to print variables in a readable format. After all I can't be the first one who comes across this situation.
Therefore my question is: How do you get GDB to print variables in a readable format (preferably using operator<<
as implemented in the respective type)?
The linked question I found is from 2010 and so I am hoping that since then the situation has improved.