tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

debugging_firefox_with_lldb.rst (2920B)


      1 Debugging Firefox with LLDB
      2 ===========================
      3 
      4 See http://lldb.llvm.org/index.html.
      5 
      6 Mozilla-specific lldb settings
      7 ------------------------------
      8 
      9 There's an
     10 ``.lldbinit`` `file <https://searchfox.org/mozilla-central/source/.lldbinit>`_
     11 in the Mozilla source tree, which applies recommended settings and
     12 includes a few type summaries and Mozilla-specific debugging commands
     13 via the lldbutils module (see
     14 `python/lldbutils/README.txt <https://searchfox.org/mozilla-central/source/python/lldbutils/README.txt>`__).
     15 For information about available features see the links above and the `Using
     16 LLDB to debug Gecko <http://mcc.id.au/blog/2014/01/lldb-gecko>`__ blog
     17 post.
     18 
     19 The in-tree ``.lldbinit`` should be loaded automatically in most cases
     20 when running lldb from the command line (e.g. using
     21 :ref:`mach`), but **not**
     22 when using Xcode. See :ref:`Debugging on macOS` for information on setting up
     23 Xcode.
     24 
     25 .. warning::
     26 
     27   LLDB warning: Xcode 5 only comes with lldb (gdb is gone). The
     28   introduction and use of UNIFIED_SOURCES in the source starting around
     29   November 2013 has broken the default LLDB configuration so that it
     30   will not manage to resolve breakpoints in files that are build using
     31   UNIFIED_SOURCES (the breakpoints will be listed as "pending", and
     32   lldb will not stop at them). To fix this add the following to your
     33   $HOME/.lldbinit file:
     34 
     35   .. code::
     36 
     37      # Mozilla's use of UNIFIED_SOURCES to include multiple source files into a
     38      # single compiled file breaks lldb breakpoint setting. This works around that.
     39      # See http://lldb.llvm.org/troubleshooting.html for more.
     40      settings set target.inline-breakpoint-strategy always
     41 
     42   Restart Xcode/lldb and restart your debugging session. If that still
     43   doesn't fix things then try closing Xcode/lldb, doing a clobber
     44   build, reopening Xcode/lldb, and restarting your debugging session.
     45 
     46 Starting a debugging session
     47 ----------------------------
     48 
     49 Attaching to an existing process
     50 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     51 
     52 You can attach to Firefox with following command:
     53 
     54 .. code::
     55 
     56   (lldb) process attach --name firefox
     57 
     58 Some versions of lldb causes crashes after attaching to Firefox.
     59 
     60 Running a new process
     61 ~~~~~~~~~~~~~~~~~~~~~
     62 
     63 To start Firefox under the debugger, run ``lldb`` followed by "--",
     64 followed by the command line you'd like to run, like this:
     65 
     66 .. code:: bash
     67 
     68   $ lldb -- obj-ff-dbg/dist/Nightly.app/Contents/MacOS/firefox -profile /path/to/profile
     69 
     70 Then set breakpoints you need and start the process:
     71 
     72 .. code::
     73 
     74   (lldb) breakpoint set --name nsInProcessTabChildGlobal::InitTabChildGlobal
     75   Breakpoint created: 1: name = 'nsInProcessTabChildGlobal::InitTabChildGlobal', locations = 0 (pending)
     76   WARNING: Unable to resolve breakpoint to any actual locations.
     77 
     78   (lldb) r
     79   Process 7602 launched: '/.../obj-ff-opt/dist/Nightly.app/Contents/MacOS/firefox' (x86_64)
     80   1 location added to breakpoint 1