Title: [281257] trunk/Tools
Revision
281257
Author
jbed...@apple.com
Date
2021-08-19 12:46:00 -0700 (Thu, 19 Aug 2021)

Log Message

[run-webkit-tests] Handle json crash logs (Part 1)
https://bugs.webkit.org/show_bug.cgi?id=229288
<rdar://problem/77074039>

Reviewed by Alexey Proskuryakov.

* Scripts/webkitpy/common/system/crashlogs.py:
(CrashLogs._parse_darwin_crash_log): Attempt to parse crash logs as json, since Monterey .ips
(CrashLogs._find_newest_log_darwin.is_crash_log):
* Scripts/webkitpy/common/system/crashlogs_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (281256 => 281257)


--- trunk/Tools/ChangeLog	2021-08-19 19:44:56 UTC (rev 281256)
+++ trunk/Tools/ChangeLog	2021-08-19 19:46:00 UTC (rev 281257)
@@ -1,3 +1,16 @@
+2021-08-19  Jonathan Bedard  <jbed...@apple.com>
+
+        [run-webkit-tests] Handle json crash logs (Part 1)
+        https://bugs.webkit.org/show_bug.cgi?id=229288
+        <rdar://problem/77074039>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Scripts/webkitpy/common/system/crashlogs.py:
+        (CrashLogs._parse_darwin_crash_log): Attempt to parse crash logs as json, since Monterey .ips
+        (CrashLogs._find_newest_log_darwin.is_crash_log):
+        * Scripts/webkitpy/common/system/crashlogs_unittest.py:
+
 2021-08-19  Carlos Garcia Campos  <cgar...@igalia.com>
 
         document.hasFocus() returns true for unfocused pages

Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py (281256 => 281257)


--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py	2021-08-19 19:44:56 UTC (rev 281256)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py	2021-08-19 19:46:00 UTC (rev 281257)
@@ -1,5 +1,5 @@
 # Copyright (c) 2011, Google Inc. All rights reserved.
-# Copyright (c) 2015, Apple Inc. All rights reserved.
+# Copyright (c) 2015, 2021 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
@@ -28,6 +28,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import datetime
+import json
 import logging
 import re
 
@@ -65,8 +66,21 @@
         contents = self._host.symbolicate_crash_log_if_needed(path)
         if not contents:
             return (None, None, None)
+
+        lines = contents.splitlines()
+        if len(lines) >= 2 and lines[0].startswith('{') and lines[1].startswith('{'):
+            try:
+                json.loads(lines[0])
+                decoded = json.loads('\n'.join(lines[1:]))
+                name = decoded.get('procName')
+                pid = decoded.get('pid')
+                if name and pid:
+                    return (name, pid, contents)
+            except ValueError:
+                pass
+
         is_sandbox_violation = False
-        for line in contents.splitlines():
+        for line in lines:
             if line.startswith('Sandbox Violation:'):
                 is_sandbox_violation = True
             match = CrashLogs.DARWIN_PROCESS_REGEX.match(line)
@@ -79,7 +93,7 @@
             if self._crash_logs_to_skip and fs.join(dirpath, basename) in self._crash_logs_to_skip:
                 return False
             return (basename.startswith(process_name + '_') and (basename.endswith('.crash')) or
-                    (process_name in basename  and basename.endswith('.ips')))
+                    (process_name in basename and basename.endswith('.ips')))
 
         logs = self._host.filesystem.files_under(self._crash_log_directory, file_filter=is_crash_log)
         errors = ''

Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py (281256 => 281257)


--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py	2021-08-19 19:44:56 UTC (rev 281256)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py	2021-08-19 19:46:00 UTC (rev 281257)
@@ -1,4 +1,5 @@
 # Copyright (C) 2011 Google Inc. All rights reserved.
+# Copyright (c) 2021, Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -74,6 +75,24 @@
 """.format(process_name=process_name, pid=pid)
 
 
+def make_mock_ips_crash_report_darwin(process_name, pid):
+    return """{{"app_name":"{name}","timestamp":"2011-12-07 13:27:34.816 -0800","name":"{name}"}}
+{{
+  "uptime" : 6900,
+  "procRole" : "Non UI",
+  "version" : 2,
+  "userID" : 501,
+  "deployVersion" : 209,
+  "modelCode" : "MacBookPro16,4",
+  "coalitionID" : 512,
+  "captureTime" : "2011-12-07 13:27:34.816 -0800",
+  "incident" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
+  "bug_type" : "309",
+  "pid" : {pid},
+  "procName" : "{name}"
+}}""".format(name=process_name, pid=pid)
+
+
 def make_mock_sandbox_report_darwin(process_name, pid):
     return """Incident Identifier: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 CrashReporter Key:   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -286,7 +305,7 @@
         self.older_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28528)
         self.sandbox_crash_report = make_mock_sandbox_report_darwin('DumpRenderTree', 28530)
         self.mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28530)
-        self.newer_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28529)
+        self.newer_mock_crash_report = make_mock_ips_crash_report_darwin('DumpRenderTree', 28529)
         self.other_process_mock_crash_report = make_mock_crash_report_darwin('FooProcess', 28527)
         self.misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_darwin('DumpRenderTree', 28526)[200:]
         self.files = {}
@@ -295,7 +314,7 @@
         self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150717_quadzen_2.crash'] = self.older_mock_crash_report
         self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash'] = self.sandbox_crash_report
         self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash'] = self.mock_crash_report
-        self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash'] = self.newer_mock_crash_report
+        self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.ips'] = self.newer_mock_crash_report
         self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash'] = None
         self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = self.other_process_mock_crash_report
         self.files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = self.misformatted_mock_crash_report
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to