Changes between Version 14 and Version 15 of WebKitGTK/Debugging


Ignore:
Timestamp:
Jan 27, 2017, 10:04:12 AM (8 years ago)
Author:
clopez@igalia.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WebKitGTK/Debugging

    v14 v15  
    1717}}}
    1818
    19 In other to run ''GtkLauncher'' under ''gdb'' you should use a ''jhbuild'' shell and run ''gdb'' normally or use the ''jhbuild-wrapper'' as follows:
     19If you want to debug the web process, the simplest way is to connect to it using gdb:
    2020{{{
    21 #!sh
    22 $ Tools/jhbuild/jhbuild-wrapper --gtk run gdb --args WebKitBuild/Debug/Programs/GtkLauncher
     21$ gdb -p <pid of WebKitWebProcess>
    2322}}}
     23However that doesn't work in all cases, because the web process might already have crashed when you are trying to connect to it.
     24
     25You can use the '''WEB_PROCESS_CMD_PREFIX''' environment variable (only works on Debug builds) for that purpose. If that variable is defined the web process will be run using its value as a prefix.
     26
     27Example:
     28{{{
     29WEB_PROCESS_CMD_PREFIX='/usr/bin/gdbserver localhost:8080' WebKitBuild/Debug/bin/MiniBrowser
     30}}}
     31and in a different terminal:
     32{{{
     33$ cd WebKitBuild/Debug
     34$ gdb -q bin/WebKitWebProcess
     35Reading symbols from bin/WebKitWebProcess...done.
     36(gdb) target remote localhost:8080
     37(gdb) continue
     38}}}
     39
     40If you want to debug the network process you can use '''NETWORK_PROCESS_CMD_PREFIX''' in a similar way.
     41
     42Note that these variables are only enabled in debug builds. If you still want to use them in release builds you can remove the relevant
     43'''#ifndef NDEBUG''' in '''ProcessLauncherGtk.cpp''',
     44'''ProcessLauncher.h''', '''WebProcessProxyGtk.cpp''' and
     45'''NetworkProcessProxySoup.cpp'''
     46
     47
     48= Getting a backtrace =
     49
     50This works both with release and debug builds. If you are trying to get a backtrace from the WebKitGTK+ packages shipped by your distribution, '''ensure you have the corresponding dbgsym packages installed'''.
     51
     52* Open a terminal/shell, and enable coredumps
     53{{{
     54ulimit -c unlimited
     55}}}
     56* From that shell, run the browser and make it crash.
     57* After it has crashed a file named "core" should have appeared on your working directory.
     58  * If it wasn't the case ensure that you have not set the sysctl kernel.core_pattern set to another directory/pipe
     59{{{
     60$ sudo sysctl kernel.core_pattern=core
     61}}}
     62* Once you have the core, get a backtrace from it as follows:
     63{{{
     64gdb --batch -ex "thread apply all bt full" /full/path/to/WebKitWebProcess core &> backtrace.txt
     65}}}
     66  * If you get a [https://bugs.webkit.org/show_bug.cgi?id=159919 crash on the GDB demangler], you can workaround it as follows:
     67    * Edit (or create) the file ${HOME}/.gdbinit
     68    * Write this line on it
     69{{{
     70set demangle-style none
     71}}}
     72    * And repeat the operation. You should not have got a backtrace with the files mangled.
     73      * You can now manually demangle those symbols by piping the output as follows
     74{{{
     75cat backtrace.txt | c++filt
     76}}}
     77
     78
     79
     80
     81
    2482
    2583== Logging support ==
     
    86144}}}
    87145
    88 == Debugging WebKit2 ==
    89 
    90 If you want to debug the web process, the simplest way is to connect to
    91 it using gdb:
    92 {{{
    93 $ gdb -p <pid of WebKitWebProcess>
    94 }}}
    95 However that doesn't work in all cases, because the web process might
    96 already have crashed when you are trying to connect to it.
    97 
    98 You can use the '''WEB_PROCESS_CMD_PREFIX''' environment variable for
    99 that purpose. If that variable is defined the web process will be run
    100 using its value as a prefix.
    101 
    102 Example:
    103 {{{
    104 WEB_PROCESS_CMD_PREFIX='/usr/bin/gdbserver localhost:8080' WebKitBuild/Debug/bin/MiniBrowser
    105 }}}
    106 and in a different terminal:
    107 {{{
    108 $ cd WebKitBuild/Debug
    109 $ gdb -q bin/WebKitWebProcess
    110 Reading symbols from bin/WebKitWebProcess...done.
    111 (gdb) target remote localhost:8080
    112 (gdb) continue
    113 }}}
    114 
    115 If you want to debug the network process you can use
    116 '''NETWORK_PROCESS_CMD_PREFIX''' in a similar way.
    117 
    118 Note that these variables are only enabled in debug builds. If you
    119 still want to use them in release builds you can remove the relevant
    120 '''#ifndef NDEBUG''' in '''ProcessLauncherGtk.cpp''',
    121 '''ProcessLauncher.h''', '''WebProcessProxyGtk.cpp''' and
    122 '''NetworkProcessProxySoup.cpp'''
    123146
    124147== Debugging issues ==