[Lldb-commits] [PATCH] D119755: [crashlog] Change heuristic to stripping the meta data from crashlogs
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 14 12:18:28 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG343662a02878: [crashlog] Change heuristic to stripping the meta data from crashlogs (authored by JDevlieghere).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119755/new/
https://reviews.llvm.org/D119755
Files:
lldb/examples/python/crashlog.py
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -397,7 +397,7 @@
class CrashLogParseException(Exception):
- pass
+ pass
class CrashLogParser:
@@ -414,22 +414,22 @@
self.verbose = verbose
self.crashlog = CrashLog(debugger, self.path, self.verbose)
+ def parse_json(self, buffer):
+ try:
+ return json.loads(buffer)
+ except:
+ # The first line can contain meta data. Try stripping it and try
+ # again.
+ head, _, tail = buffer.partition('\n')
+ return json.loads(tail)
+
def parse(self):
with open(self.path, 'r') as f:
buffer = f.read()
- # 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)
- except ValueError:
+ self.data = self.parse_json(buffer)
+ except:
raise CrashLogFormatException()
try:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119755.408552.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220214/c2950156/attachment.bin>
More information about the lldb-commits
mailing list