move CrashReporterClientSPI.h and parts of WKCrashReporter to WTF so it can be used...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2019 19:36:12 +0000 (19:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2019 19:36:12 +0000 (19:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203803

Patch by Tuomas Karkkainen <tuomas.webkit@apple.com> on 2019-11-05
Reviewed by Saam Barati.

Source/WebKit:

No new tests added because functionality is not changing, code is only
moved from WebKit to WTF.

* Platform/cocoa/WKCrashReporter.mm:
(WebKit::setCrashReportApplicationSpecificInformation):
(WebKit::setCrashLogMessage): Deleted.
* WebKit.xcodeproj/project.pbxproj:

Source/WTF:

* WTF.xcodeproj/project.pbxproj:
* wtf/PlatformMac.cmake:
* wtf/cocoa/CrashReporter.cpp: Added.
(WTF::setCrashLogMessage):
* wtf/cocoa/CrashReporter.h: Added.
* wtf/spi/cocoa/CrashReporterClientSPI.h: Renamed from Source/WebKit/Platform/spi/Cocoa/CrashReporterClientSPI.h.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252065 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/PlatformMac.cmake
Source/WTF/wtf/cocoa/CrashReporter.cpp [new file with mode: 0644]
Source/WTF/wtf/cocoa/CrashReporter.h [new file with mode: 0644]
Source/WTF/wtf/spi/cocoa/CrashReporterClientSPI.h [moved from Source/WebKit/Platform/spi/Cocoa/CrashReporterClientSPI.h with 99% similarity]
Source/WebKit/ChangeLog
Source/WebKit/Platform/cocoa/WKCrashReporter.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index d47f22e..dc3c4ea 100644 (file)
@@ -1,3 +1,17 @@
+2019-11-05  Tuomas Karkkainen  <tuomas.webkit@apple.com>
+
+        move CrashReporterClientSPI.h and parts of WKCrashReporter to WTF so it can be used in JavaScriptCore
+        https://bugs.webkit.org/show_bug.cgi?id=203803
+
+        Reviewed by Saam Barati.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/PlatformMac.cmake:
+        * wtf/cocoa/CrashReporter.cpp: Added.
+        (WTF::setCrashLogMessage):
+        * wtf/cocoa/CrashReporter.h: Added.
+        * wtf/spi/cocoa/CrashReporterClientSPI.h: Renamed from Source/WebKit/Platform/spi/Cocoa/CrashReporterClientSPI.h.
+
 2019-11-02  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Add diagnostic logging for frontend feature usage
index 2dfc903..7f035b0 100644 (file)
                C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2BCFC531F621F3F00C9222C /* LineEnding.cpp */; };
                C805EF39E5F14481A96D39FC /* ASCIILiteral.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F050790D9C432A99085E75 /* ASCIILiteral.cpp */; };
                CD5497AC15857D0300B5BC30 /* MediaTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5497AA15857D0300B5BC30 /* MediaTime.cpp */; };
+               CEA072AA236FFBF70018839C /* CrashReporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA072A9236FFBF70018839C /* CrashReporter.cpp */; };
                DCEE22011CEA7551000C2396 /* BlockObjCExceptions.mm in Sources */ = {isa = PBXBuildFile; fileRef = DCEE21FD1CEA7551000C2396 /* BlockObjCExceptions.mm */; };
                E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
                E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E311FB151F0A568B003C08DE /* ThreadGroup.cpp */; };
                CD7600FF1F90A3CA00026E26 /* UnsafePointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnsafePointer.h; sourceTree = "<group>"; };
                CDCC9BC422382FCE00FFB51C /* AggregateLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AggregateLogger.h; path = wtf/AggregateLogger.h; sourceTree = SOURCE_ROOT; };
                CE73E02419DCB7AB00580D5C /* XPCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCSPI.h; sourceTree = "<group>"; };
+               CEA072A7236FFA160018839C /* CrashReporterClientSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrashReporterClientSPI.h; sourceTree = "<group>"; };
+               CEA072A8236FFBF70018839C /* CrashReporter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrashReporter.h; sourceTree = "<group>"; };
+               CEA072A9236FFBF70018839C /* CrashReporter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CrashReporter.cpp; sourceTree = "<group>"; };
                DCEE21FA1CEA7538000C2396 /* CFBundleSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundleSPI.h; sourceTree = "<group>"; };
                DCEE21FC1CEA7551000C2396 /* BlockObjCExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockObjCExceptions.h; sourceTree = "<group>"; };
                DCEE21FD1CEA7551000C2396 /* BlockObjCExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockObjCExceptions.mm; sourceTree = "<group>"; };
                CE46516C19DB1FB4003ECA05 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               CEA072A7236FFA160018839C /* CrashReporterClientSPI.h */,
                                9384B73E20DEA284005B73B2 /* CFXPCBridgeSPI.h */,
                                E31BDE2822E913CC0029B105 /* MachVMSPI.h */,
                                93D191CF20CAECE800C51B8E /* objcSPI.h */,
                                A30D412C1F0DE0BA00B71954 /* SoftLinking.h */,
                                5CC0EE862162BC2200A1A842 /* URLCocoa.mm */,
                                E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */,
+                               CEA072A8236FFBF70018839C /* CrashReporter.h */,
+                               CEA072A9236FFBF70018839C /* CrashReporter.cpp */,
                        );
                        path = cocoa;
                        sourceTree = "<group>";
                                53534F2A1EC0E10E00141B2F /* MachExceptions.defs in Sources */,
                                7A6EBA3420746C34004F9C44 /* MachSendRight.cpp in Sources */,
                                A8A473E5151A825B004123FF /* MainThread.cpp in Sources */,
+                               CEA072AA236FFBF70018839C /* CrashReporter.cpp in Sources */,
                                A8A473E4151A825B004123FF /* MainThreadCocoa.mm in Sources */,
                                A8A473E9151A825B004123FF /* MD5.cpp in Sources */,
                                CD5497AC15857D0300B5BC30 /* MediaTime.cpp in Sources */,
index c674ba3..b9a8975 100644 (file)
@@ -13,6 +13,7 @@ list(APPEND WTF_PUBLIC_HEADERS
     cf/CFURLExtras.h
     cf/TypeCastsCF.h
 
+    cocoa/CrashReporter.h
     cocoa/Entitlements.h
     cocoa/NSURLExtras.h
     cocoa/SoftLinking.h
@@ -23,6 +24,7 @@ list(APPEND WTF_PUBLIC_HEADERS
     spi/cf/CFStringSPI.h
 
     spi/cocoa/CFXPCBridgeSPI.h
+    spi/cocoa/CrashReporterClientSPI.h
     spi/cocoa/MachVMSPI.h
     spi/cocoa/SecuritySPI.h
     spi/cocoa/objcSPI.h
@@ -51,6 +53,7 @@ list(APPEND WTF_SOURCES
 
     cocoa/AutodrainedPool.cpp
     cocoa/CPUTimeCocoa.cpp
+    cocoa/CrashReporter.cpp
     cocoa/Entitlements.mm
     cocoa/FileSystemCocoa.mm
     cocoa/MachSendRight.cpp
diff --git a/Source/WTF/wtf/cocoa/CrashReporter.cpp b/Source/WTF/wtf/cocoa/CrashReporter.cpp
new file mode 100644 (file)
index 0000000..beb1bcb
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+* Copyright (C) 2019 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "config.h"
+#include "CrashReporter.h"
+
+#include <wtf/spi/cocoa/CrashReporterClientSPI.h>
+
+// Avoid having to link with libCrashReporterClient.a
+CRASH_REPORTER_CLIENT_HIDDEN
+struct crashreporter_annotations_t gCRAnnotations
+    __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
+    = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
+
+namespace WTF {
+void setCrashLogMessage(const char* message)
+{
+    // We have to copy the string because CRSetCrashLogMessage doesn't.
+    char* copiedMessage = message ? strdup(message) : nullptr;
+
+    CRSetCrashLogMessage(copiedMessage);
+
+    // Delete the message from last time, so we don't keep leaking messages.
+    static char* previousCopiedCrashLogMessage;
+    std::free(std::exchange(previousCopiedCrashLogMessage, copiedMessage));
+}
+}
diff --git a/Source/WTF/wtf/cocoa/CrashReporter.h b/Source/WTF/wtf/cocoa/CrashReporter.h
new file mode 100644 (file)
index 0000000..29c5c1a
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+* Copyright (C) 2019 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#pragma once
+
+namespace WTF {
+
+WTF_EXPORT void setCrashLogMessage(const char*);
+
+} // namespace WTF
@@ -23,6 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#pragma once
+
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <CrashReporterClient.h>
index 17a4325..80d7ab1 100644 (file)
@@ -1,3 +1,18 @@
+2019-11-05  Tuomas Karkkainen  <tuomas.webkit@apple.com>
+
+        move CrashReporterClientSPI.h and parts of WKCrashReporter to WTF so it can be used in JavaScriptCore
+        https://bugs.webkit.org/show_bug.cgi?id=203803
+
+        Reviewed by Saam Barati.
+
+        No new tests added because functionality is not changing, code is only
+        moved from WebKit to WTF.
+
+        * Platform/cocoa/WKCrashReporter.mm:
+        (WebKit::setCrashReportApplicationSpecificInformation):
+        (WebKit::setCrashLogMessage): Deleted.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-11-05  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Native text substitutions interfere with HTML <datalist> options resulting in crash
index 923d3ba..dda4e2b 100644 (file)
 
 #import "config.h"
 #import "WKCrashReporter.h"
+#import <wtf/cocoa/CrashReporter.h>
 
 #import <cstdlib>
-#import "CrashReporterClientSPI.h"
-
-// Avoid having to link with libCrashReporterClient.a
-CRASH_REPORTER_CLIENT_HIDDEN
-struct crashreporter_annotations_t gCRAnnotations
-__attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
-    = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
 
 namespace WebKit {
 
-static void setCrashLogMessage(const char* message)
-{
-    // We have to copy the string because CRSetCrashLogMessage doesn't.
-    char* copiedMessage = message ? strdup(message) : nullptr;
-
-    CRSetCrashLogMessage(copiedMessage);
-
-    // Delete the message from last time, so we don't keep leaking messages.
-    static char* previousCopiedCrashLogMessage;
-    std::free(std::exchange(previousCopiedCrashLogMessage, copiedMessage));
-}
-
 void setCrashReportApplicationSpecificInformation(CFStringRef infoString)
 {
-    setCrashLogMessage([(__bridge NSString *)infoString UTF8String]);
+    WTF::setCrashLogMessage([(__bridge NSString *)infoString UTF8String]);
 }
 
 }
index 21f3f6a..772a100 100644 (file)
                A1EA02381DABFF7E0096021F /* WKContextMenuListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A1EA02361DABFF7E0096021F /* WKContextMenuListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1EA02401DAC31DB0096021F /* WebContextMenuListenerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A1EA023E1DAC31DB0096021F /* WebContextMenuListenerProxy.h */; };
                A1FB68241F6E518200C43F9F /* WKCrashReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1FB68221F6E518200C43F9F /* WKCrashReporter.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               A1FB68271F6E51C100C43F9F /* CrashReporterClientSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1FB68261F6E51C100C43F9F /* CrashReporterClientSPI.h */; };
                A513F5402154A5D700662841 /* WebPageInspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = A513F53E2154A5CC00662841 /* WebPageInspectorController.h */; };
                A518B5D21FE1D55B00F9FA28 /* WKInspectorWKWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = A518B5D01FE1D55B00F9FA28 /* WKInspectorWKWebView.h */; };
                A54293A4195A43DA002782C7 /* WKInspectorNodeSearchGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */; };
                A1EDD2DC1884B9B500BBFE98 /* SecItemShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SecItemShim.xcconfig; sourceTree = "<group>"; };
                A1FB68221F6E518200C43F9F /* WKCrashReporter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKCrashReporter.h; sourceTree = "<group>"; };
                A1FB68231F6E518200C43F9F /* WKCrashReporter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKCrashReporter.mm; sourceTree = "<group>"; };
-               A1FB68261F6E51C100C43F9F /* CrashReporterClientSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrashReporterClientSPI.h; sourceTree = "<group>"; };
                A513F53E2154A5CC00662841 /* WebPageInspectorController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPageInspectorController.h; sourceTree = "<group>"; };
                A513F53F2154A5CD00662841 /* WebPageInspectorController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageInspectorController.cpp; sourceTree = "<group>"; };
                A518B5D01FE1D55B00F9FA28 /* WKInspectorWKWebView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKInspectorWKWebView.h; sourceTree = "<group>"; };
                        children = (
                                1A5705101BE410E500874AF1 /* BlockSPI.h */,
                                37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */,
-                               A1FB68261F6E51C100C43F9F /* CrashReporterClientSPI.h */,
                                57DCEDAA214B9B430016B847 /* DeviceIdentitySPI.h */,
                                2DAADA8E2298C21000E36B0C /* DeviceManagementSPI.h */,
                                57B826402304EB3E00B72EB0 /* NearFieldSPI.h */,
                                5106D7C418BDBE73000AB166 /* ContextMenuContextData.h in Headers */,
                                37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */,
                                B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
-                               A1FB68271F6E51C100C43F9F /* CrashReporterClientSPI.h in Headers */,
                                57597EBD218184900037F924 /* CtapAuthenticator.h in Headers */,
                                57597EB921811D9A0037F924 /* CtapHidDriver.h in Headers */,
                                570DAACA230385FD00E8FC04 /* CtapNfcDriver.h in Headers */,