Skip to content
Permalink
Browse files
It should be possible to attach to the WebProcess in gdb during startup
https://bugs.webkit.org/show_bug.cgi?id=42853

Reviewed by Adam Roben.

Create an unique bootstrap service name and pass it to the web process, instead of registering a per process
name (which was incorrect anyway). This lets us get rid of the requirement that the UI process always should be
the parent process of the web process, something which is false when running under the debugger.

* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* WebProcess/mac/WebProcessMainMac.mm:
(WebKit::WebProcessMain):

Canonical link: https://commits.webkit.org/54754@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jul 22, 2010
1 parent 541a36b commit 41f2e2251703719f338856d3b96909f0ddbc4939
Showing with 33 additions and 5 deletions.
  1. +16 −0 WebKit2/ChangeLog
  2. +9 −3 WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
  3. +8 −2 WebKit2/WebProcess/mac/WebProcessMainMac.mm
@@ -1,3 +1,19 @@
2010-07-22 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Roben.

It should be possible to attach to the WebProcess in gdb during startup
https://bugs.webkit.org/show_bug.cgi?id=42853

Create an unique bootstrap service name and pass it to the web process, instead of registering a per process
name (which was incorrect anyway). This lets us get rid of the requirement that the UI process always should be
the parent process of the web process, something which is false when running under the debugger.

* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* WebProcess/mac/WebProcessMainMac.mm:
(WebKit::WebProcessMain):

2010-07-22 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -28,13 +28,16 @@
#include "RunLoop.h"
#include "WebProcess.h"
#include "WebSystemInterface.h"

#include <WebCore/PlatformString.h>
#include <crt_externs.h>
#include <runtime/InitializeThreading.h>
#include <servers/bootstrap.h>
#include <spawn.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Threading.h>
#include <wtf/text/CString.h>

using namespace WebCore;

// FIXME: We should be doing this another way.
extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, uint64_t);
@@ -53,11 +56,14 @@
NSString *webProcessAppPath = [[NSBundle bundleWithIdentifier:@"com.apple.WebKit2"] pathForAuxiliaryExecutable:@"WebProcess.app"];
NSString *webProcessAppExecutablePath = [[NSBundle bundleWithPath:webProcessAppPath] executablePath];

// Make a unique, per pid, per process launcher web process service name.
CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8();

const char* path = [webProcessAppExecutablePath fileSystemRepresentation];
const char* args[] = { path, "-mode", "legacywebprocess", 0 };
const char* args[] = { path, "-mode", "legacywebprocess", "-servicename", serviceName.data(), 0 };

// Register ourselves.
kern_return_t kr = bootstrap_register2(bootstrap_port, (char*)"com.apple.WebKit.WebProcess", listeningPort, /* BOOTSTRAP_PER_PID_SERVICE */ 1);
kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0);
if (kr)
NSLog(@"bootstrap_register2 result: %x", kr);

@@ -38,6 +38,7 @@
#import <sysexits.h>
#import <unistd.h>
#import <wtf/Threading.h>
#import <wtf/text/CString.h>

#if ENABLE(WEB_PROCESS_SANDBOX)
#import <sandbox.h>
@@ -52,7 +53,7 @@

namespace WebKit {

int WebProcessMain(CommandLine*)
int WebProcessMain(CommandLine* commandLine)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

@@ -68,8 +69,13 @@ int WebProcessMain(CommandLine*)
}
#endif

String serviceName = (*commandLine)["servicename"];
if (serviceName.isEmpty())
return EXIT_FAILURE;

// Get the server port.
mach_port_t serverPort;
kern_return_t kr = bootstrap_look_up2(bootstrap_port, "com.apple.WebKit.WebProcess", &serverPort, getppid(), /* BOOTSTRAP_PER_PID_SERVICE */ 1);
kern_return_t kr = bootstrap_look_up2(bootstrap_port, serviceName.utf8().data(), &serverPort, 0, 0);
if (kr) {
printf("bootstrap_look_up2 result: %x", kr);
return 2;

0 comments on commit 41f2e22

Please sign in to comment.