From 69789dd4787b8b3c588a296ac3400309c16717e3 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 14 Oct 2024 07:02:02 -0700 Subject: [PATCH 1/2] [lldb] Make the system log a NOOP on Windows (#112052) Windows doesn't have a built-in system log. Previously we got away with writing to stdout and stderr because it was used only sporadically. As we're trying to make the system log more useful on the other platforms, the increased use become a concern. Make it a NOOP until someone figures out a reasonable alternative. (cherry picked from commit 3dedcab6d9b660a690d8fe5ddad3d43276a82708) --- lldb/source/Host/common/Host.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 01fada13fae53..bb39595fdb8d0 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -111,17 +111,7 @@ void Host::SystemLog(Severity severity, llvm::StringRef message) { syslog(level, "%s", message.data()); } #else -void Host::SystemLog(Severity severity, llvm::StringRef message) { - switch (severity) { - case lldb::eSeverityInfo: - case lldb::eSeverityWarning: - llvm::outs() << message; - break; - case lldb::eSeverityError: - llvm::errs() << message; - break; - } -} +void Host::SystemLog(Severity severity, llvm::StringRef message) {} #endif #endif From ca48db9c20eba8a23819a68779382935b79b041c Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 15 Oct 2024 16:07:17 -0700 Subject: [PATCH 2/2] [lldb] Make the system log a NOOP on non-Darwin platforms As discussed in #111911, we have consensus that as it stands, the system log is only meaningful on Darwin and that by default it should be a NOOP on other platforms. (cherry picked from commit cc13d4fb4a208363ed1dab29829cd200a3e39c52) --- lldb/source/Host/common/Host.cpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index bb39595fdb8d0..fd5cc1d17da25 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -89,31 +89,12 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) -#if !defined(_WIN32) -#include -void Host::SystemLog(Severity severity, llvm::StringRef message) { - static llvm::once_flag g_openlog_once; - llvm::call_once(g_openlog_once, [] { - openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); - }); - int level = LOG_DEBUG; - switch (severity) { - case lldb::eSeverityInfo: - level = LOG_INFO; - break; - case lldb::eSeverityWarning: - level = LOG_WARNING; - break; - case lldb::eSeverityError: - level = LOG_ERR; - break; - } - syslog(level, "%s", message.data()); -} -#else +// The system log is currently only meaningful on Darwin, where this means +// os_log. The meaning of a "system log" isn't as clear on other platforms, and +// therefore we don't providate a default implementation. Vendors are free to +// to implement this function if they have a use for it. void Host::SystemLog(Severity severity, llvm::StringRef message) {} #endif -#endif #if !defined(__APPLE__) && !defined(_WIN32) static thread_result_t