diff options
Diffstat (limited to 'lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp')
| -rw-r--r-- | lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 87edf7789f0d..b024854f3981 100644 --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -143,14 +143,9 @@ public: const char *GetLoggingModuleName() const { return "libsystem_trace.dylib"; } }; -using StructuredDataDarwinLogPropertiesSP = - std::shared_ptr<StructuredDataDarwinLogProperties>; - -static const StructuredDataDarwinLogPropertiesSP &GetGlobalProperties() { - static StructuredDataDarwinLogPropertiesSP g_settings_sp; - if (!g_settings_sp) - g_settings_sp = std::make_shared<StructuredDataDarwinLogProperties>(); - return g_settings_sp; +static StructuredDataDarwinLogProperties &GetGlobalProperties() { + static StructuredDataDarwinLogProperties g_settings; + return g_settings; } const char *const s_filter_attributes[] = { @@ -879,9 +874,9 @@ protected: process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName()); stream.Printf("Availability: %s\n", plugin_sp ? "available" : "unavailable"); - ConstString plugin_name = StructuredDataDarwinLog::GetStaticPluginName(); + llvm::StringRef plugin_name = StructuredDataDarwinLog::GetStaticPluginName(); const bool enabled = - plugin_sp ? plugin_sp->GetEnabled(plugin_name) : false; + plugin_sp ? plugin_sp->GetEnabled(ConstString(plugin_name)) : false; stream.Printf("Enabled: %s\n", enabled ? "true" : "false"); } @@ -1023,7 +1018,7 @@ bool RunEnableCommand(CommandInterpreter &interpreter) { StreamString command_stream; command_stream << "plugin structured-data darwin-log enable"; - auto enable_options = GetGlobalProperties()->GetAutoEnableOptions(); + auto enable_options = GetGlobalProperties().GetAutoEnableOptions(); if (!enable_options.empty()) { command_stream << ' '; command_stream << enable_options; @@ -1054,22 +1049,6 @@ void StructuredDataDarwinLog::Terminate() { PluginManager::UnregisterPlugin(&CreateInstance); } -ConstString StructuredDataDarwinLog::GetStaticPluginName() { - static ConstString s_plugin_name("darwin-log"); - return s_plugin_name; -} - -#pragma mark - -#pragma mark PluginInterface API - -// PluginInterface API - -ConstString StructuredDataDarwinLog::GetPluginName() { - return GetStaticPluginName(); -} - -uint32_t StructuredDataDarwinLog::GetPluginVersion() { return 1; } - #pragma mark - #pragma mark StructuredDataPlugin API @@ -1220,7 +1199,7 @@ Status StructuredDataDarwinLog::GetDescription( } bool StructuredDataDarwinLog::GetEnabled(ConstString type_name) const { - if (type_name == GetStaticPluginName()) + if (type_name.GetStringRef() == GetStaticPluginName()) return m_is_enabled; else return false; @@ -1237,7 +1216,7 @@ void StructuredDataDarwinLog::ModulesDidLoad(Process &process, __FUNCTION__, process.GetUniqueID()); // Check if we should enable the darwin log support on startup/attach. - if (!GetGlobalProperties()->GetEnableOnStartup() && + if (!GetGlobalProperties().GetEnableOnStartup() && !s_is_explicitly_enabled) { // We're neither auto-enabled or explicitly enabled, so we shouldn't try to // enable here. @@ -1264,7 +1243,7 @@ void StructuredDataDarwinLog::ModulesDidLoad(Process &process, // must be loaded into the debugged process before we can try to enable // logging. const char *logging_module_cstr = - GetGlobalProperties()->GetLoggingModuleName(); + GetGlobalProperties().GetLoggingModuleName(); if (!logging_module_cstr || (logging_module_cstr[0] == 0)) { // We need this. Bail. LLDB_LOGF(log, @@ -1384,7 +1363,7 @@ void StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger) { debugger, StructuredDataDarwinLogProperties::GetSettingName())) { const bool is_global_setting = true; PluginManager::CreateSettingForStructuredDataPlugin( - debugger, GetGlobalProperties()->GetValueProperties(), + debugger, GetGlobalProperties().GetValueProperties(), ConstString("Properties for the darwin-log" " plug-in."), is_global_setting); @@ -1421,7 +1400,7 @@ Status StructuredDataDarwinLog::FilterLaunchInfo(ProcessLaunchInfo &launch_info, // If DarwinLog is not enabled (either by explicit user command or via the // auto-enable option), then we have nothing to do. - if (!GetGlobalProperties()->GetEnableOnStartup() && + if (!GetGlobalProperties().GetEnableOnStartup() && !s_is_explicitly_enabled) { // Nothing to do, DarwinLog is not enabled. return error; @@ -1617,7 +1596,7 @@ void StructuredDataDarwinLog::AddInitCompletionHook(Process &process) { // Build up the module list. FileSpecList module_spec_list; auto module_file_spec = - FileSpec(GetGlobalProperties()->GetLoggingModuleName()); + FileSpec(GetGlobalProperties().GetLoggingModuleName()); module_spec_list.Append(module_file_spec); // We aren't specifying a source file set. @@ -1638,7 +1617,7 @@ void StructuredDataDarwinLog::AddInitCompletionHook(Process &process) { LLDB_LOGF(log, "StructuredDataDarwinLog::%s() failed to set " "breakpoint in module %s, function %s (process uid %u)", - __FUNCTION__, GetGlobalProperties()->GetLoggingModuleName(), + __FUNCTION__, GetGlobalProperties().GetLoggingModuleName(), func_name, process.GetUniqueID()); return; } @@ -1649,7 +1628,7 @@ void StructuredDataDarwinLog::AddInitCompletionHook(Process &process) { LLDB_LOGF(log, "StructuredDataDarwinLog::%s() breakpoint set in module %s," "function %s (process uid %u)", - __FUNCTION__, GetGlobalProperties()->GetLoggingModuleName(), + __FUNCTION__, GetGlobalProperties().GetLoggingModuleName(), func_name, process.GetUniqueID()); } |
