Author: Jonas Devlieghere Date: 2020-06-10T18:13:32-07:00 New Revision: 6b2e676555c10201705a3c2e928f3d35d1fa1d4f
URL: https://github.com/llvm/llvm-project/commit/6b2e676555c10201705a3c2e928f3d35d1fa1d4f DIFF: https://github.com/llvm/llvm-project/commit/6b2e676555c10201705a3c2e928f3d35d1fa1d4f.diff LOG: [Debugger] Use FileSystem instead of calling openFileForWrite directly. This replaces the (only) call to llvm::sys::fs::openFileForWrite with FileSystem::Open. This guarantees that we include log files in the reproducers. Differential revision: https://reviews.llvm.org/D81499 Added: Modified: lldb/source/Core/Debugger.cpp Removed: ################################################################################ diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 546dc9e86e7d..5f4f1e266d81 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1154,17 +1154,22 @@ bool Debugger::EnableLog(llvm::StringRef channel, if (pos != m_log_streams.end()) log_stream_sp = pos->second.lock(); if (!log_stream_sp) { - llvm::sys::fs::OpenFlags flags = llvm::sys::fs::OF_Text; + File::OpenOptions flags = + File::eOpenOptionWrite | File::eOpenOptionCanCreate; if (log_options & LLDB_LOG_OPTION_APPEND) - flags |= llvm::sys::fs::OF_Append; - int FD; - if (std::error_code ec = llvm::sys::fs::openFileForWrite( - log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) { - error_stream << "Unable to open log file: " << ec.message(); + flags |= File::eOpenOptionAppend; + else + flags |= File::eOpenOptionTruncate; + auto 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; return false; } - log_stream_sp = - std::make_shared<llvm::raw_fd_ostream>(FD, should_close, unbuffered); + + log_stream_sp = std::make_shared<llvm::raw_fd_ostream>( + (*file)->GetDescriptor(), should_close, unbuffered); m_log_streams[log_file] = log_stream_sp; } } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits