debugging python objects and fields with gdb

Sep 25, 2014

Sometimes your python code crashes or runs into a deadlock. For this the Python Extension for GDB 7 are very handy. On one mainstream Linux distribution this was automatically available when the devel/debug package for python was installed. But this extension has certain limitations, and one that I found quite important was the ability to print individual fields of objects. The "py-print" command truncates it's output so for a relatively complex object you can't really see the member attributes.

After looking at the source for this extension I saw it would be relatively easy to fix this. I wrote another command that actually goes through the object's dictionary and prints out the requested field only. Here's the gist: