开发者

printing a GHashTable out in GDB

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

From what I understand, this Archer project functionality was pushed in to GDB mainstream.

In GDB I do:

set print pretty on

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

(gd开发者_StackOverflowb) print call_data->fields->field_indicies
$3 = (GHashTable *) 0x87f4580

If I try de-referencing the pointer in GDB, I get an incomplete type:

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

I am running 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 I can print this out? or why I do not have the proper glib and gdb support?


There are two things you need for Python pretty printers to work:

  1. A GDB which supports Python pretty printers and
  2. An actual Python code to pretty print your desired type

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

The second part requires you to install the pretty printer so GDB can find it. You are likely missing that part.

Eventually GDB will be able to automagically find pretty printers on its own, but that feature is newer (I think it's only in GDB 7.2) and requires GLIB maintainers to distribute their pretty printers with libglib2.0-0-dbg, which (I am guessing) they haven't done yet.

You can check: dpkg -L libglib2.0-0-dbg | grep '\.py$'. If this doesn't list any .py files, then pretty printers are absent. If does, they likely are present, but GDB is not finding them.

The pretty printer for GHashTable appears to have been added here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜