⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changes between Version 3 and Version 4 of Debugging With Xcode


Ignore:
Timestamp:
Jun 5, 2026, 5:47:24 PM (32 hours ago)
Author:
darbinyan@apple.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Debugging With Xcode

    v3 v4  
    1  * [https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode_Overview/About_Xcode/about.html#//apple_ref/doc/uid/TP40010215-CH3-SW1 General information on using Xcode]
    2  * [http://www.webkit.org/building/debug.html The main WebKit debug information]
    3 
    4 = Debugging WebKit2 =
    5 
    6 == Method #1 ==
    7 
    8  1. Make sure '''Use WebKit2 for New Windows''' option is selected in Safari’s '''Debug'''
    9  2. Open `WebKit2.xcodeproj` and make sure that the WebProcess is set to the Active Executable
    10  3. Control-click the `WebProcess` executable and choose '''Get Info'''
    11  4. In the Debugging tab, select '''Wait for next launch/push notification'''
    12  5. Choose '''Run ► Debug'''
    13  6. A dialog will appear saying: “Waiting for WebProcess to launch…”
    14  7. Open `Safari.xcodeproj` '''Run ► Debug'''
    15  8. The WebProcess will break in the debugger, and you’ll probably have to continue at least once before normal execution resumes
    16 
    17 You’re now debugging both the `UIProcess` and the `WebProcess`. Your breakpoints in either should be work accordingly.
    18 
    19 
    20 == Method #2 ==
    21 
    22  1. Open the Xcode projects for Safari and WebCore (or WebKit2, or whatever)
    23  2. From the Safari project, '''Run'''
    24  3. From the WebCore project, choose '''Run ► Attach to Process''', and choose the `WebProcess`
    25  4. Let `gdb` do its thing, and Continue
    26 
    27 You’re now debugging the `WebProcess`.  ''('''Note:''' I've had issues with `gdb` using this method.)''
    28 
    29 
    30 = Debugging DumpRenderTree =
    31 
    32 TODO
    33 
    34 = Debugging WebKitTestRunner =
    35 
    36 Some code that executes during initialization can be hard to debug with the default way of attaching to the child process. In this situation, the following steps allowed Xcode to attach fairly early:
    37 
    38 1. Set a breakpoint in the WebCore/WK2 WebProcess code you are interested in.
    39 1. Set a breakpoint in `TestInvocation::invoke`.
    40 1. Start WebKitTestRunner with the desired arguments.
    41 1. Hit the breakpoint inside `invoke()`.
    42 1. Attach to the spawned web process (at the time of writing, named `com.apple.WebKit.WebContent.Development`.
    43 2. Continue
    44 
    45 = Miscellaneous Tips =
    46 
    47 == Prevent Safari from complaining about web process hangs when debugging ==
    48 
    49  1. Control-click the Safari executable and choose '''Get Info'''
    50  2. Select the '''Arguments''' tab
    51  3. Beneath the list '''Variables to be set in the environment''', click the “`✚`” button
    52  4. Add the following item:
    53   * '''Name:''' `DebugInitialDelayForUnresponsiveWebProcess`
    54   * '''Value:''' `99999999`
    55 
    56 == To debug a web process crash on launch: ==
    57 
    58  1. Edit `WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm`
    59  2. Search for `SIGCONT`
    60  3. Remove the line of code that sends `SIGCONT` to the web process, then build
    61  4. In Terminal:
    62   a. launch `gdb`, then type `attach WebProcess` — OR
    63   b. in Xcode select '''Run  ► Attach to Process  ► Process ID...''' and type the WebProcess’s process ID
    64  5. Once attached:
    65   a. In `gdb` type `continue«enter»` — OR
    66   b. In Xcode select '''Run ► Continue'''
    67 
    68 == To debug a web process using Instruments/DTrace: ==
    69 
    70 If you’re having trouble attaching to the WebProcess, try disabling the sandbox:
    71 
    72 {{{defaults write com.apple.WebProcess DisableSandbox YES}}}
     1{{{#!html
     2<meta http-equiv="refresh" content="0; url=https://docs.webkit.org/Build%20%26%20Debug/DebuggingWithXcode.html">
     3<script>
     4window.location.replace("https://docs.webkit.org/Build%20%26%20Debug/DebuggingWithXcode.html");
     5</script>
     6<p>This page has moved. If you are not redirected automatically, <a href="https://docs.webkit.org/Build%20%26%20Debug/DebuggingWithXcode.html">click here</a>.</p>
     7}}}