[Lldb-commits] [PATCH] D81499: [Debugger] Use FileSystem instead of calling llvm::sys::fs::openFileForWrite directly.
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 10 18:21:12 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b2e676555c1: [Debugger] Use FileSystem instead of calling openFileForWrite directly. (authored by JDevlieghere).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81499/new/
https://reviews.llvm.org/D81499
Files:
lldb/source/Core/Debugger.cpp
Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1154,17 +1154,22 @@
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;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81499.270018.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200611/13f69b2b/attachment.bin>
More information about the lldb-commits
mailing list