forked from OSchip/llvm-project
[lldb] Remove LogHandler::Create functions (NFC)
Remove the LogHandler::Create functions. Except for the StreamHandler they were just forwarding their arguments to std::make_shared.
This commit is contained in:
parent
8eeede973c
commit
de74756571
|
@ -58,12 +58,10 @@ private:
|
||||||
|
|
||||||
class StreamLogHandler : public LogHandler {
|
class StreamLogHandler : public LogHandler {
|
||||||
public:
|
public:
|
||||||
StreamLogHandler(int fd, bool should_close, bool unbuffered);
|
StreamLogHandler(int fd, bool should_close, bool unbuffered = true);
|
||||||
|
|
||||||
void Emit(llvm::StringRef message) override;
|
void Emit(llvm::StringRef message) override;
|
||||||
|
|
||||||
static std::shared_ptr<StreamLogHandler> Create(int fd, bool unbuffered);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
llvm::raw_fd_ostream m_stream;
|
llvm::raw_fd_ostream m_stream;
|
||||||
};
|
};
|
||||||
|
@ -74,9 +72,6 @@ public:
|
||||||
|
|
||||||
void Emit(llvm::StringRef message) override;
|
void Emit(llvm::StringRef message) override;
|
||||||
|
|
||||||
static std::shared_ptr<CallbackLogHandler>
|
|
||||||
Create(lldb::LogOutputCallback callback, void *baton);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lldb::LogOutputCallback m_callback;
|
lldb::LogOutputCallback m_callback;
|
||||||
void *m_baton;
|
void *m_baton;
|
||||||
|
@ -89,8 +84,6 @@ public:
|
||||||
void Emit(llvm::StringRef message) override;
|
void Emit(llvm::StringRef message) override;
|
||||||
void Dump(llvm::raw_ostream &stream) const;
|
void Dump(llvm::raw_ostream &stream) const;
|
||||||
|
|
||||||
static std::shared_ptr<RotatingLogHandler> Create(size_t size);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t NormalizeIndex(size_t i) const;
|
size_t NormalizeIndex(size_t i) const;
|
||||||
size_t GetNumMessages() const;
|
size_t GetNumMessages() const;
|
||||||
|
|
|
@ -757,7 +757,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
|
||||||
m_forward_listener_sp(), m_clear_once() {
|
m_forward_listener_sp(), m_clear_once() {
|
||||||
m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str());
|
m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str());
|
||||||
if (log_callback)
|
if (log_callback)
|
||||||
m_callback_handler_sp = CallbackLogHandler::Create(log_callback, baton);
|
m_callback_handler_sp =
|
||||||
|
std::make_shared<CallbackLogHandler>(log_callback, baton);
|
||||||
m_command_interpreter_up->Initialize();
|
m_command_interpreter_up->Initialize();
|
||||||
// Always add our default platform to the platform list
|
// Always add our default platform to the platform list
|
||||||
PlatformSP default_platform_sp(Platform::GetHostPlatform());
|
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
|
// 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
|
// open logging streams, I just redirect everything from here on out to the
|
||||||
// callback.
|
// callback.
|
||||||
m_callback_handler_sp = CallbackLogHandler::Create(log_callback, baton);
|
m_callback_handler_sp =
|
||||||
|
std::make_shared<CallbackLogHandler>(log_callback, baton);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,
|
static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,
|
||||||
|
@ -1417,8 +1419,8 @@ bool Debugger::EnableLog(llvm::StringRef channel,
|
||||||
log_options |=
|
log_options |=
|
||||||
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
|
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
|
||||||
} else if (log_file.empty()) {
|
} else if (log_file.empty()) {
|
||||||
log_handler_sp = StreamLogHandler::Create(GetOutputFile().GetDescriptor(),
|
log_handler_sp = std::make_shared<StreamLogHandler>(
|
||||||
!should_close);
|
GetOutputFile().GetDescriptor(), !should_close);
|
||||||
} else {
|
} else {
|
||||||
auto pos = m_stream_handlers.find(log_file);
|
auto pos = m_stream_handlers.find(log_file);
|
||||||
if (pos != m_stream_handlers.end())
|
if (pos != m_stream_handlers.end())
|
||||||
|
@ -1438,8 +1440,8 @@ bool Debugger::EnableLog(llvm::StringRef channel,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_handler_sp =
|
log_handler_sp = std::make_shared<StreamLogHandler>(
|
||||||
StreamLogHandler::Create((*file)->GetDescriptor(), should_close);
|
(*file)->GetDescriptor(), should_close);
|
||||||
m_stream_handlers[log_file] = log_handler_sp;
|
m_stream_handlers[log_file] = log_handler_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,12 +347,6 @@ void StreamLogHandler::Emit(llvm::StringRef message) {
|
||||||
m_stream.flush();
|
m_stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<StreamLogHandler> StreamLogHandler::Create(int fd,
|
|
||||||
bool should_close) {
|
|
||||||
constexpr const bool unbuffered = true;
|
|
||||||
return std::make_shared<StreamLogHandler>(fd, should_close, unbuffered);
|
|
||||||
}
|
|
||||||
|
|
||||||
CallbackLogHandler::CallbackLogHandler(lldb::LogOutputCallback callback,
|
CallbackLogHandler::CallbackLogHandler(lldb::LogOutputCallback callback,
|
||||||
void *baton)
|
void *baton)
|
||||||
: m_callback(callback), m_baton(baton) {}
|
: m_callback(callback), m_baton(baton) {}
|
||||||
|
@ -361,11 +355,6 @@ void CallbackLogHandler::Emit(llvm::StringRef message) {
|
||||||
m_callback(message.data(), m_baton);
|
m_callback(message.data(), m_baton);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CallbackLogHandler>
|
|
||||||
CallbackLogHandler::Create(lldb::LogOutputCallback callback, void *baton) {
|
|
||||||
return std::make_shared<CallbackLogHandler>(callback, baton);
|
|
||||||
}
|
|
||||||
|
|
||||||
RotatingLogHandler::RotatingLogHandler(size_t size)
|
RotatingLogHandler::RotatingLogHandler(size_t size)
|
||||||
: m_messages(std::make_unique<std::string[]>(size)), m_size(size) {}
|
: m_messages(std::make_unique<std::string[]>(size)), m_size(size) {}
|
||||||
|
|
||||||
|
@ -395,7 +384,3 @@ void RotatingLogHandler::Dump(llvm::raw_ostream &stream) const {
|
||||||
}
|
}
|
||||||
stream.flush();
|
stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RotatingLogHandler> RotatingLogHandler::Create(size_t size) {
|
|
||||||
return std::make_shared<RotatingLogHandler>(size);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue