diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index b78988721b5079..3b49b5e3935077 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -242,6 +242,13 @@ class Host { static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); + /// Check if we're running in an interactive graphical session. + /// + /// \return + /// True if we're running in an interactive graphical session. False if + /// we're not or don't know. + static bool IsInteractiveGraphicSession(); + static Environment GetEnvironment(); static std::unique_ptr diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 28232eadd350be..e8c5ece9a4f6c4 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -575,6 +575,7 @@ bool Host::OpenFileInExternalEditor(const FileSpec &file_spec, return false; } +bool Host::IsInteractiveGraphicSession() { return false; } #endif std::unique_ptr Host::CreateDefaultConnection(llvm::StringRef url) { diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index ca6a408642ae80..7c490f922128dd 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -32,6 +32,8 @@ #define LauncherXPCServiceErrorTypeKey "errorType" #define LauncherXPCServiceCodeTypeKey "errorCode" +#include +#include #endif #include "llvm/Support/Host.h" @@ -406,6 +408,16 @@ repeat with the_window in (get windows)\n\ #endif // TARGET_OS_OSX } +bool Host::IsInteractiveGraphicSession() { +#if !TARGET_OS_OSX + return false; +#else + auditinfo_addr_t info; + getaudit_addr(&info, sizeof(info)); + return info.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS; +#endif +} + Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); } static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) {