Skip to content

Commit fbf25b1

Browse files
author
Tom Yang
committed
Add option for enabling/disabling parallel load
Add a setting to gate the new parallel dynamic library loading feature in the next diff. I followed the example of `lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp` and `lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp` to create a scoped setting for the new feature. NOTE: this setting defaults to FALSE. Users should be able to enable the new feature as easily as adding a line to their .lldbinit file, or manually setting it in their session. ``` (lldb) apropos "POSIX dynamic" No commands found pertaining to 'POSIX dynamic'. Try 'help' to see a complete list of debugger commands. The following settings variables may relate to 'POSIX dynamic': plugin.dynamic-loader.posix-dyld.parallel-module-load -- Enable experimental loading of modules in parallel for the POSIX dynamic loader. (lldb) settings show plugin.dynamic-loader.posix-dyld.parallel-module-load plugin.dynamic-loader.posix-dyld.parallel-module-load (boolean) = false (lldb) settings set plugin.dynamic-loader.posix-dyld.parallel-module-load true (lldb) settings show plugin.dynamic-loader.posix-dyld.parallel-module-load plugin.dynamic-loader.posix-dyld.parallel-module-load (boolean) = true ```
1 parent 94c937d commit fbf25b1

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
lldb_tablegen(DynamicLoaderPOSIXDYLDProperties.inc -gen-lldb-property-defs
2+
SOURCE DynamicLoaderPOSIXDYLDProperties.td
3+
TARGET LLDBPluginDynamicLoaderPOSIXDYLDPropertiesGen)
4+
5+
lldb_tablegen(DynamicLoaderPOSIXDYLDPropertiesEnum.inc -gen-lldb-property-enum-defs
6+
SOURCE DynamicLoaderPOSIXDYLDProperties.td
7+
TARGET LLDBPluginDynamicLoaderPOSIXDYLDPropertiesEnumGen)
8+
19
add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
210
DYLDRendezvous.cpp
311
DynamicLoaderPOSIXDYLD.cpp
@@ -13,3 +21,7 @@ add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
1321
LINK_COMPONENTS
1422
Support
1523
)
24+
25+
add_dependencies(lldbPluginDynamicLoaderPosixDYLD
26+
LLDBPluginDynamicLoaderPOSIXDYLDPropertiesGen
27+
LLDBPluginDynamicLoaderPOSIXDYLDPropertiesEnumGen)

lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,56 @@ using namespace lldb_private;
3434

3535
LLDB_PLUGIN_DEFINE_ADV(DynamicLoaderPOSIXDYLD, DynamicLoaderPosixDYLD)
3636

37+
namespace {
38+
39+
#define LLDB_PROPERTIES_dynamicloaderposixdyld
40+
#include "DynamicLoaderPOSIXDYLDProperties.inc"
41+
42+
enum {
43+
#define LLDB_PROPERTIES_dynamicloaderposixdyld
44+
#include "DynamicLoaderPOSIXDYLDPropertiesEnum.inc"
45+
};
46+
47+
class PluginProperties : public Properties {
48+
public:
49+
static llvm::StringRef GetSettingName() {
50+
return DynamicLoaderPOSIXDYLD::GetPluginNameStatic();
51+
}
52+
53+
PluginProperties() : Properties() {
54+
m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
55+
m_collection_sp->Initialize(g_dynamicloaderposixdyld_properties);
56+
}
57+
58+
~PluginProperties() override = default;
59+
60+
bool GetParallelModuleLoad() const {
61+
const uint32_t idx = ePropertyParallelModuleLoad;
62+
return GetPropertyAtIndexAs<bool>(idx, true);
63+
}
64+
};
65+
66+
} // namespace
67+
68+
static PluginProperties &GetGlobalPluginProperties() {
69+
static PluginProperties g_settings;
70+
return g_settings;
71+
}
72+
3773
void DynamicLoaderPOSIXDYLD::Initialize() {
3874
PluginManager::RegisterPlugin(GetPluginNameStatic(),
39-
GetPluginDescriptionStatic(), CreateInstance);
75+
GetPluginDescriptionStatic(), CreateInstance,
76+
&DebuggerInitialize);
77+
}
78+
79+
void DynamicLoaderPOSIXDYLD::DebuggerInitialize(Debugger &debugger) {
80+
if (!PluginManager::GetSettingForDynamicLoaderPlugin(
81+
debugger, PluginProperties::GetSettingName())) {
82+
const bool is_global_setting = true;
83+
PluginManager::CreateSettingForDynamicLoaderPlugin(
84+
debugger, GetGlobalPluginProperties().GetValueProperties(),
85+
"Properties for the POSIX dynamic loader plug-in.", is_global_setting);
86+
}
4087
}
4188

4289
void DynamicLoaderPOSIXDYLD::Terminate() {}

lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader {
2828

2929
static void Initialize();
3030

31+
static void DebuggerInitialize(lldb_private::Debugger &debugger);
32+
3133
static void Terminate();
3234

3335
static llvm::StringRef GetPluginNameStatic() { return "posix-dyld"; }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
include "../../../../include/lldb/Core/PropertiesBase.td"
3+
4+
let Definition = "dynamicloaderposixdyld" in {
5+
def ParallelModuleLoad: Property<"parallel-module-load", "Boolean">,
6+
DefaultFalse,
7+
Desc<"Enable experimental loading of modules in parallel for the POSIX dynamic loader.">;
8+
}

0 commit comments

Comments
 (0)