Index: lldb/include/lldb/Utility/Log.h =================================================================== --- lldb/include/lldb/Utility/Log.h +++ lldb/include/lldb/Utility/Log.h @@ -96,6 +96,14 @@ size_t m_total_count = 0; }; +#if defined(__APPLE__) +class OSLogLogHandler : public LogHandler { +public: + OSLogLogHandler(); + void Emit(llvm::StringRef message) override; +}; +#endif + class Log final { public: /// The underlying type of all log channel enums. Declare them as: Index: lldb/source/Utility/Log.cpp =================================================================== --- lldb/source/Utility/Log.cpp +++ lldb/source/Utility/Log.cpp @@ -32,6 +32,12 @@ #include #endif +#if defined(__APPLE__) +#include +static os_log_t g_os_log; +static std::once_flag g_os_log_once; +#endif + using namespace lldb_private; llvm::ManagedStatic Log::g_channel_map; @@ -389,3 +395,15 @@ } stream.flush(); } + +#if defined(__APPLE__) +OSLogLogHandler::OSLogLogHandler() { + std::call_once(g_os_log_once, []() { + g_os_log = os_log_create("com.apple.dt.lldb", "lldb"); + }); +} + +void OSLogLogHandler::Emit(llvm::StringRef message) { + os_log_with_type(g_os_log, OS_LOG_TYPE_DEFAULT, "%{public}s", message.data()); +} +#endif