In GDB, objects typically display with lots of tripe due to included template objects.
There’s a lot of useless std::char_traits …
Is there a way to filter this stuff out? Basically, I’d like to know if I can configure .gdbinit to display the text only for a std::string, and perhaps the first few elements for a vector.
Alternatively, is there some sort of macro I can write to let me print out just a particular field of an object instead of writing by hand
For a string, I can write:
p s.c_str()
but I’ll get a seg fault if it’s NULL.
I’d like enough logic to ignore that but don’t know that gdb has any facility for it?
Yes, there are such things about! It’s a bit limited but you can do it.
Look here and also here.