gdb hint for debugging libxml

From a letter to the libxml mailing list. Probably it's well known, but I'd like to share useful gdb settings. From my ~/.gdbinit:

<code>
define xp
call xmlDebugDumpNode(stdout, $arg0, 0)
end
document xp
Executes xmlDebugDumpNode(stdout, arg, 0).
Use also:
xmlDebugDumpOneNode
xmlDebugDumpNodeList
xmlDebugDumpDocument
end
</code>

Now, debugging in gdb, it's possible to dump a variable as an XML node:

<screen>
(gdb) cont
Breakpoint 2, xmlFreeNode (cur=0x8051760) at tree.c:3333
3333        xmlDictPtr dict = NULL;
(gdb) help xp
Executes xmlDebugDumpNode(stdout, arg, 0).
Use also:
xmlDebugDumpOneNode
xmlDebugDumpNodeList
xmlDebugDumpDocument
(gdb) xp cur
TEXT
  content= 
test.xsl:0: error : Node has no parent
</screen>
Categories:

Updated: