Changeset 139961 in webkit
- Timestamp:
- Jan 16, 2013 8:58:13 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r139960 r139961 1 2013-01-16 Sam Weinig <sam@webkit.org> 2 3 Make debug-safari --target-web-process work again 4 https://bugs.webkit.org/show_bug.cgi?id=107088 5 6 Reviewed by Anders Carlsson. 7 8 --target-web-process was made harder to use during recent refactoring 9 by requiring users to pass a -ui-process-name parameter in addition to 10 the -client-executable. Instead, we should conjure up that name from 11 the information we already have at our disposal. 12 13 * WebProcess/mac/WebProcessMainMac.mm: 14 (WebKit::WebProcessMainDelegate::getConnectionIdentifier): 15 Simplify by making the non-client-executable path use the base 16 class implementation. 17 18 (WebKit::WebProcessMainDelegate::getClientIdentifier): 19 Ditto. 20 21 (WebKit::WebProcessMainDelegate::getClientProcessName): 22 Added. Create a client process name (its actually not too important what it is, as it 23 is only used to show a name in Activity Monitor) from the passed in client executable 24 path. 25 1 26 2013-01-16 Sam Weinig <sam@webkit.org> 2 27 -
trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm
r139066 r139961 61 61 virtual bool getConnectionIdentifier(CoreIPC::Connection::Identifier& identifier) 62 62 { 63 String serviceName = m_commandLine["servicename"];64 63 String clientExecutable = m_commandLine["client-executable"]; 65 if (serviceName.isEmpty() && clientExecutable.isEmpty()) 64 if (clientExecutable.isEmpty()) 65 return ChildProcessMainDelegate::getConnectionIdentifier(identifier); 66 67 mach_port_name_t publishedService; 68 mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &publishedService); 69 mach_port_insert_right(mach_task_self(), publishedService, publishedService, MACH_MSG_TYPE_MAKE_SEND); 70 // Make it possible to look up. 71 String serviceName = String::format("com.apple.WebKit.WebProcess-%d", getpid()); 72 if (kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.utf8().data()), publishedService, 0)) { 73 WTFLogAlways("Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr); 74 return false; 75 } 76 77 CString command = clientExecutable.utf8(); 78 const char* args[] = { command.data(), 0 }; 79 80 EnvironmentVariables environmentVariables; 81 environmentVariables.set(EnvironmentVariables::preexistingProcessServiceNameKey(), serviceName.utf8().data()); 82 environmentVariables.set(EnvironmentVariables::preexistingProcessTypeKey(), m_commandLine["type"].utf8().data()); 83 84 posix_spawn_file_actions_t fileActions; 85 posix_spawn_file_actions_init(&fileActions); 86 posix_spawn_file_actions_addinherit_np(&fileActions, STDIN_FILENO); 87 posix_spawn_file_actions_addinherit_np(&fileActions, STDOUT_FILENO); 88 posix_spawn_file_actions_addinherit_np(&fileActions, STDERR_FILENO); 89 90 posix_spawnattr_t attributes; 91 posix_spawnattr_init(&attributes); 92 posix_spawnattr_setflags(&attributes, POSIX_SPAWN_CLOEXEC_DEFAULT | POSIX_SPAWN_SETPGROUP); 93 94 int spawnResult = posix_spawn(0, command.data(), &fileActions, &attributes, const_cast<char**>(args), environmentVariables.environmentPointer()); 95 96 posix_spawnattr_destroy(&attributes); 97 posix_spawn_file_actions_destroy(&fileActions); 98 99 if (spawnResult) 66 100 return false; 67 101 68 mach_port_t serverPort; 69 if (clientExecutable.isEmpty()) { 70 kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort); 71 if (kr) { 72 WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr); 73 return false; 74 } 75 } else { 76 mach_port_name_t publishedService; 77 mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &publishedService); 78 mach_port_insert_right(mach_task_self(), publishedService, publishedService, MACH_MSG_TYPE_MAKE_SEND); 79 // Make it possible to look up. 80 serviceName = String::format("com.apple.WebKit.WebProcess-%d", getpid()); 81 if (kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.utf8().data()), publishedService, 0)) { 82 WTFLogAlways("Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr); 83 return false; 84 } 102 mach_msg_empty_rcv_t message; 103 if (kern_return_t kr = mach_msg(&message.header, MACH_RCV_MSG, 0, sizeof(message), publishedService, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL)) { 104 WTFLogAlways("Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr); 105 return false; 106 } 85 107 86 CString command = clientExecutable.utf8(); 87 const char* args[] = { command.data(), 0 }; 88 89 EnvironmentVariables environmentVariables; 90 environmentVariables.set(EnvironmentVariables::preexistingProcessServiceNameKey(), serviceName.utf8().data()); 91 environmentVariables.set(EnvironmentVariables::preexistingProcessTypeKey(), m_commandLine["type"].utf8().data()); 92 93 posix_spawn_file_actions_t fileActions; 94 posix_spawn_file_actions_init(&fileActions); 95 posix_spawn_file_actions_addinherit_np(&fileActions, STDIN_FILENO); 96 posix_spawn_file_actions_addinherit_np(&fileActions, STDOUT_FILENO); 97 posix_spawn_file_actions_addinherit_np(&fileActions, STDERR_FILENO); 98 99 posix_spawnattr_t attributes; 100 posix_spawnattr_init(&attributes); 101 posix_spawnattr_setflags(&attributes, POSIX_SPAWN_CLOEXEC_DEFAULT | POSIX_SPAWN_SETPGROUP); 102 103 int spawnResult = posix_spawn(0, command.data(), &fileActions, &attributes, const_cast<char**>(args), environmentVariables.environmentPointer()); 104 105 posix_spawnattr_destroy(&attributes); 106 posix_spawn_file_actions_destroy(&fileActions); 107 108 if (spawnResult) 109 return false; 110 111 mach_msg_empty_rcv_t message; 112 if (kern_return_t kr = mach_msg(&message.header, MACH_RCV_MSG, 0, sizeof(message), publishedService, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL)) { 113 WTFLogAlways("Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr); 114 return false; 115 } 116 117 mach_port_mod_refs(mach_task_self(), publishedService, MACH_PORT_RIGHT_RECEIVE, -1); 118 serverPort = message.header.msgh_remote_port; 119 mach_port_type_t portType; 120 kern_return_t kr = mach_port_type(mach_task_self(), serverPort, &portType); 121 if (kr || !(portType & MACH_PORT_TYPE_SEND)) { 122 WTFLogAlways("Failed to obtain send right for port received from the UI process.\n"); 123 return false; 124 } 108 mach_port_mod_refs(mach_task_self(), publishedService, MACH_PORT_RIGHT_RECEIVE, -1); 109 mach_port_t serverPort = message.header.msgh_remote_port; 110 mach_port_type_t portType; 111 kern_return_t kr = mach_port_type(mach_task_self(), serverPort, &portType); 112 if (kr || !(portType & MACH_PORT_TYPE_SEND)) { 113 WTFLogAlways("Failed to obtain send right for port received from the UI process.\n"); 114 return false; 125 115 } 126 116 … … 132 122 { 133 123 String clientExecutable = m_commandLine["client-executable"]; 124 if (clientExecutable.isEmpty()) 125 return ChildProcessMainDelegate::getClientIdentifier(clientIdentifier); 134 126 127 RetainPtr<NSURL> clientExecutableURL = adoptNS([[NSURL alloc] initFileURLWithPath:nsStringFromWebCoreString(clientExecutable)]); 128 RetainPtr<CFURLRef> clientBundleURL = adoptCF(WKCopyBundleURLForExecutableURL((CFURLRef)clientExecutableURL.get())); 129 RetainPtr<NSBundle> clientBundle = adoptNS([[NSBundle alloc] initWithURL:(NSURL *)clientBundleURL.get()]); 130 clientIdentifier = [clientBundle.get() bundleIdentifier]; 131 if (clientIdentifier.isEmpty()) 132 return false; 133 return true; 134 } 135 136 virtual bool getClientProcessName(String& clientProcessName) 137 { 138 String clientExecutable = m_commandLine["client-executable"]; 135 139 if (clientExecutable.isEmpty()) 136 clientIdentifier = m_commandLine["client-identifier"]; 137 else { 138 RetainPtr<NSURL> clientExecutableURL = adoptNS([[NSURL alloc] initFileURLWithPath:nsStringFromWebCoreString(clientExecutable)]); 139 RetainPtr<CFURLRef> clientBundleURL = adoptCF(WKCopyBundleURLForExecutableURL((CFURLRef)clientExecutableURL.get())); 140 RetainPtr<NSBundle> clientBundle = adoptNS([[NSBundle alloc] initWithURL:(NSURL *)clientBundleURL.get()]); 141 clientIdentifier = [clientBundle.get() bundleIdentifier]; 142 } 140 return ChildProcessMainDelegate::getClientProcessName(clientProcessName); 143 141 144 if (clientIdentifier.isEmpty()) 142 // Conjure up a process name by using everything after the last slash from the client-executable, 143 // e.g. /Applications/Safari.app/Contents/MacOS/Safari becomes Safari. 144 size_t lastSlash = clientExecutable.reverseFind('/'); 145 clientProcessName = clientExecutable.substring(lastSlash + 1); 146 if (clientProcessName.isEmpty()) 145 147 return false; 146 148 return true; -
trunk/Tools/ChangeLog
r139957 r139961 1 2013-01-16 Sam Weinig <sam@webkit.org> 2 3 Make debug-safari --target-web-process work again 4 https://bugs.webkit.org/show_bug.cgi?id=107088 5 6 Reviewed by Anders Carlsson. 7 8 * Scripts/webkitdirs.pm: 9 (execMacWebKitAppForDebugging): 10 The shim is now called SecItemShim. 11 1 12 2013-01-16 Alan Cutter <alancutter@chromium.org> 2 13 -
trunk/Tools/Scripts/webkitdirs.pm
r139868 r139961 2686 2686 } 2687 2687 2688 my $webProcessShimPath = File::Spec->catfile($productDir, " WebProcessShim.dylib");2688 my $webProcessShimPath = File::Spec->catfile($productDir, "SecItemShim.dylib"); 2689 2689 my $webProcessPath = File::Spec->catdir($productDir, "WebProcess.app"); 2690 2690 my $webKit2ExecutablePath = File::Spec->catfile($productDir, "WebKit2.framework", "WebKit2");
Note: See TracChangeset
for help on using the changeset viewer.