diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h index 0beb97b4891f..806eb390773b 100644 --- a/lldb/include/lldb/Utility/Log.h +++ b/lldb/include/lldb/Utility/Log.h @@ -58,12 +58,10 @@ private: class StreamLogHandler : public LogHandler { public: - StreamLogHandler(int fd, bool should_close, bool unbuffered); + StreamLogHandler(int fd, bool should_close, bool unbuffered = true); void Emit(llvm::StringRef message) override; - static std::shared_ptr Create(int fd, bool unbuffered); - private: llvm::raw_fd_ostream m_stream; }; @@ -74,9 +72,6 @@ public: void Emit(llvm::StringRef message) override; - static std::shared_ptr - Create(lldb::LogOutputCallback callback, void *baton); - private: lldb::LogOutputCallback m_callback; void *m_baton; @@ -89,8 +84,6 @@ public: void Emit(llvm::StringRef message) override; void Dump(llvm::raw_ostream &stream) const; - static std::shared_ptr Create(size_t size); - private: size_t NormalizeIndex(size_t i) const; size_t GetNumMessages() const; diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 08d95c0ea654..c6f1cbe581da 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -757,7 +757,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) m_forward_listener_sp(), m_clear_once() { m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str()); if (log_callback) - m_callback_handler_sp = CallbackLogHandler::Create(log_callback, baton); + m_callback_handler_sp = + std::make_shared(log_callback, baton); m_command_interpreter_up->Initialize(); // Always add our default platform to the platform list PlatformSP default_platform_sp(Platform::GetHostPlatform()); @@ -1290,7 +1291,8 @@ void Debugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, // For simplicity's sake, I am not going to deal with how to close down any // open logging streams, I just redirect everything from here on out to the // callback. - m_callback_handler_sp = CallbackLogHandler::Create(log_callback, baton); + m_callback_handler_sp = + std::make_shared(log_callback, baton); } static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id, @@ -1417,8 +1419,8 @@ bool Debugger::EnableLog(llvm::StringRef channel, log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; } else if (log_file.empty()) { - log_handler_sp = StreamLogHandler::Create(GetOutputFile().GetDescriptor(), - !should_close); + log_handler_sp = std::make_shared( + GetOutputFile().GetDescriptor(), !should_close); } else { auto pos = m_stream_handlers.find(log_file); if (pos != m_stream_handlers.end()) @@ -1438,8 +1440,8 @@ bool Debugger::EnableLog(llvm::StringRef channel, return false; } - log_handler_sp = - StreamLogHandler::Create((*file)->GetDescriptor(), should_close); + log_handler_sp = std::make_shared( + (*file)->GetDescriptor(), should_close); m_stream_handlers[log_file] = log_handler_sp; } } diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp index 62547154dbee..6649dc0b9f73 100644 --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -347,12 +347,6 @@ void StreamLogHandler::Emit(llvm::StringRef message) { m_stream.flush(); } -std::shared_ptr StreamLogHandler::Create(int fd, - bool should_close) { - constexpr const bool unbuffered = true; - return std::make_shared(fd, should_close, unbuffered); -} - CallbackLogHandler::CallbackLogHandler(lldb::LogOutputCallback callback, void *baton) : m_callback(callback), m_baton(baton) {} @@ -361,11 +355,6 @@ void CallbackLogHandler::Emit(llvm::StringRef message) { m_callback(message.data(), m_baton); } -std::shared_ptr -CallbackLogHandler::Create(lldb::LogOutputCallback callback, void *baton) { - return std::make_shared(callback, baton); -} - RotatingLogHandler::RotatingLogHandler(size_t size) : m_messages(std::make_unique(size)), m_size(size) {} @@ -395,7 +384,3 @@ void RotatingLogHandler::Dump(llvm::raw_ostream &stream) const { } stream.flush(); } - -std::shared_ptr RotatingLogHandler::Create(size_t size) { - return std::make_shared(size); -}