0

Does something like Data::Dumper exists in gdb? How can I pretty print complex C structures e.g. what if I have array of arrays which elements are some structures? I've read about scripting gdb with python but don't know if it can do this?

Wakan Tanka
  • 7,542
  • 16
  • 69
  • 122

1 Answers1

0

It's not totally clear what exactly you want to do.

If you want to hook custom printing code into the gdb print functions -- not just print but also stack traces and communication with GUI front ends -- then read about gdb pretty-printers, which, despite their name, are really more like value transformers.

If you want to completely control printing yourself, then use the gdb.Value API to fetch values and dissect them, generally using gdb.Type information to understand what you're looking at.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
  • I was thinking about some nice output that will recognize that structure is tree or 2D array or something more complicated and automatically indent nested members etc. I have found those python features in gdb but still do not know where to begin for scripting gdb with python. Some simple "hello world" like example will be nice, don't you know about anything like that? – Wakan Tanka Mar 26 '15 at 17:19