Printing GHashTable in GDB

I am trying to print a GHashTable in GDB in a clean way. I found a blog in the Archer project that shows the ability to print GHashTable: http://blogs.gnome.org/alexl/2009/09/21/archer-gdb-macros-for-glib/

From what I understand, this functionality of the Archer project has been included in the main GDB stream.

In GDB, I do:

set print pretty on 

And then I try to print the hash table, but it still gives me the memory address:

 (gdb) print call_data->fields->field_indicies $3 = (GHashTable *) 0x87f4580 

If I try to remove the pointer link in GDB, I get an incomplete type:

 (gdb) print *call_data->fields->field_indicies $2 = <incomplete type> 

I run Ubuntu and I have libglib2.0-0-dbg installed:

 gnychis@qc2 :~/Documents/wireshark_native$ sudo apt-get install libglib2.0-0-dbg Reading package lists... Done Building dependency tree Reading state information... Done libglib2.0-0-dbg is already the newest version. 

Does anyone know how else can I print this? or why i don't have proper glib and gdb support?

+4
source share
1 answer

For good Python printers, you need two things:

  • Gdb that supports beautiful python printers and
  • The actual Python code to print the type you want.

The first part should be available for the latest Linux distributions (the Archer branch was merged into GDB 7.0, so if you have 7.0 or newer GDB, you should be fine).

The second part requires that you install a beautiful printer so that GDB can find it. You are probably missing this part.

Ultimately, GDB will be able to automatically find beautiful printers on its own, but this feature is newer (I think this is only in GDB 7.2) and requires that GLIB developers distribute their pretty printers with libglib2.0-0-dbg , which (I assume) they have not done yet.

You can check: dpkg -L libglib2.0-0-dbg | grep '\.py$' dpkg -L libglib2.0-0-dbg | grep '\.py$' . If no .py files are listed on this list, then pretty printers are missing. If so, they are probably present, but GDB does not find them.

A nice printer for GHashTable seems to have been added here .

+4
source

All Articles