[Lldb-commits] [PATCH] D85970: [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't open the log file

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 17 01:43:43 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG867c347c32e2: [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85970/new/

https://reviews.llvm.org/D85970

Files:
  lldb/source/Core/Debugger.cpp
  lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py


Index: lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
===================================================================
--- lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
+++ lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
@@ -15,3 +15,8 @@
     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"])
Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1164,11 +1164,11 @@
         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;
       }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85970.285937.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200817/8040156d/attachment-0001.bin>


More information about the lldb-commits mailing list