== GDB and WebKit == GDB 7 introduced Python scripting of GDB. `Tools/gdb/webkit.py` extends GDB with WebKit-specific knowledge. See the top of the file for info on how to add this to your GDB. === Pretty Printing === With the script in place, we can pretty-print WTF string classes. So, for example, I can now break in GDB and see: {{{ (gdb) p run $1 = (const WebCore::TextRun &) @0x7fffffffa450: {m_characters = "Plugin Testsa", m_len = 12, m_xpos = 0, m_padding = 0, m_allowTabs = false, m_rtl = false, m_directionalOverride = false, m_applyRunRounding = true, m_applyWordRounding = true, m_disableSpacing = false} }}} Where `m_characters` is a `UChar*`. (Note that because it's a raw pointer, we have to guess at the length of the string -- the `m_len` parameter there is the length this code probably ends up using. When pretty-printing a string object we get the length correct.) To undo this pretty-printing, pass the `/r` switch to `p`, like so: {{{ (gdb) p/r run.m_characters $2 = (const UChar *) 0x3355130 (gdb) x/12hc run.m_characters 0x3355130: 80 'P' 108 'l' 117 'u' 103 'g' 105 'i' 110 'n' 32 ' ' 84 'T' 0x3355140: 101 'e' 115 's' 116 't' 115 's' }}} === Helper Functions === That script also adds a GDB command useful for printing WebKit Node trees. `printpathtoroot variable_name` will print the tree of nodes above a `WebCore::Node.` === Troubleshooting: GDB crashes on Linux === Ubuntu Karmic has a bug which causes gdb to crash on Linux when WebKit is compiled in `debug` mode. You can solve the crash by increasing stack size: {{{ ulimit -s 65535 }}}