Skip to content

Commit 735dd1f

Browse files
committed
Add support for enable/disable instrumentation-runtime plugins
1 parent 29aa20d commit 735dd1f

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

lldb/include/lldb/Core/PluginManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ class PluginManager {
544544
static InstrumentationRuntimeCreateInstance
545545
GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
546546

547+
static std::vector<RegisteredPluginInfo>
548+
GetInstrumentationRuntimePluginInfo();
549+
550+
static bool SetInstrumentationRuntimePluginEnabled(llvm::StringRef name,
551+
bool enabled);
552+
547553
// TypeSystem
548554
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
549555
TypeSystemCreateInstance create_callback,

lldb/source/Core/PluginManager.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ llvm::ArrayRef<PluginNamespace> PluginManager::GetPluginNamespaces() {
186186
// over time.
187187
static PluginNamespace PluginNamespaces[] = {
188188
{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
189-
PluginManager::SetSystemRuntimePluginEnabled}};
189+
PluginManager::SetSystemRuntimePluginEnabled},
190+
{"instrumentation-runtime",
191+
PluginManager::GetInstrumentationRuntimePluginInfo,
192+
PluginManager::SetInstrumentationRuntimePluginEnabled}};
190193

191194
return PluginNamespaces;
192195
}
@@ -1546,6 +1549,16 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx) {
15461549
return GetInstrumentationRuntimeInstances().GetCallbackAtIndex(idx);
15471550
}
15481551

1552+
std::vector<RegisteredPluginInfo>
1553+
PluginManager::GetInstrumentationRuntimePluginInfo() {
1554+
return GetInstrumentationRuntimeInstances().GetPluginInfoForAllInstances();
1555+
}
1556+
1557+
bool PluginManager::SetInstrumentationRuntimePluginEnabled(llvm::StringRef name,
1558+
bool enable) {
1559+
return GetInstrumentationRuntimeInstances().SetInstanceEnabled(name, enable);
1560+
}
1561+
15491562
#pragma mark TypeSystem
15501563

15511564
struct TypeSystemInstance : public PluginInstance<TypeSystemCreateInstance> {

lldb/test/Shell/Commands/command-plugin-enable+disable.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ plugin enable system-runtime
4747
# CHECK: system-runtime
4848
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries
4949

50+
# Test plugin enable/disable for instrumentation plugin works.
51+
plugin enable instrumentation-runtime
52+
# CHECK-LABEL: plugin enable instrumentation-runtime
53+
# CHECK: instrumentation-runtime
54+
# CHECK: [+] AddressSanitizer
55+
plugin disable instrumentation-runtime
56+
# CHECK-LABEL: plugin disable instrumentation-runtime
57+
# CHECK: instrumentation-runtime
58+
# CHECK: [-] AddressSanitizer
59+
5060
# Test plugin enable/disable for unknown plugin returns an error.
5161
# RUN: %lldb -o "plugin enable some-plugin-that-does-not-exist" 2>&1 | FileCheck %s --check-prefix=ERROR_PLUGIN_NOT_FOUND
5262
# RUN: %lldb -o "plugin disable some-plugin-that-does-not-exist" 2>&1 | FileCheck %s --check-prefix=ERROR_PLUGIN_NOT_FOUND

lldb/test/Shell/Commands/command-plugin-list.test

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ plugin list
1212
# CHECK-LABEL: plugin list
1313
# CHECK: system-runtime
1414
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries
15+
# CHECK: instrumentation-runtime
16+
# CHECK: [+] AddressSanitizer AddressSanitizer instrumentation runtime plugin.
1517

1618
# Test plugin list works with fully qualified name.
1719
plugin list system-runtime.systemruntime-macosx
@@ -29,14 +31,23 @@ plugin list system-runtime
2931
plugin list --json
3032
# CHECK-LABEL plugin list --json
3133
# CHECK: {
34+
# CHECK-DAG: "system-runtime":
35+
# CHECK-DAG: "instrumentation-runtime":
36+
# CHECK: }
37+
38+
# Test json output for plugin list with a namespace
39+
plugin list system-runtime --json
40+
# CHECK-LABEL plugin list --json
41+
# CHECK: {
3242
# CHECK: "system-runtime": [
3343
# CHECK: {
34-
# CHECK-DAG: "enabled": true,
44+
# CHECK-DAG: "enabled": true
3545
# CHECK-DAG: "name": "systemruntime-macosx"
3646
# CHECK: }
3747
# CHECK: ]
3848
# CHECK: }
3949

50+
4051
# Test plugin list does not match a plugin name by substring.
4152
# RUN: %lldb -o "plugin list macosx" 2>&1 | FileCheck %s --check-prefix=ERROR_PLUGIN_NOT_FOUND
4253

0 commit comments

Comments
 (0)