49
49
except ImportError :
50
50
# Ask the command line driver for the path to the lldb module. Copy over
51
51
# the environment so that SDKROOT is propagated to xcrun.
52
- env = os .environ .copy ()
53
- env ['LLDB_DEFAULT_PYTHON_VERSION' ] = str (sys .version_info .major )
54
52
command = ['xcrun' , 'lldb' , '-P' ] if platform .system () == 'Darwin' else ['lldb' , '-P' ]
55
53
# Extend the PYTHONPATH if the path exists and isn't already there.
56
- lldb_python_path = subprocess .check_output (command , env = env ).decode ("utf-8" ).strip ()
54
+ lldb_python_path = subprocess .check_output (command ).decode ("utf-8" ).strip ()
57
55
if os .path .exists (lldb_python_path ) and not sys .path .__contains__ (lldb_python_path ):
58
56
sys .path .append (lldb_python_path )
59
57
# Try importing LLDB again.
@@ -399,7 +397,7 @@ class CrashLogFormatException(Exception):
399
397
400
398
401
399
class CrashLogParseException (Exception ):
402
- pass
400
+ pass
403
401
404
402
405
403
class CrashLogParser :
@@ -416,22 +414,22 @@ def __init__(self, debugger, path, verbose):
416
414
self .verbose = verbose
417
415
self .crashlog = CrashLog (debugger , self .path , self .verbose )
418
416
417
+ def parse_json (self , buffer ):
418
+ try :
419
+ return json .loads (buffer )
420
+ except :
421
+ # The first line can contain meta data. Try stripping it and try
422
+ # again.
423
+ head , _ , tail = buffer .partition ('\n ' )
424
+ return json .loads (tail )
425
+
419
426
def parse (self ):
420
427
with open (self .path , 'r' ) as f :
421
428
buffer = f .read ()
422
429
423
- # Skip the first line if it contains meta data.
424
- head , _ , tail = buffer .partition ('\n ' )
425
430
try :
426
- metadata = json .loads (head )
427
- if 'app_name' in metadata and 'app_version' in metadata :
428
- buffer = tail
429
- except ValueError :
430
- pass
431
-
432
- try :
433
- self .data = json .loads (buffer )
434
- except ValueError :
431
+ self .data = self .parse_json (buffer )
432
+ except :
435
433
raise CrashLogFormatException ()
436
434
437
435
try :
0 commit comments