1

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?

Dov
  • 8,000
  • 8
  • 46
  • 75

1 Answers1

1

Yes, there are such things about! It's a bit limited but you can do it.

Look here and also here.

Community
  • 1
  • 1
Component 10
  • 10,247
  • 7
  • 47
  • 64
  • What is limited? GDB supports python output routines from version 7.0. You can also write pretty printers for your own classes if you want, it's actually very simple. – Šimon Tóth Nov 26 '10 at 14:37