Skip to content

Commit 3cb3839

Browse files
committed
[lldb/crashlog] Expand crash report file path before parsing
This patch should fix a crash in the opening a crash report that was passed with a relative path. This patch expands the crash report path before parsing it and raises a `FileNotFoundError` exception if the file doesn't exist. Differential Revision: https://reviews.llvm.org/D152012 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 202adae commit 3cb3839

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lldb/examples/python/crashlog.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,13 +1179,7 @@ def add_module(image, target):
11791179
print(error)
11801180

11811181

1182-
def load_crashlog_in_scripted_process(debugger, crash_log_file, options, result):
1183-
crashlog_path = os.path.expanduser(crash_log_file)
1184-
if not os.path.exists(crashlog_path):
1185-
raise InteractiveCrashLogException(
1186-
"crashlog file %s does not exist" % crashlog_path
1187-
)
1188-
1182+
def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
11891183
crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
11901184

11911185
target = lldb.SBTarget()
@@ -1469,17 +1463,22 @@ def should_run_in_interactive_mode(options, ci):
14691463
ci = debugger.GetCommandInterpreter()
14701464

14711465
if args:
1472-
for crash_log_file in args:
1466+
for crashlog_file in args:
1467+
crashlog_path = os.path.expanduser(crashlog_file)
1468+
if not os.path.exists(crashlog_path):
1469+
raise FileNotFoundError(
1470+
"crashlog file %s does not exist" % crashlog_path
1471+
)
14731472
if should_run_in_interactive_mode(options, ci):
14741473
try:
14751474
load_crashlog_in_scripted_process(
1476-
debugger, crash_log_file, options, result
1475+
debugger, crashlog_path, options, result
14771476
)
14781477
except InteractiveCrashLogException as e:
14791478
result.SetError(str(e))
14801479
else:
14811480
crash_log = CrashLogParser.create(
1482-
debugger, crash_log_file, options.verbose
1481+
debugger, crashlog_path, options.verbose
14831482
).parse()
14841483
SymbolicateCrashLog(crash_log, options)
14851484

0 commit comments

Comments
 (0)