debugging python objects and fields with gdb

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:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s