Skip to content

Commit 5e0087f

Browse files
authored
Merge pull request #3942 from apple/🍒/austria/d52866e1a82d+343662a02878
🍒/austria/d52866e1a82d+343662a02878
2 parents aeb3081 + 8be53d5 commit 5e0087f

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lldb/examples/python/crashlog.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@
4949
except ImportError:
5050
# Ask the command line driver for the path to the lldb module. Copy over
5151
# 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)
5452
command = ['xcrun', 'lldb', '-P'] if platform.system() == 'Darwin' else ['lldb', '-P']
5553
# 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()
5755
if os.path.exists(lldb_python_path) and not sys.path.__contains__(lldb_python_path):
5856
sys.path.append(lldb_python_path)
5957
# Try importing LLDB again.
@@ -399,7 +397,7 @@ class CrashLogFormatException(Exception):
399397

400398

401399
class CrashLogParseException(Exception):
402-
pass
400+
pass
403401

404402

405403
class CrashLogParser:
@@ -416,22 +414,22 @@ def __init__(self, debugger, path, verbose):
416414
self.verbose = verbose
417415
self.crashlog = CrashLog(debugger, self.path, self.verbose)
418416

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+
419426
def parse(self):
420427
with open(self.path, 'r') as f:
421428
buffer = f.read()
422429

423-
# Skip the first line if it contains meta data.
424-
head, _, tail = buffer.partition('\n')
425430
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:
435433
raise CrashLogFormatException()
436434

437435
try:

0 commit comments

Comments
 (0)