[Lldb-commits] [lldb] 3d7161e - [lldb] Remove shared_ptr from some global Properties objects
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 8 01:43:44 PDT 2021
Author: Pavel Labath
Date: 2021-10-08T10:43:37+02:00
New Revision: 3d7161e3c14c25a60a3c03aa4c07a1dc4e35511b
URL: https://github.com/llvm/llvm-project/commit/3d7161e3c14c25a60a3c03aa4c07a1dc4e35511b
DIFF: https://github.com/llvm/llvm-project/commit/3d7161e3c14c25a60a3c03aa4c07a1dc4e35511b.diff
LOG: [lldb] Remove shared_ptr from some global Properties objects
they're unnecessary, make the code longer, and their removal actually
ensures proper initialization in multithreaded scenarios.
Added:
Modified:
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Target/Thread.h
lldb/include/lldb/lldb-forward.h
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 878739c46fa4a..9aed70188097f 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -55,7 +55,6 @@ class PlatformProperties : public Properties {
void SetDefaultModuleCacheDirectory(const FileSpec &dir_spec);
};
-typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP;
typedef llvm::SmallVector<lldb::addr_t, 6> MmapArgList;
/// \class Platform Platform.h "lldb/Target/Platform.h"
@@ -84,7 +83,7 @@ class Platform : public PluginInterface {
static void Terminate();
- static const PlatformPropertiesSP &GetGlobalPlatformProperties();
+ static PlatformProperties &GetGlobalPlatformProperties();
/// Get the native host platform plug-in.
///
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 741c9e1021cc6..5f4c1272ef28d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -106,8 +106,6 @@ class ProcessProperties : public Properties {
std::unique_ptr<ProcessExperimentalProperties> m_experimental_properties_up;
};
-typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
-
// ProcessAttachInfo
//
// Describes any information that is required to attach to a process.
@@ -501,7 +499,7 @@ class Process : public std::enable_shared_from_this<Process>,
static void SettingsTerminate();
- static const ProcessPropertiesSP &GetGlobalProperties();
+ static ProcessProperties &GetGlobalProperties();
/// Find a Process plug-in that can debug \a module using the currently
/// selected architecture.
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 4ddaf3fe2fca6..c8fc66db7ef4a 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -562,7 +562,7 @@ class Target : public std::enable_shared_from_this<Target>,
// Settings accessors
- static const lldb::TargetPropertiesSP &GetGlobalProperties();
+ static TargetProperties &GetGlobalProperties();
std::recursive_mutex &GetAPIMutex();
diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h
index 0f6b5741573ee..a48be19005153 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -57,8 +57,6 @@ class ThreadProperties : public Properties {
uint64_t GetMaxBacktraceDepth() const;
};
-typedef std::shared_ptr<ThreadProperties> ThreadPropertiesSP;
-
class Thread : public std::enable_shared_from_this<Thread>,
public ThreadProperties,
public UserID,
@@ -149,7 +147,7 @@ class Thread : public std::enable_shared_from_this<Thread>,
static void SettingsTerminate();
- static const ThreadPropertiesSP &GetGlobalProperties();
+ static ThreadProperties &GetGlobalProperties();
lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); }
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index bb6ab1fa0a843..b68e9048ce3b4 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -399,7 +399,6 @@ typedef std::shared_ptr<lldb_private::SyntheticChildrenFrontEnd>
SyntheticChildrenFrontEndSP;
typedef std::shared_ptr<lldb_private::Target> TargetSP;
typedef std::weak_ptr<lldb_private::Target> TargetWP;
-typedef std::shared_ptr<lldb_private::TargetProperties> TargetPropertiesSP;
typedef std::shared_ptr<lldb_private::Thread> ThreadSP;
typedef std::weak_ptr<lldb_private::Thread> ThreadWP;
typedef std::shared_ptr<lldb_private::ThreadCollection> ThreadCollectionSP;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index eb092cc705c4b..1ddd95726f0c9 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -723,10 +723,10 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_collection_sp->AppendProperty(
ConstString("target"),
ConstString("Settings specify to debugging targets."), true,
- Target::GetGlobalProperties()->GetValueProperties());
+ Target::GetGlobalProperties().GetValueProperties());
m_collection_sp->AppendProperty(
ConstString("platform"), ConstString("Platform settings."), true,
- Platform::GetGlobalPlatformProperties()->GetValueProperties());
+ Platform::GetGlobalPlatformProperties().GetValueProperties());
m_collection_sp->AppendProperty(
ConstString("symbols"), ConstString("Symbol lookup and cache settings."),
true, ModuleList::GetGlobalModuleListProperties().GetValueProperties());
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 5a9b7f04d0c4a..223cccf28d74b 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2113,13 +2113,6 @@ static void GetCwdInitFile(llvm::SmallVectorImpl<char> &init_file) {
FileSystem::Instance().Resolve(init_file);
}
-static LoadCWDlldbinitFile ShouldLoadCwdInitFile() {
- lldb::TargetPropertiesSP properties = Target::GetGlobalProperties();
- if (!properties)
- return eLoadCWDlldbinitFalse;
- return properties->GetLoadCWDlldbinitFile();
-}
-
void CommandInterpreter::SourceInitFile(FileSpec file,
CommandReturnObject &result) {
assert(!m_skip_lldbinit_files);
@@ -2155,7 +2148,8 @@ void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {
return;
}
- LoadCWDlldbinitFile should_load = ShouldLoadCwdInitFile();
+ LoadCWDlldbinitFile should_load =
+ Target::GetGlobalProperties().GetLoadCWDlldbinitFile();
switch (should_load) {
case eLoadCWDlldbinitFalse:
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index cf6a666c2d7e1..fd4dd1dfa3a58 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -124,14 +124,9 @@ class DynamicLoaderDarwinKernelProperties : public Properties {
}
};
-typedef std::shared_ptr<DynamicLoaderDarwinKernelProperties>
- DynamicLoaderDarwinKernelPropertiesSP;
-
-static const DynamicLoaderDarwinKernelPropertiesSP &GetGlobalProperties() {
- static DynamicLoaderDarwinKernelPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp = std::make_shared<DynamicLoaderDarwinKernelProperties>();
- return g_settings_sp;
+static DynamicLoaderDarwinKernelProperties &GetGlobalProperties() {
+ static DynamicLoaderDarwinKernelProperties g_settings;
+ return g_settings;
}
// Create an instance of this class. This function is filled into the plugin
@@ -240,7 +235,7 @@ DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr(Process *process) {
// address of the kernel if one was found, else LLDB_INVALID_ADDRESS.
lldb::addr_t
DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints(Process *process) {
- if (GetGlobalProperties()->GetScanType() == eKASLRScanNone)
+ if (GetGlobalProperties().GetScanType() == eKASLRScanNone)
return LLDB_INVALID_ADDRESS;
Status read_err;
@@ -292,8 +287,8 @@ DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints(Process *process) {
// LLDB_INVALID_ADDRESS.
lldb::addr_t
DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) {
- if (GetGlobalProperties()->GetScanType() == eKASLRScanNone ||
- GetGlobalProperties()->GetScanType() == eKASLRScanLowgloAddresses) {
+ if (GetGlobalProperties().GetScanType() == eKASLRScanNone ||
+ GetGlobalProperties().GetScanType() == eKASLRScanLowgloAddresses) {
return LLDB_INVALID_ADDRESS;
}
@@ -350,7 +345,7 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) {
// kernel if one was found, else LLDB_INVALID_ADDRESS.
lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch(
Process *process) {
- if (GetGlobalProperties()->GetScanType() != eKASLRScanExhaustiveScan) {
+ if (GetGlobalProperties().GetScanType() != eKASLRScanExhaustiveScan) {
return LLDB_INVALID_ADDRESS;
}
@@ -1177,7 +1172,7 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries(
// read the plugin.dynamic-loader.darwin-kernel.load-kexts setting -- if the
// user requested no kext loading, don't print any messages about kexts &
// don't try to read them.
- const bool load_kexts = GetGlobalProperties()->GetLoadKexts();
+ const bool load_kexts = GetGlobalProperties().GetLoadKexts();
// By default, all kexts we've loaded in the past are marked as "remove" and
// all of the kexts we just found out about from ReadKextSummaries are marked
@@ -1548,7 +1543,7 @@ void DynamicLoaderDarwinKernel::DebuggerInitialize(
debugger, DynamicLoaderDarwinKernelProperties::GetSettingName())) {
const bool is_global_setting = true;
PluginManager::CreateSettingForDynamicLoaderPlugin(
- debugger, GetGlobalProperties()->GetValueProperties(),
+ debugger, GetGlobalProperties().GetValueProperties(),
ConstString("Properties for the DynamicLoaderDarwinKernel plug-in."),
is_global_setting);
}
diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index b7e11d4a8ca46..8cd6b92a7495d 100644
--- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -105,11 +105,9 @@ class PluginProperties : public Properties {
}
};
-typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
-
-static const JITLoaderGDBPropertiesSP &GetGlobalPluginProperties() {
- static const auto g_settings_sp(std::make_shared<PluginProperties>());
- return g_settings_sp;
+static PluginProperties &GetGlobalPluginProperties() {
+ static PluginProperties g_settings;
+ return g_settings;
}
template <typename ptr_t>
@@ -160,7 +158,7 @@ void JITLoaderGDB::DebuggerInitialize(Debugger &debugger) {
debugger, PluginProperties::GetSettingName())) {
const bool is_global_setting = true;
PluginManager::CreateSettingForJITLoaderPlugin(
- debugger, GetGlobalPluginProperties()->GetValueProperties(),
+ debugger, GetGlobalPluginProperties().GetValueProperties(),
ConstString("Properties for the JIT LoaderGDB plug-in."),
is_global_setting);
}
@@ -412,7 +410,7 @@ lldb_private::ConstString JITLoaderGDB::GetPluginNameStatic() {
JITLoaderSP JITLoaderGDB::CreateInstance(Process *process, bool force) {
JITLoaderSP jit_loader_sp;
bool enable;
- switch (GetGlobalPluginProperties()->GetEnable()) {
+ switch (GetGlobalPluginProperties().GetEnable()) {
case EnableJITLoaderGDB::eEnableJITLoaderGDBOn:
enable = true;
break;
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index ee8850f8cb5e4..4bc95ff8425d7 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -209,14 +209,9 @@ class PlatformDarwinKernelProperties : public Properties {
}
};
-typedef std::shared_ptr<PlatformDarwinKernelProperties>
- PlatformDarwinKernelPropertiesSP;
-
-static const PlatformDarwinKernelPropertiesSP &GetGlobalProperties() {
- static PlatformDarwinKernelPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp = std::make_shared<PlatformDarwinKernelProperties>();
- return g_settings_sp;
+static PlatformDarwinKernelProperties &GetGlobalProperties() {
+ static PlatformDarwinKernelProperties g_settings;
+ return g_settings;
}
void PlatformDarwinKernel::DebuggerInitialize(
@@ -225,7 +220,7 @@ void PlatformDarwinKernel::DebuggerInitialize(
debugger, PlatformDarwinKernelProperties::GetSettingName())) {
const bool is_global_setting = true;
PluginManager::CreateSettingForPlatformPlugin(
- debugger, GetGlobalProperties()->GetValueProperties(),
+ debugger, GetGlobalProperties().GetValueProperties(),
ConstString("Properties for the PlatformDarwinKernel plug-in."),
is_global_setting);
}
@@ -377,7 +372,7 @@ void PlatformDarwinKernel::CollectKextAndKernelDirectories() {
}
void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() {
- FileSpecList user_dirs(GetGlobalProperties()->GetKextDirectories());
+ FileSpecList user_dirs(GetGlobalProperties().GetKextDirectories());
std::vector<FileSpec> possible_sdk_dirs;
const uint32_t user_dirs_count = user_dirs.GetSize();
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index a6c89e0199734..749d7446b6464 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -82,13 +82,9 @@ class PluginProperties : public Properties {
}
};
-typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
-
-static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() {
- static ProcessKDPPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp = std::make_shared<PluginProperties>();
- return g_settings_sp;
+static PluginProperties &GetGlobalPluginProperties() {
+ static PluginProperties g_settings;
+ return g_settings;
}
} // anonymous namespace end
@@ -161,7 +157,7 @@ ProcessKDP::ProcessKDP(TargetSP target_sp, ListenerSP listener_sp)
m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue,
"async thread continue");
const uint64_t timeout_seconds =
- GetGlobalPluginProperties()->GetPacketTimeout();
+ GetGlobalPluginProperties().GetPacketTimeout();
if (timeout_seconds > 0)
m_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
}
@@ -725,7 +721,7 @@ void ProcessKDP::DebuggerInitialize(lldb_private::Debugger &debugger) {
debugger, PluginProperties::GetSettingName())) {
const bool is_global_setting = true;
PluginManager::CreateSettingForProcessPlugin(
- debugger, GetGlobalPluginProperties()->GetValueProperties(),
+ debugger, GetGlobalPluginProperties().GetValueProperties(),
ConstString("Properties for the kdp-remote process plug-in."),
is_global_setting);
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 9f5811baa2699..0f34cb42e9865 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -165,13 +165,9 @@ class PluginProperties : public Properties {
}
};
-typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
-
-static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() {
- static ProcessKDPPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp = std::make_shared<PluginProperties>();
- return g_settings_sp;
+static PluginProperties &GetGlobalPluginProperties() {
+ static PluginProperties g_settings;
+ return g_settings;
}
} // namespace
@@ -213,7 +209,7 @@ ProcessGDBRemote::CreateInstance(lldb::TargetSP target_sp,
}
std::chrono::seconds ProcessGDBRemote::GetPacketTimeout() {
- return std::chrono::seconds(GetGlobalPluginProperties()->GetPacketTimeout());
+ return std::chrono::seconds(GetGlobalPluginProperties().GetPacketTimeout());
}
bool ProcessGDBRemote::CanDebug(lldb::TargetSP target_sp,
@@ -302,12 +298,12 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
}
const uint64_t timeout_seconds =
- GetGlobalPluginProperties()->GetPacketTimeout();
+ GetGlobalPluginProperties().GetPacketTimeout();
if (timeout_seconds > 0)
m_gdb_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
m_use_g_packet_for_reading =
- GetGlobalPluginProperties()->GetUseGPacketForReading();
+ GetGlobalPluginProperties().GetUseGPacketForReading();
}
// Destructor
@@ -401,7 +397,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
// timeout is and can see it.
const auto host_packet_timeout = m_gdb_comm.GetHostDefaultPacketTimeout();
if (host_packet_timeout > std::chrono::seconds(0)) {
- GetGlobalPluginProperties()->SetPacketTimeout(host_packet_timeout.count());
+ GetGlobalPluginProperties().SetPacketTimeout(host_packet_timeout.count());
}
// Register info search order:
@@ -411,7 +407,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
// 3 - Fall back on the qRegisterInfo packets.
FileSpec target_definition_fspec =
- GetGlobalPluginProperties()->GetTargetDefinitionFile();
+ GetGlobalPluginProperties().GetTargetDefinitionFile();
if (!FileSystem::Instance().Exists(target_definition_fspec)) {
// If the filename doesn't exist, it may be a ~ not having been expanded -
// try to resolve it.
@@ -3528,7 +3524,7 @@ void ProcessGDBRemote::DebuggerInitialize(Debugger &debugger) {
debugger, PluginProperties::GetSettingName())) {
const bool is_global_setting = true;
PluginManager::CreateSettingForProcessPlugin(
- debugger, GetGlobalPluginProperties()->GetValueProperties(),
+ debugger, GetGlobalPluginProperties().GetValueProperties(),
ConstString("Properties for the gdb-remote process plug-in."),
is_global_setting);
}
@@ -4564,7 +4560,7 @@ llvm::Expected<LoadedModuleInfoList> ProcessGDBRemote::GetLoadedModuleList() {
LoadedModuleInfoList list;
GDBRemoteCommunicationClient &comm = m_gdb_comm;
- bool can_use_svr4 = GetGlobalPluginProperties()->GetUseSVR4();
+ bool can_use_svr4 = GetGlobalPluginProperties().GetUseSVR4();
// check that we have extended feature read support
if (can_use_svr4 && comm.GetQXferLibrariesSVR4ReadSupported()) {
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 343a1092f7d53..5339c5bd702ee 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -143,14 +143,9 @@ class StructuredDataDarwinLogProperties : public Properties {
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[] = {
@@ -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;
@@ -1235,7 +1230,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.
@@ -1262,7 +1257,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,
@@ -1382,7 +1377,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);
@@ -1419,7 +1414,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;
@@ -1615,7 +1610,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.
@@ -1636,7 +1631,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;
}
@@ -1647,7 +1642,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());
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index b1025650ced24..6085027abcc46 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -145,11 +145,9 @@ class PluginProperties : public Properties {
}
};
-typedef std::shared_ptr<PluginProperties> SymbolFileDWARFPropertiesSP;
-
-static const SymbolFileDWARFPropertiesSP &GetGlobalPluginProperties() {
- static const auto g_settings_sp(std::make_shared<PluginProperties>());
- return g_settings_sp;
+static PluginProperties &GetGlobalPluginProperties() {
+ static PluginProperties g_settings;
+ return g_settings;
}
} // namespace
@@ -267,7 +265,7 @@ void SymbolFileDWARF::DebuggerInitialize(Debugger &debugger) {
debugger, PluginProperties::GetSettingName())) {
const bool is_global_setting = true;
PluginManager::CreateSettingForSymbolFilePlugin(
- debugger, GetGlobalPluginProperties()->GetValueProperties(),
+ debugger, GetGlobalPluginProperties().GetValueProperties(),
ConstString("Properties for the dwarf symbol-file plug-in."),
is_global_setting);
}
@@ -470,7 +468,7 @@ SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) {
void SymbolFileDWARF::InitializeObject() {
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- if (!GetGlobalPluginProperties()->IgnoreFileIndexes()) {
+ if (!GetGlobalPluginProperties().IgnoreFileIndexes()) {
StreamString module_desc;
GetObjectFile()->GetModule()->GetDescription(module_desc.AsRawOstream(),
lldb::eDescriptionLevelBrief);
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 7f762a68710e8..7a40446261f73 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -155,9 +155,9 @@ void Platform::Terminate() {
}
}
-const PlatformPropertiesSP &Platform::GetGlobalPlatformProperties() {
- static const auto g_settings_sp(std::make_shared<PlatformProperties>());
- return g_settings_sp;
+PlatformProperties &Platform::GetGlobalPlatformProperties() {
+ static PlatformProperties g_settings;
+ return g_settings;
}
void Platform::SetHostPlatform(const lldb::PlatformSP &platform_sp) {
@@ -1606,8 +1606,8 @@ Status Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
bool Platform::GetCachedSharedModule(const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
bool *did_create_ptr) {
- if (IsHost() || !GetGlobalPlatformProperties()->GetUseModuleCache() ||
- !GetGlobalPlatformProperties()->GetModuleCacheDirectory())
+ if (IsHost() || !GetGlobalPlatformProperties().GetUseModuleCache() ||
+ !GetGlobalPlatformProperties().GetModuleCacheDirectory())
return false;
Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
@@ -1691,7 +1691,7 @@ Status Platform::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
}
FileSpec Platform::GetModuleCacheRoot() {
- auto dir_spec = GetGlobalPlatformProperties()->GetModuleCacheDirectory();
+ auto dir_spec = GetGlobalPlatformProperties().GetModuleCacheDirectory();
dir_spec.AppendPathComponent(GetName().AsCString());
return dir_spec;
}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 59fea136c12d0..c4f047a4caac1 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -166,10 +166,10 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
m_collection_sp->Initialize(g_process_properties);
m_collection_sp->AppendProperty(
ConstString("thread"), ConstString("Settings specific to threads."),
- true, Thread::GetGlobalProperties()->GetValueProperties());
+ true, Thread::GetGlobalProperties().GetValueProperties());
} else {
m_collection_sp =
- OptionValueProperties::CreateLocalCopy(*Process::GetGlobalProperties());
+ OptionValueProperties::CreateLocalCopy(Process::GetGlobalProperties());
m_collection_sp->SetValueChangedCallback(
ePropertyPythonOSPluginPath,
[this] { m_process->LoadOperatingSystemPlugin(true); });
@@ -500,12 +500,12 @@ Process::~Process() {
m_thread_list.Clear();
}
-const ProcessPropertiesSP &Process::GetGlobalProperties() {
+ProcessProperties &Process::GetGlobalProperties() {
// NOTE: intentional leak so we don't crash if global destructor chain gets
// called as other threads still use the result of this function
- static ProcessPropertiesSP *g_settings_sp_ptr =
- new ProcessPropertiesSP(new ProcessProperties(nullptr));
- return *g_settings_sp_ptr;
+ static ProcessProperties *g_settings_ptr =
+ new ProcessProperties(nullptr);
+ return *g_settings_ptr;
}
void Process::Finalize() {
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 801906d020ce9..995527e2e8da1 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2345,35 +2345,22 @@ void Target::SettingsInitialize() { Process::SettingsInitialize(); }
void Target::SettingsTerminate() { Process::SettingsTerminate(); }
FileSpecList Target::GetDefaultExecutableSearchPaths() {
- TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
- if (properties_sp)
- return properties_sp->GetExecutableSearchPaths();
- return FileSpecList();
+ return Target::GetGlobalProperties().GetExecutableSearchPaths();
}
FileSpecList Target::GetDefaultDebugFileSearchPaths() {
- TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
- if (properties_sp)
- return properties_sp->GetDebugFileSearchPaths();
- return FileSpecList();
+ return Target::GetGlobalProperties().GetDebugFileSearchPaths();
}
ArchSpec Target::GetDefaultArchitecture() {
- TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
- if (properties_sp)
- return properties_sp->GetDefaultArchitecture();
- return ArchSpec();
+ return Target::GetGlobalProperties().GetDefaultArchitecture();
}
void Target::SetDefaultArchitecture(const ArchSpec &arch) {
- TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
- if (properties_sp) {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET),
- "Target::SetDefaultArchitecture setting target's "
- "default architecture to {0} ({1})",
- arch.GetArchitectureName(), arch.GetTriple().getTriple());
- return properties_sp->SetDefaultArchitecture(arch);
- }
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET),
+ "setting target's default architecture to {0} ({1})",
+ arch.GetArchitectureName(), arch.GetTriple().getTriple());
+ Target::GetGlobalProperties().SetDefaultArchitecture(arch);
}
Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
@@ -2768,12 +2755,12 @@ bool Target::RunStopHooks() {
return false;
}
-const TargetPropertiesSP &Target::GetGlobalProperties() {
+TargetProperties &Target::GetGlobalProperties() {
// NOTE: intentional leak so we don't crash if global destructor chain gets
// called as other threads still use the result of this function
- static TargetPropertiesSP *g_settings_sp_ptr =
- new TargetPropertiesSP(new TargetProperties(nullptr));
- return *g_settings_sp_ptr;
+ static TargetProperties *g_settings_ptr =
+ new TargetProperties(nullptr);
+ return *g_settings_ptr;
}
Status Target::Install(ProcessLaunchInfo *launch_info) {
@@ -2936,17 +2923,9 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
launch_info.GetFlags().Set(eLaunchFlagDebug);
if (launch_info.IsScriptedProcess()) {
- TargetPropertiesSP properties_sp = GetGlobalProperties();
-
- if (!properties_sp) {
- LLDB_LOGF(log, "Target::%s Couldn't fetch target global properties.",
- __FUNCTION__);
- return error;
- }
-
// Only copy scripted process launch options.
- ProcessLaunchInfo &default_launch_info =
- const_cast<ProcessLaunchInfo &>(properties_sp->GetProcessLaunchInfo());
+ ProcessLaunchInfo &default_launch_info = const_cast<ProcessLaunchInfo &>(
+ GetGlobalProperties().GetProcessLaunchInfo());
default_launch_info.SetProcessPluginName("ScriptedProcess");
default_launch_info.SetScriptedProcessClassName(
@@ -3731,7 +3710,7 @@ TargetProperties::TargetProperties(Target *target)
: Properties(), m_launch_info(), m_target(target) {
if (target) {
m_collection_sp =
- OptionValueProperties::CreateLocalCopy(*Target::GetGlobalProperties());
+ OptionValueProperties::CreateLocalCopy(Target::GetGlobalProperties());
// Set callbacks to update launch_info whenever "settins set" updated any
// of these properties
@@ -3781,7 +3760,7 @@ TargetProperties::TargetProperties(Target *target)
true, m_experimental_properties_up->GetValueProperties());
m_collection_sp->AppendProperty(
ConstString("process"), ConstString("Settings specific to processes."),
- true, Process::GetGlobalProperties()->GetValueProperties());
+ true, Process::GetGlobalProperties().GetValueProperties());
}
}
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index b423f1b5f1fe2..da6a444e98753 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -55,12 +55,11 @@
using namespace lldb;
using namespace lldb_private;
-const ThreadPropertiesSP &Thread::GetGlobalProperties() {
+ThreadProperties &Thread::GetGlobalProperties() {
// NOTE: intentional leak so we don't crash if global destructor chain gets
// called as other threads still use the result of this function
- static ThreadPropertiesSP *g_settings_sp_ptr =
- new ThreadPropertiesSP(new ThreadProperties(true));
- return *g_settings_sp_ptr;
+ static ThreadProperties *g_settings_ptr = new ThreadProperties(true);
+ return *g_settings_ptr;
}
#define LLDB_PROPERTIES_thread
@@ -103,7 +102,7 @@ ThreadProperties::ThreadProperties(bool is_global) : Properties() {
m_collection_sp->Initialize(g_thread_properties);
} else
m_collection_sp =
- OptionValueProperties::CreateLocalCopy(*Thread::GetGlobalProperties());
+ OptionValueProperties::CreateLocalCopy(Thread::GetGlobalProperties());
}
ThreadProperties::~ThreadProperties() = default;
More information about the lldb-commits
mailing list