* [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] * [http://www.webkit.org/building/debug.html The main WebKit debug information] = Debugging WebKit2 = == Method #1 == 1. Make sure '''Use WebKit2 for New Windows''' option is selected in Safari’s '''Debug''' 2. Open `WebKit2.xcodeproj` and make sure that the WebProcess is set to the Active Executable 3. Control-click the `WebProcess` executable and choose '''Get Info''' 4. In the Debugging tab, select '''Wait for next launch/push notification''' 5. Choose '''Run ► Debug''' 6. A dialog will appear saying: “Waiting for WebProcess to launch…” 7. Open `Safari.xcodeproj` '''Run ► Debug''' 8. The WebProcess will break in the debugger, and you’ll probably have to continue at least once before normal execution resumes You’re now debugging both the `UIProcess` and the `WebProcess`. Your breakpoints in either should be work accordingly. == Method #2 == 1. Open the Xcode projects for Safari and WebCore (or WebKit2, or whatever) 2. From the Safari project, '''Run''' 3. From the WebCore project, choose '''Run ► Attach to Process''', and choose the `WebProcess` 4. Let `gdb` do its thing, and Continue You’re now debugging the `WebProcess`. ''('''Note:''' I've had issues with `gdb` using this method.)'' = Debugging DumpRenderTree = TODO = Debugging WebKitTestRunner = 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: 1. Set a breakpoint in the WebCore/WK2 WebProcess code you are interested in. 1. Set a breakpoint in `TestInvocation::invoke`. 1. Start WebKitTestRunner with the desired arguments. 1. Hit the breakpoint inside `invoke()`. 1. Attach to the spawned web process (at the time of writing, named `com.apple.WebKit.WebContent.Development`. 2. Continue = Miscellaneous Tips = == Prevent Safari from complaining about web process hangs when debugging == 1. Control-click the Safari executable and choose '''Get Info''' 2. Select the '''Arguments''' tab 3. Beneath the list '''Variables to be set in the environment''', click the “`✚`” button 4. Add the following item: * '''Name:''' `DebugInitialDelayForUnresponsiveWebProcess` * '''Value:''' `99999999` == To debug a web process crash on launch: == 1. Edit `WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm` 2. Search for `SIGCONT` 3. Remove the line of code that sends `SIGCONT` to the web process, then build 4. In Terminal: a. launch `gdb`, then type `attach WebProcess` — OR b. in Xcode select '''Run ► Attach to Process ► Process ID...''' and type the WebProcess’s process ID 5. Once attached: a. In `gdb` type `continue«enter»` — OR b. In Xcode select '''Run ► Continue''' == To debug a web process using Instruments/DTrace: == If you’re having trouble attaching to the WebProcess, try disabling the sandbox: {{{defaults write com.apple.WebProcess DisableSandbox YES}}}