aboutsummaryrefslogtreecommitdiff
path: root/lldb/examples/python/crashlog.py
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2021-10-05 12:12:04 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2021-10-05 12:15:54 -0700
commit730fca46fc87dad09040cb0b27ede10ae2c7c9d7 (patch)
treea3223ad42bc43e581a79a85275cac4b976413b9e /lldb/examples/python/crashlog.py
parentf92961d238efdfeccce27f9bb7b0a6629c376d4a (diff)
downloadllvm-730fca46fc87dad09040cb0b27ede10ae2c7c9d7.zip
llvm-730fca46fc87dad09040cb0b27ede10ae2c7c9d7.tar.gz
llvm-730fca46fc87dad09040cb0b27ede10ae2c7c9d7.tar.bz2
[lldb] Improve meta data stripping from JSON crashlogs
JSON crashlogs normally start with a single line of meta data that we strip unconditionally. Some producers started omitting the meta data which tripped up crashlog. Be more resilient by only removing the first line when we know it really is meta data. rdar://82641662
Diffstat (limited to 'lldb/examples/python/crashlog.py')
-rwxr-xr-xlldb/examples/python/crashlog.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index e6d88a0..aec4096 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -415,8 +415,14 @@ class JSONCrashLogParser:
with open(self.path, 'r') as f:
buffer = f.read()
- # First line is meta-data.
- buffer = buffer[buffer.index('\n') + 1:]
+ # Skip the first line if it contains meta data.
+ head, _, tail = buffer.partition('\n')
+ try:
+ metadata = json.loads(head)
+ if 'app_name' in metadata and 'app_version' in metadata:
+ buffer = tail
+ except ValueError:
+ pass
try:
self.data = json.loads(buffer)