Skip to content

[lldb] Remove ASL (Apple System Log) support from debugserver (NFC) #112260

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

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

JDevlieghere
Copy link
Member

Remove support for ASL (Apple System Log) which has been deprecated since macOS 10.12. Fixes the following warnings:

warning: 'asl_new' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
warning: 'asl_set' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
warning: 'asl_vlog' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)

Remove support for ASL (Apple System Log) which has been deprecated
since macOS 10.12. Fixes the following warnings:

  warning: 'asl_new' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
  warning: 'asl_set' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
  warning: 'asl_vlog' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Remove support for ASL (Apple System Log) which has been deprecated since macOS 10.12. Fixes the following warnings:

warning: 'asl_new' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
warning: 'asl_set' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)
warning: 'asl_vlog' is deprecated: first deprecated in macOS 10.12 - os_log(3) has replaced asl(3)


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

1 Files Affected:

  • (modified) lldb/tools/debugserver/source/debugserver.cpp (+1-38)
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index cfc9646ed2d081..f41a9e00ec9481 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -759,35 +759,6 @@ static int ConnectRemote(RNBRemote *remote, const char *host, int port,
   return 1;
 }
 
-// ASL Logging callback that can be registered with DNBLogSetLogCallback
-void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-                    va_list args) {
-  if (format == NULL)
-    return;
-  static aslmsg g_aslmsg = NULL;
-  if (g_aslmsg == NULL) {
-    g_aslmsg = ::asl_new(ASL_TYPE_MSG);
-    char asl_key_sender[PATH_MAX];
-    snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.%s-%s",
-             DEBUGSERVER_PROGRAM_NAME, DEBUGSERVER_VERSION_STR);
-    ::asl_set(g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
-  }
-
-  int asl_level;
-  if (flags & DNBLOG_FLAG_FATAL)
-    asl_level = ASL_LEVEL_CRIT;
-  else if (flags & DNBLOG_FLAG_ERROR)
-    asl_level = ASL_LEVEL_ERR;
-  else if (flags & DNBLOG_FLAG_WARNING)
-    asl_level = ASL_LEVEL_WARNING;
-  else if (flags & DNBLOG_FLAG_VERBOSE)
-    asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_INFO;
-  else
-    asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_DEBUG;
-
-  ::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
-}
-
 // FILE based Logging callback that can be registered with
 // DNBLogSetLogCallback
 void FileLogCallback(void *baton, uint32_t flags, const char *format,
@@ -948,16 +919,8 @@ int main(int argc, char *argv[]) {
   // Set up DNB logging by default. If the user passes different log flags or a
   // log file, these settings will be modified after processing the command line
   // arguments.
-  auto log_callback = OsLogger::GetLogFunction();
-  if (log_callback) {
-    // if os_log() support is available, log through that.
+  if (auto log_callback = OsLogger::GetLogFunction())
     DNBLogSetLogCallback(log_callback, nullptr);
-    DNBLog("debugserver will use os_log for internal logging.");
-  } else {
-    // Fall back to ASL support.
-    DNBLogSetLogCallback(ASLLogCallback, nullptr);
-    DNBLog("debugserver will use ASL for internal logging.");
-  }
   DNBLogSetLogMask(/*log_flags*/ 0);
 
   g_remoteSP = std::make_shared<RNBRemote>();

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

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

LGTM.

@JDevlieghere JDevlieghere merged commit 8225938 into llvm:main Oct 15, 2024
7 of 8 checks passed
@JDevlieghere JDevlieghere deleted the remove-apple-system-log branch October 15, 2024 00:06
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
…lvm#112260)

Remove support for ASL (Apple System Log) which has been deprecated
since macOS 10.12. Fixes the following warnings:

warning: 'asl_new' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
warning: 'asl_set' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
warning: 'asl_vlog' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Oct 22, 2024
…lvm#112260)

Remove support for ASL (Apple System Log) which has been deprecated
since macOS 10.12. Fixes the following warnings:

warning: 'asl_new' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
warning: 'asl_set' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)
warning: 'asl_vlog' is deprecated: first deprecated in macOS 10.12 -
os_log(3) has replaced asl(3)

(cherry picked from commit 8225938)
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.

4 participants