+2012-04-10 Mark Rowe <mrowe@apple.com>
+
+ <rdar://problem/10583749> WebKit2 should log to both ASL and stderr
+
+ Reviewed by Sam Weinig.
+
+ * wtf/Assertions.cpp: Add a WTFLogAlways function that unconditionally logs the given message.
+ * wtf/Assertions.h:
+
2012-04-10 Patrick Gansterer <paroga@webkit.org>
Cleanup wtf/Platform.h and config.h files
printCallSite(file, line, function);
}
+void WTFLogAlways(const char* format, ...)
+{
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelInfo);
+#endif
+
+ va_list args;
+ va_start(args, format);
+ vprintf_stderr_with_trailing_newline(format, args);
+ va_end(args);
+}
+
} // extern "C"
WTF_EXPORT_PRIVATE void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
WTF_EXPORT_PRIVATE void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
WTF_EXPORT_PRIVATE void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
+WTF_EXPORT_PRIVATE void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
WTF_EXPORT_PRIVATE void WTFReportBacktrace();
+2012-04-10 Mark Rowe <mrowe@apple.com>
+
+ <rdar://problem/10583749> WebKit2 should log to both ASL and stderr
+
+ Replace direct calls to fprintf stderr with calls to WTFLogAlways.
+
+ Reviewed by Sam Weinig.
+
+ * PluginProcess/mac/PluginProcessMainMac.mm:
+ (WebKit::PluginProcessMain):
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::checkURLReceivedFromWebProcess):
+ (WebKit::WebProcessProxy::didReceiveInvalidMessage):
+ * WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp:
+ (WebKit::InjectedBundle::load):
+ * WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm:
+ (readSandboxProfile):
+ (WKN_EnterSandbox):
+ * WebProcess/mac/WebProcessMac.mm:
+ (WebKit::initializeSandbox):
+ * WebProcess/mac/WebProcessMainMac.mm:
+ (WebKit::WebProcessMain):
+
2012-04-10 Yael Aharon <yael.aharon@nokia.com>
Unreviewed build fix after r113791.
mach_port_t serverPort;
kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort);
if (kr) {
- fprintf(stderr, "bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
+ WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
return EXIT_FAILURE;
}
}
// A Web process that was never asked to load a file URL should not ever ask us to do anything with a file URL.
- fprintf(stderr, "Received an unexpected URL from the web process: '%s'\n", url.string().utf8().data());
+ WTFLogAlways("Received an unexpected URL from the web process: '%s'\n", url.string().utf8().data());
return false;
}
void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID)
{
- fprintf(stderr, "Received an invalid message from the web process with message ID %x\n", messageID.toInt());
+ WTFLogAlways("Received an invalid message from the web process with message ID %x\n", messageID.toInt());
// Terminate the WebProcesses.
terminate();
{
if (m_sandboxExtension) {
if (!m_sandboxExtension->consume()) {
- fprintf(stderr, "InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
+ WTFLogAlways("InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
return false;
}
RetainPtr<CFStringRef> injectedBundlePathStr(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(m_path.characters()), m_path.length()));
if (!injectedBundlePathStr) {
- fprintf(stderr, "InjectedBundle::load failed - Could not create the path string.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not create the path string.\n");
return false;
}
RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(0, injectedBundlePathStr.get(), kCFURLPOSIXPathStyle, false));
if (!bundleURL) {
- fprintf(stderr, "InjectedBundle::load failed - Could not create the url from the path string.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not create the url from the path string.\n");
return false;
}
m_platformBundle = CFBundleCreate(0, bundleURL.get());
if (!m_platformBundle) {
- fprintf(stderr, "InjectedBundle::load failed - Could not create the bundle.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not create the bundle.\n");
return false;
}
if (!CFBundleLoadExecutable(m_platformBundle)) {
- fprintf(stderr, "InjectedBundle::load failed - Could not load the executable from the bundle.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not load the executable from the bundle.\n");
return false;
}
WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName(m_platformBundle, CFSTR("WKBundleInitialize")));
if (!initializeFunction) {
- fprintf(stderr, "InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
return false;
}
RetainPtr<CFURLRef> profileURL(AdoptCF, CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("com.apple.WebKit.PluginProcess"), CFSTR("sb"), 0));
char profilePath[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(profileURL.get(), false, reinterpret_cast<UInt8*>(profilePath), sizeof(profilePath))) {
- fprintf(stderr, "Could not get file system representation of plug-in sandbox URL\n");
+ WTFLogAlways("Could not get file system representation of plug-in sandbox URL\n");
return CString();
}
FILE *file = fopen(profilePath, "r");
if (!file) {
- fprintf(stderr, "Could not open plug-in sandbox file '%s'\n", profilePath);
+ WTFLogAlways("Could not open plug-in sandbox file '%s'\n", profilePath);
return CString();
}
struct stat fileInfo;
if (stat(profilePath, &fileInfo)) {
- fprintf(stderr, "Could not get plug-in sandbox file size '%s'\n", profilePath);
+ WTFLogAlways("Could not get plug-in sandbox file size '%s'\n", profilePath);
return CString();
}
CString result = CString::newUninitialized(fileInfo.st_size, characterBuffer);
if (1 != fread(characterBuffer, fileInfo.st_size, 1, file)) {
- fprintf(stderr, "Could not read plug-in sandbox file '%s'\n", profilePath);
+ WTFLogAlways("Could not read plug-in sandbox file '%s'\n", profilePath);
return CString();
}
setenv("DIRHELPER_USER_DIR_SUFFIX", fileSystemRepresentation(systemDirectorySuffix).data(), 0);
char temporaryDirectory[PATH_MAX];
if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
- fprintf(stderr, "PluginProcess: couldn't retrieve private temporary directory path: %d\n", errno);
+ WTFLogAlways("PluginProcess: couldn't retrieve private temporary directory path: %d\n", errno);
exit(EX_NOPERM);
}
setenv("TMPDIR", temporaryDirectory, 1);
const char* sandboxParameters[] = { "HOME_DIR", homeDirectory, 0, 0 };
if (!WKEnterPluginSandbox(profile.data(), sandboxParameters, extendedReadOnlyPaths.data(), extendedReadWritePaths.data())) {
- fprintf(stderr, "Couldn't initialize sandbox profile\n");
+ WTFLogAlways("Couldn't initialize sandbox profile\n");
exit(EX_NOPERM);
}
if (noErr != WKEnableSandboxStyleFileQuarantine()) {
- fprintf(stderr, "Couldn't enable file quarantine\n");
+ WTFLogAlways("Couldn't enable file quarantine\n");
exit(EX_NOPERM);
}
{
#if ENABLE(WEB_PROCESS_SANDBOX)
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisableSandbox"]) {
- fprintf(stderr, "Bypassing sandbox due to DisableSandbox user default.\n");
+ WTFLogAlways("Bypassing sandbox due to DisableSandbox user default.\n");
return;
}
setenv("DIRHELPER_USER_DIR_SUFFIX", fileSystemRepresentation(systemDirectorySuffix).data(), 0);
char temporaryDirectory[PATH_MAX];
if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
- fprintf(stderr, "WebProcess: couldn't retrieve private temporary directory path: %d\n", errno);
+ WTFLogAlways("WebProcess: couldn't retrieve private temporary directory path: %d\n", errno);
exit(EX_NOPERM);
}
setenv("TMPDIR", temporaryDirectory, 1);
char* errorBuf;
if (sandbox_init_with_parameters(profilePath, SANDBOX_NAMED_EXTERNAL, sandboxParameters.data(), &errorBuf)) {
- fprintf(stderr, "WebProcess: couldn't initialize sandbox profile [%s]\n", profilePath);
+ WTFLogAlways("WebProcess: couldn't initialize sandbox profile [%s]\n", profilePath);
for (size_t i = 0; sandboxParameters[i]; i += 2)
- fprintf(stderr, "%s=%s\n", sandboxParameters[i], sandboxParameters[i + 1]);
+ WTFLogAlways("%s=%s\n", sandboxParameters[i], sandboxParameters[i + 1]);
exit(EX_NOPERM);
}
// This will override LSFileQuarantineEnabled from Info.plist unless sandbox quarantine is globally disabled.
OSStatus error = WKEnableSandboxStyleFileQuarantine();
if (error) {
- fprintf(stderr, "WebProcess: couldn't enable sandbox style file quarantine: %ld\n", (long)error);
+ WTFLogAlways("WebProcess: couldn't enable sandbox style file quarantine: %ld\n", (long)error);
exit(EX_NOPERM);
}
#endif
if (clientExecutable.isEmpty()) {
kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort);
if (kr) {
- fprintf(stderr, "bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
+ WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
return 2;
}
}
// Make it possible to look up.
serviceName = String::format("com.apple.WebKit.WebProcess-%d", getpid());
if (kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.utf8().data()), publishedService, 0)) {
- fprintf(stderr, "Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr);
+ WTFLogAlways("Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr);
return EXIT_FAILURE;
}
mach_msg_empty_rcv_t message;
if (kern_return_t kr = mach_msg(&message.header, MACH_RCV_MSG, 0, sizeof(message), publishedService, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL)) {
- fprintf(stderr, "Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr);
+ WTFLogAlways("Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr);
return EXIT_FAILURE;
}
mach_port_type_t portType;
kern_return_t kr = mach_port_type(mach_task_self(), serverPort, &portType);
if (kr || !(portType & MACH_PORT_TYPE_SEND)) {
- fprintf(stderr, "Failed to obtain send right for port received from the UI process.\n");
+ WTFLogAlways("Failed to obtain send right for port received from the UI process.\n");
return EXIT_FAILURE;
}
}