Author: Med Ismail Bennani Date: 2023-06-06T10:58:34-07:00 New Revision: 3bc0baf9d43967d828e2d311f6c0863e79158f07
URL: https://github.com/llvm/llvm-project/commit/3bc0baf9d43967d828e2d311f6c0863e79158f07 DIFF: https://github.com/llvm/llvm-project/commit/3bc0baf9d43967d828e2d311f6c0863e79158f07.diff LOG: [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 <ism...@bennani.ma> Added: Modified: lldb/examples/python/crashlog.py Removed: ################################################################################ diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index 4a14e99bea10e..36825b077c6a0 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -1346,13 +1346,7 @@ def add_module(image, target, obj_dir): print(error) -def load_crashlog_in_scripted_process(debugger, crash_log_file, options, result): - crashlog_path = os.path.expanduser(crash_log_file) - if not os.path.exists(crashlog_path): - raise InteractiveCrashLogException( - "crashlog file %s does not exist" % crashlog_path - ) - +def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result): crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse() target = lldb.SBTarget() @@ -1641,17 +1635,22 @@ def should_run_in_interactive_mode(options, ci): ci = debugger.GetCommandInterpreter() if args: - for crash_log_file in args: + for crashlog_file in args: + crashlog_path = os.path.expanduser(crashlog_file) + if not os.path.exists(crashlog_path): + raise FileNotFoundError( + "crashlog file %s does not exist" % crashlog_path + ) if should_run_in_interactive_mode(options, ci): try: load_crashlog_in_scripted_process( - debugger, crash_log_file, options, result + debugger, crashlog_path, options, result ) except InteractiveCrashLogException as e: result.SetError(str(e)) else: crash_log = CrashLogParser.create( - debugger, crash_log_file, options.verbose + debugger, crashlog_path, options.verbose ).parse() SymbolicateCrashLog(crash_log, options) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits