| 1 | = Debugging WebKit2 = |
| 2 | |
| 3 | = Debugging DumpRenderTree = |
| 4 | |
| 5 | 1. `build-webkit --debug` |
| 6 | 1. `build-dumprendertree --debug` |
| 7 | 1. `export DYLD_FRAMEWORK_PATH=/path/to/WebKit/WebKitBuild/Debug` |
| 8 | 1. `gdb --args WebKitBuild/Debug/DumpRenderTree /path/to/testfile.html` |
| 9 | |
| 10 | For LLDB, instead invoke using: |
| 11 | |
| 12 | `lldb -f WebKitBuild/Debug/DumpRenderTree -- /path/to/testfile.html` |
| 13 | |
| 14 | = Debugging WebKitTestRunner = |
| 15 | |
| 16 | = Miscellaneous Tips = |
| 17 | |
| 18 | == Shell Aliases == |
| 19 | |
| 20 | The following will automate launching and running DRT under GDB with a specific test argument. You can use it like so: `wkd-drt path/to/test` |
| 21 | {{{ |
| 22 | alias wkd-drt='(echo r; cat) | DYLD_FRAMEWORK_PATH=WebKitBuild/Debug gdb --args WebKitBuild/Debug/DumpRenderTree' |
| 23 | }}} |
| 24 | |
| 25 | == WebKit-specific Scripts == |
| 26 | |
| 27 | 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. The LLDB equivalent is located at `Tools/lldb/lldb_webkit.py`. |
| 28 | |
| 29 | == Pretty Printing == |
| 30 | |
| 31 | With the script in place, we can pretty-print WTF string classes. So, for example, I can now break in GDB and see: |
| 32 | |
| 33 | {{{ |
| 34 | (gdb) p run |
| 35 | $1 = (const WebCore::TextRun &) @0x7fffffffa450: {m_characters = "Plugin Testsa", m_len = 12, m_xpos = 0, |
| 36 | m_padding = 0, m_allowTabs = false, m_rtl = false, m_directionalOverride = false, |
| 37 | m_applyRunRounding = true, m_applyWordRounding = true, m_disableSpacing = false} |
| 38 | }}} |
| 39 | |
| 40 | 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.) |
| 41 | |
| 42 | To undo this pretty-printing, pass the `/r` switch to `p`, like so: |
| 43 | |
| 44 | {{{ |
| 45 | (gdb) p/r run.m_characters |
| 46 | $2 = (const UChar *) 0x3355130 |
| 47 | (gdb) x/12hc run.m_characters |
| 48 | 0x3355130: 80 'P' 108 'l' 117 'u' 103 'g' 105 'i' 110 'n' 32 ' ' 84 'T' |
| 49 | 0x3355140: 101 'e' 115 's' 116 't' 115 's' |
| 50 | }}} |
| 51 | |
| 52 | === Helper Functions === |
| 53 | |
| 54 | That script also adds a GDB command useful for printing WebKit Node trees. |
| 55 | `printpathtoroot variable_name` |
| 56 | will print the tree of nodes above a `WebCore::Node.` |
| 57 | |
| 58 | |
| 59 | === Troubleshooting: GDB crashes on Linux === |
| 60 | |
| 61 | 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: |
| 62 | |
| 63 | {{{ |
| 64 | ulimit -s 65535 |
| 65 | }}} |