Changes between Initial Version and Version 1 of Debugging With LLDB or GDB


Ignore:
Timestamp:
Mar 2, 2014 6:11:36 PM (10 years ago)
Author:
BJ Burg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Debugging With LLDB or GDB

    v1 v1  
     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
     10For 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
     20The 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{{{
     22alias wkd-drt='(echo r; cat) | DYLD_FRAMEWORK_PATH=WebKitBuild/Debug gdb --args WebKitBuild/Debug/DumpRenderTree'
     23}}}
     24
     25== WebKit-specific Scripts ==
     26
     27GDB 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
     31With 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
     40Where `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
     42To 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
     480x3355130:      80 'P'  108 'l' 117 'u' 103 'g' 105 'i' 110 'n' 32 ' '  84 'T'
     490x3355140:      101 'e' 115 's' 116 't' 115 's'
     50}}}
     51
     52=== Helper Functions ===
     53
     54That script also adds a GDB command useful for printing WebKit Node trees.
     55  `printpathtoroot variable_name`
     56will print the tree of nodes above a `WebCore::Node.`
     57
     58
     59=== Troubleshooting: GDB crashes on Linux ===
     60
     61Ubuntu 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{{{
     64ulimit -s 65535
     65}}}