Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Always emit diagnostic events to the system log #90913

Merged
merged 1 commit into from
May 3, 2024

Conversation

JDevlieghere
Copy link
Member

Always emit diagnostic events to the system log so that they end up in the sysdiagnose on Darwin.

@llvmbot
Copy link
Collaborator

llvmbot commented May 2, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Always emit diagnostic events to the system log so that they end up in the sysdiagnose on Darwin.


Full diff: https://github.com/llvm/llvm-project/pull/90913.diff

1 Files Affected:

  • (modified) lldb/source/Core/Debugger.cpp (+15)
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index cac4642873b772..c5ab99fac75d27 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1512,7 +1512,22 @@ void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type,
                                     std::string message,
                                     std::optional<lldb::user_id_t> debugger_id,
                                     std::once_flag *once) {
+  auto GetSystemLogLevel = [](DiagnosticEventData::Type type) {
+    switch (type) {
+    case DiagnosticEventData::Type::Info:
+      return Host::eSystemLogInfo;
+    case DiagnosticEventData::Type::Warning:
+      return Host::eSystemLogWarning;
+    case DiagnosticEventData::Type::Error:
+      return Host::eSystemLogError;
+    }
+    llvm_unreachable("All cases handled above!");
+  };
+
   auto ReportDiagnosticLambda = [&]() {
+    // Always log diagnostics to the system log.
+    Host::SystemLog(GetSystemLogLevel(type), message);
+
     // The diagnostic subsystem is optional but we still want to broadcast
     // events when it's disabled.
     if (Diagnostics::Enabled())

Copy link
Member

@medismailben medismailben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with comment

@@ -1512,7 +1512,22 @@ void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
std::optional<lldb::user_id_t> debugger_id,
std::once_flag *once) {
auto GetSystemLogLevel = [](DiagnosticEventData::Type type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This could be constexpr I think

Always emit diagnostic events to the system log so that they end up in
the sysdiagnose on Darwin.
@JDevlieghere JDevlieghere force-pushed the log-diagnostics-to-system-log branch from 4589130 to 7ed4008 Compare May 3, 2024 16:41
@JDevlieghere JDevlieghere merged commit f9d91fb into llvm:main May 3, 2024
4 checks passed
@JDevlieghere JDevlieghere deleted the log-diagnostics-to-system-log branch May 3, 2024 16:45
JDevlieghere added a commit to apple/llvm-project that referenced this pull request May 3, 2024
Always emit diagnostic events to the system log so that they end up in
the sysdiagnose on Darwin.

(cherry picked from commit f9d91fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants