Author: Raphael Isemann Date: 2020-08-17T10:43:00+02:00 New Revision: 867c347c32e27825a649af1ca5ccf22c350d2b8c
URL: https://github.com/llvm/llvm-project/commit/867c347c32e27825a649af1ca5ccf22c350d2b8c DIFF: https://github.com/llvm/llvm-project/commit/867c347c32e27825a649af1ca5ccf22c350d2b8c.diff LOG: [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't open the log file We didn't do anything with the llvm::Error we get from `Open`, so when we end up in the error case we just crash due to the llvm::Error sanity check. Also add the missing newline behind the error message so it no longer messes with the next (lldb) prompt. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D85970 Added: Modified: lldb/source/Core/Debugger.cpp lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py Removed: ################################################################################ diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 61d77d03f893..f51754e15d9b 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1164,11 +1164,11 @@ bool Debugger::EnableLog(llvm::StringRef channel, flags |= File::eOpenOptionAppend; else flags |= File::eOpenOptionTruncate; - auto file = FileSystem::Instance().Open( + llvm::Expected<FileUP> file = FileSystem::Instance().Open( FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false); if (!file) { - // FIXME: This gets garbled when called from the log command. - error_stream << "Unable to open log file: " << log_file; + error_stream << "Unable to open log file '" << log_file + << "': " << llvm::toString(file.takeError()) << "\n"; return false; } diff --git a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py index b8c7d86a7084..9a1fc699c572 100644 --- a/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py +++ b/lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py @@ -15,3 +15,8 @@ def test_enable_empty(self): def test_disable_empty(self): self.expect("log disable", error=True, substrs=["error: log disable takes a log channel and one or more log types."]) + + @no_debug_info_test + def test_enable_empty(self): + self.expect("log enable lldb all -f this/is/not/a/valid/path", error=True, + substrs=["Unable to open log file 'this/is/not/a/valid/path': No such file or directory\n"]) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits