LLDB mainline
PluginManager.cpp
Go to the documentation of this file.
1//===-- PluginManager.cpp -------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
12#include "lldb/Core/Debugger.h"
14#include "lldb/Host/HostInfo.h"
18#include "lldb/Target/Process.h"
20#include "lldb/Utility/Status.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/SmallSet.h"
24#include "llvm/ADT/StringRef.h"
25#include "llvm/ADT/Twine.h"
26#include "llvm/Support/DynamicLibrary.h"
27#include "llvm/Support/ErrorExtras.h"
28#include "llvm/Support/FileSystem.h"
29#include "llvm/Support/raw_ostream.h"
30#include <cassert>
31#include <memory>
32#include <mutex>
33#include <string>
34#include <utility>
35#if defined(_WIN32)
37#endif
38
39using namespace lldb;
40using namespace lldb_private;
41
43typedef void (*PluginTermCallback)();
44
45struct PluginInfo {
46 PluginInfo() = default;
47
48 PluginInfo(const PluginInfo &) = delete;
49 PluginInfo &operator=(const PluginInfo &) = delete;
50
52 : library(std::move(other.library)),
54 std::exchange(other.plugin_init_callback, nullptr)),
56 std::exchange(other.plugin_term_callback, nullptr)) {}
57
59 library = std::move(other.library);
60 plugin_init_callback = std::exchange(other.plugin_init_callback, nullptr);
61 plugin_term_callback = std::exchange(other.plugin_term_callback, nullptr);
62 return *this;
63 }
64
66 if (!library.isValid())
67 return;
69 return;
71 }
72
73 static llvm::Expected<PluginInfo> Create(const FileSpec &path);
74
75private:
76 llvm::sys::DynamicLibrary library;
79};
80
81typedef llvm::SmallDenseMap<FileSpec, PluginInfo> DynamicPluginMap;
82
83namespace {
84enum class PluginLifecycle { Uninitialized, Initialized, Terminated };
85
86struct PluginRegistry {
87 std::recursive_mutex mutex;
89
90 void Initialize() {
91 std::lock_guard<std::recursive_mutex> guard(mutex);
92 lifecycle = PluginLifecycle::Initialized;
93 }
94
95 void Terminate() {
96 std::lock_guard<std::recursive_mutex> guard(mutex);
97 lifecycle = PluginLifecycle::Terminated;
98 map.clear();
99 }
100
101 // Only after Terminate() is a leftover PluginInstances registration a bug;
102 // exiting in any other state (e.g. `import lldb`, which never calls
103 // Terminate()) is supported and leaves plugins registered.
104 bool IsTerminated() const { return lifecycle == PluginLifecycle::Terminated; }
105
106private:
107 PluginLifecycle lifecycle = PluginLifecycle::Uninitialized;
108};
109} // namespace
110
111// Never destroyed: at static-destruction time the PluginInstances containers
112// (separate statics, arbitrary teardown order) still call IsTerminated(), and
113// the map's PluginInfo terminate callbacks must not run when the containers
114// they unregister from may already be gone. Terminate() clears the map
115// explicitly while everything is alive. The static pointer keeps it reachable,
116// so this is not a LeakSanitizer leak.
117static PluginRegistry &GetPluginRegistry() {
118 static PluginRegistry *g_registry = new PluginRegistry();
119 return *g_registry;
120}
121
122static std::recursive_mutex &GetPluginMapMutex() {
123 return GetPluginRegistry().mutex;
124}
125
127
128static bool PluginIsLoaded(const FileSpec &plugin_file_spec) {
129 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
130 return GetPluginMap().contains(plugin_file_spec);
131}
132
133static void SetPluginInfo(const FileSpec &plugin_file_spec,
134 PluginInfo plugin_info) {
135 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
136 DynamicPluginMap &plugin_map = GetPluginMap();
137 assert(!plugin_map.contains(plugin_file_spec));
138 plugin_map.try_emplace(plugin_file_spec, std::move(plugin_info));
139}
140
141template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
142 return reinterpret_cast<FPtrTy>(VPtr);
143}
144
145static constexpr llvm::StringLiteral g_plugin_prefix = "liblldbPlugin";
146struct PluginDir {
148 /// Try to load anything that looks like a shared library.
150
151 /// Only load shared libraries who's filename start with g_plugin_prefix.
153 };
154
157
158 explicit operator bool() const { return FileSystem::Instance().Exists(path); }
159
160 /// The path to the plugin directory.
162
163 /// Filter when looking for plugins.
165};
166
167llvm::Expected<PluginInfo> PluginInfo::Create(const FileSpec &path) {
168 PluginInfo plugin_info;
169 std::string error;
170 plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary(
171 path.GetPath().c_str(), &error);
172 if (!plugin_info.library.isValid())
173 return llvm::createStringError(error);
174
175 // Look for files that follow the convention <g_plugin_prefix><name>.<ext>, in
176 // which case we need to call lldb_initialize_<name> and
177 // lldb_terminate_<name>.
178 llvm::StringRef file_name = path.GetFileNameStrippingExtension();
179 if (file_name.starts_with(g_plugin_prefix)) {
180 llvm::StringRef plugin_name = file_name.substr(g_plugin_prefix.size());
181 std::string init_symbol =
182 llvm::Twine("lldb_initialize_" + plugin_name).str();
183
184 if (auto *init_fn = CastToFPtr<PluginInitCallback>(
185 plugin_info.library.getAddressOfSymbol(init_symbol.c_str()))) {
186 if (!init_fn())
187 return llvm::createStringErrorV("initializer '{0}' returned false",
188 init_symbol);
189 const std::string term_symbol =
190 llvm::Twine("lldb_terminate_" + plugin_name).str();
192 plugin_info.library.getAddressOfSymbol(term_symbol.c_str()));
193 }
194 return plugin_info;
195 }
196
197 // Look for the legacy LLDBPluginInitialize/LLDBPluginTerminate symbols.
198 if (auto *init_fn = CastToFPtr<PluginInitCallback>(
199 plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"))) {
200 if (!init_fn())
201 return llvm::createStringError(
202 "initializer 'LLDBPluginInitialize' returned false");
203
204 plugin_info.plugin_init_callback = init_fn;
206 plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
207 return plugin_info;
208 }
209
210 return llvm::createStringError("no initialize symbol found");
211}
212
214LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
215 llvm::StringRef path) {
216 namespace fs = llvm::sys::fs;
217
218 static constexpr std::array<llvm::StringLiteral, 3>
219 g_shared_library_extension = {".dylib", ".so", ".dll"};
220
221 // If we have a regular file, a symbolic link or unknown file type, try and
222 // process the file. We must handle unknown as sometimes the directory
223 // enumeration might be enumerating a file system that doesn't have correct
224 // file type information.
225 if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
226 ft == fs::file_type::type_unknown) {
227 FileSpec plugin_file_spec(path);
228 FileSystem::Instance().Resolve(plugin_file_spec);
229
230 // Don't try to load unknown extensions.
231 if (!llvm::is_contained(g_shared_library_extension,
232 plugin_file_spec.GetFileNameExtension()))
234
235 // Don't try to load libraries that don't start with g_plugin_prefix if so
236 // requested.
238 if (*policy == PluginDir::LoadOnlyWithLLDBPrefix &&
239 !plugin_file_spec.GetFilename().starts_with(g_plugin_prefix))
241
242 // Don't try to load an already loaded plugin again.
243 if (PluginIsLoaded(plugin_file_spec))
245
246 llvm::Expected<PluginInfo> plugin_info =
247 PluginInfo::Create(plugin_file_spec);
248 if (plugin_info) {
249 SetPluginInfo(plugin_file_spec, std::move(*plugin_info));
250 } else {
251 // Cache an empty plugin info so we don't try to load it again and again.
252 SetPluginInfo(plugin_file_spec, PluginInfo());
253
254 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), plugin_info.takeError(),
255 "could not load plugin: {0}");
256 }
257
259 }
260
261 if (ft == fs::file_type::directory_file ||
262 ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
263 // Try and recurse into anything that a directory or symbolic link. We must
264 // also do this for unknown as sometimes the directory enumeration might be
265 // enumerating a file system that doesn't have correct file type
266 // information.
268 }
269
271}
272
274 GetPluginRegistry().Initialize();
275
276 static const bool find_directories = true;
277 static const bool find_files = true;
278 static const bool find_other = true;
279
280 // Directories to scan for plugins. Unlike the plugin directories, which are
281 // meant exclusively for LLDB, the shared library directory is likely to
282 // contain unrelated shared libraries that we do not want to load. Therefore,
283 // limit the scan to libraries that start with g_plugin_prefix.
284 const std::array<PluginDir, 3> plugin_dirs = {
285 PluginDir(HostInfo::GetShlibDir(), PluginDir::LoadOnlyWithLLDBPrefix),
286 PluginDir(HostInfo::GetSystemPluginDir(), PluginDir::LoadAnyDylib),
287 PluginDir(HostInfo::GetUserPluginDir(), PluginDir::LoadAnyDylib)};
288
289 for (const PluginDir &plugin_dir : plugin_dirs) {
290 if (plugin_dir) {
292 plugin_dir.path.GetPath().c_str(), find_directories, find_files,
293 find_other, LoadPluginCallback, (void *)&plugin_dir.policy);
294 }
295 }
296}
297
298static void ClearScriptInterpreterErrors();
299
304
305llvm::ArrayRef<PluginNamespace> PluginManager::GetPluginNamespaces() {
306 static PluginNamespace PluginNamespaces[] = {
307
308 {
309 "abi",
312 },
313
314 {
315 "architecture",
318 },
319
320 {
321 "bug-reporter",
324 },
325
326 {
327 "disassembler",
330 },
331
332 {
333 "dynamic-loader",
336 },
337
338 {
339 "emulate-instruction",
342 },
343
344 {
345 "instrumentation-runtime",
348 },
349
350 {
351 "jit-loader",
354 },
355
356 {
357 "language",
360 },
361
362 {
363 "language-runtime",
366 },
367
368 {
369 "memory-history",
372 },
373
374 {
375 "object-container",
378 },
379
380 {
381 "object-file",
384 },
385
386 {
387 "operating-system",
390 },
391
392 {
393 "platform",
396 },
397
398 {
399 "process",
402 },
403
404 {
405 "repl",
408 },
409
410 {
411 "register-type-builder",
414 },
415
416 {
417 "script-interpreter",
420 },
421
422 {
423 "scripted-interface",
426 },
427
428 {
429 "structured-data",
432 },
433
434 {
435 "symbol-file",
438 },
439
440 {
441 "symbol-locator",
444 },
445
446 {
447 "symbol-vendor",
450 },
451
452 {
453 "system-runtime",
456 },
457
458 {
459 "trace",
462 },
463
464 {
465 "trace-exporter",
468 },
469
470 {
471 "type-system",
474 },
475
476 {
477 "unwind-assembly",
480 },
481 };
482
483 return PluginNamespaces;
484}
485
486llvm::json::Object PluginManager::GetJSON(llvm::StringRef pattern) {
487 llvm::json::Object plugin_stats;
488
489 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
490 llvm::json::Array namespace_stats;
491
492 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
493 if (MatchPluginName(pattern, plugin_ns, plugin)) {
494 llvm::json::Object plugin_json;
495 plugin_json.try_emplace("name", plugin.name);
496 plugin_json.try_emplace("enabled", plugin.enabled);
497 namespace_stats.emplace_back(std::move(plugin_json));
498 }
499 }
500 if (!namespace_stats.empty())
501 plugin_stats.try_emplace(plugin_ns.name, std::move(namespace_stats));
502 }
503
504 return plugin_stats;
505}
506
507bool PluginManager::MatchPluginName(llvm::StringRef pattern,
508 const PluginNamespace &plugin_ns,
509 const RegisteredPluginInfo &plugin_info) {
510 // The empty pattern matches all plugins.
511 if (pattern.empty())
512 return true;
513
514 // Check if the pattern matches the namespace.
515 if (pattern == plugin_ns.name)
516 return true;
517
518 // Check if the pattern matches the qualified name.
519 std::string qualified_name = (plugin_ns.name + "." + plugin_info.name).str();
520 return pattern == qualified_name;
521}
522
523template <typename Instance> class PluginInstances {
524public:
526 // Only meaningful after a real teardown; see PluginRegistry::IsTerminated.
527 if (!GetPluginRegistry().IsTerminated())
528 return;
529#ifndef NDEBUG
530 for (const auto &instance : m_instances)
531 llvm::errs() << llvm::formatv("Use `image lookup -va {0:x}` to find out "
532 "which callback was not removed\n",
533 instance.create_callback);
534#endif
535 assert(m_instances.empty() && "forgot to unregister plugin?");
536 }
537
538 template <typename... Args>
539 bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
540 typename Instance::CallbackType callback,
541 Args &&...args) {
542 if (!callback)
543 return false;
544 assert(!name.empty());
545
546 std::lock_guard<std::mutex> guard(m_mutex);
547 m_instances.emplace_back(name, description, callback,
548 std::forward<Args>(args)...);
549 return true;
550 }
551
552 bool UnregisterPlugin(typename Instance::CallbackType callback) {
553 if (!callback)
554 return false;
555
556 std::lock_guard<std::mutex> guard(m_mutex);
557 auto pos = m_instances.begin();
558 auto end = m_instances.end();
559 for (; pos != end; ++pos) {
560 if (pos->create_callback == callback) {
561 m_instances.erase(pos);
562 return true;
563 }
564 }
565 return false;
566 }
567
568 llvm::StringRef GetDescriptionAtIndex(uint32_t idx) {
569 if (auto instance = GetInstanceAtIndex(idx))
570 return instance->description;
571 return "";
572 }
573
574 llvm::StringRef GetNameAtIndex(uint32_t idx) {
575 if (auto instance = GetInstanceAtIndex(idx))
576 return instance->name;
577 return "";
578 }
579
580 typename Instance::CallbackType GetCallbackForName(llvm::StringRef name) {
581 if (auto instance = GetInstanceForName(name))
582 return instance->create_callback;
583 return nullptr;
584 }
585
586 llvm::SmallVector<typename Instance::CallbackType> GetCreateCallbacks() {
587 llvm::SmallVector<Instance> snapshot = GetSnapshot();
588 llvm::SmallVector<typename Instance::CallbackType> result;
589 result.reserve(snapshot.size());
590 for (const auto &instance : snapshot)
591 result.push_back(instance.create_callback);
592 return result;
593 }
594
596 for (const auto &instance : GetSnapshot()) {
597 if (instance.debugger_init_callback)
598 instance.debugger_init_callback(debugger);
599 }
600 }
601
602 // Return a copy of all the enabled instances.
603 // Note that this is a copy of the internal state so modifications
604 // to the returned instances will not be reflected back to instances
605 // stored by the PluginInstances object.
606 llvm::SmallVector<Instance> GetSnapshot(bool enabled_only = true) const {
607 std::lock_guard<std::mutex> guard(m_mutex);
608
609 llvm::SmallVector<Instance> enabled_instances;
610 enabled_instances.reserve(m_instances.size());
611 for (const auto &instance : m_instances) {
612 if (!enabled_only || instance.enabled)
613 enabled_instances.push_back(instance);
614 }
615 return enabled_instances;
616 }
617
618 std::optional<Instance> GetInstanceAtIndex(uint32_t idx) {
619 uint32_t count = 0;
620
621 return FindEnabledInstance(
622 [&](const Instance &instance) { return count++ == idx; });
623 }
624
625 std::optional<Instance> GetInstanceForName(llvm::StringRef name,
626 bool enabled_only = true) {
627 if (name.empty())
628 return std::nullopt;
629
630 auto predicate = [&](const Instance &instance) {
631 return instance.name == name;
632 };
633 if (enabled_only)
634 return FindEnabledInstance(predicate);
635
636 return FindInstance(predicate);
637 }
638
639 std::optional<Instance>
640 FindEnabledInstance(std::function<bool(const Instance &)> predicate) const {
641 for (const auto &instance : GetSnapshot()) {
642 if (predicate(instance))
643 return instance;
644 }
645 return std::nullopt;
646 }
647
648 std::optional<Instance>
649 FindInstance(std::function<bool(const Instance &)> predicate) const {
650 std::lock_guard<std::mutex> guard(m_mutex);
651 for (const auto &instance : m_instances) {
652 if (predicate(instance))
653 return instance;
654 }
655 return std::nullopt;
656 }
657
658 // Return a list of all the registered plugin instances. This includes both
659 // enabled and disabled instances. The instances are listed in the order they
660 // were registered which is the order they would be queried if they were all
661 // enabled.
662 llvm::SmallVector<RegisteredPluginInfo> GetPluginInfoForAllInstances() {
663 std::lock_guard<std::mutex> guard(m_mutex);
664
665 // Lookup the plugin info for each instance in the sorted order.
666 llvm::SmallVector<RegisteredPluginInfo> plugin_infos;
667 plugin_infos.reserve(m_instances.size());
668
669 for (const Instance &instance : m_instances)
670 plugin_infos.push_back(
671 {instance.name, instance.description, instance.enabled});
672
673 return plugin_infos;
674 }
675
676 bool SetInstanceEnabled(llvm::StringRef name, bool enable) {
677 std::lock_guard<std::mutex> guard(m_mutex);
678 auto it = llvm::find_if(m_instances, [&](const Instance &instance) {
679 return instance.name == name;
680 });
681
682 if (it == m_instances.end())
683 return false;
684
685 it->enabled = enable;
686 return true;
687 }
688
689private:
690 mutable std::mutex m_mutex;
691 llvm::SmallVector<Instance> m_instances;
692};
693
694#pragma mark ABI
695
698
700 static ABIInstances g_instances;
701 return g_instances;
702}
703
704bool PluginManager::RegisterPlugin(llvm::StringRef name,
705 llvm::StringRef description,
706 ABICreateInstance create_callback) {
707 return GetABIInstances().RegisterPlugin(name, description, create_callback);
708}
709
711 return GetABIInstances().UnregisterPlugin(create_callback);
712}
713
714llvm::SmallVector<ABICreateInstance> PluginManager::GetABICreateCallbacks() {
716}
717
718#pragma mark Architecture
719
722
724 static ArchitectureInstances g_instances;
725 return g_instances;
726}
727
728void PluginManager::RegisterPlugin(llvm::StringRef name,
729 llvm::StringRef description,
730 ArchitectureCreateInstance create_callback) {
731 GetArchitectureInstances().RegisterPlugin(name, description, create_callback);
732}
733
735 ArchitectureCreateInstance create_callback) {
736 auto &instances = GetArchitectureInstances();
737 instances.UnregisterPlugin(create_callback);
738}
739
740std::unique_ptr<Architecture>
742 for (const auto &instances : GetArchitectureInstances().GetSnapshot()) {
743 if (auto plugin_up = instances.create_callback(arch))
744 return plugin_up;
745 }
746 return nullptr;
747}
748
749#pragma mark BugReporter
750
753
755 static BugReporterInstances g_instances;
756 return g_instances;
757}
758
759void PluginManager::RegisterPlugin(llvm::StringRef name,
760 llvm::StringRef description,
761 BugReporterCreateInstance create_callback) {
762 GetBugReporterInstances().RegisterPlugin(name, description, create_callback);
763}
764
769
770std::unique_ptr<BugReporter>
772 if (!name.empty()) {
773 if (auto create_callback =
774 GetBugReporterInstances().GetCallbackForName(name))
775 return create_callback();
776 return nullptr;
777 }
778 for (const auto &instance : GetBugReporterInstances().GetSnapshot()) {
779 if (auto plugin_up = instance.create_callback())
780 return plugin_up;
781 }
782 return nullptr;
783}
784
785#pragma mark Disassembler
786
789
791 static DisassemblerInstances g_instances;
792 return g_instances;
793}
794
795bool PluginManager::RegisterPlugin(llvm::StringRef name,
796 llvm::StringRef description,
797 DisassemblerCreateInstance create_callback) {
798 return GetDisassemblerInstances().RegisterPlugin(name, description,
799 create_callback);
800}
801
803 DisassemblerCreateInstance create_callback) {
804 return GetDisassemblerInstances().UnregisterPlugin(create_callback);
805}
806
807llvm::SmallVector<DisassemblerCreateInstance>
811
817
818#pragma mark DynamicLoader
819
822
824 static DynamicLoaderInstances g_instances;
825 return g_instances;
826}
827
829 llvm::StringRef name, llvm::StringRef description,
830 DynamicLoaderCreateInstance create_callback,
831 DebuggerInitializeCallback debugger_init_callback) {
833 name, description, create_callback, debugger_init_callback);
834}
835
837 DynamicLoaderCreateInstance create_callback) {
838 return GetDynamicLoaderInstances().UnregisterPlugin(create_callback);
839}
840
841llvm::SmallVector<DynamicLoaderCreateInstance>
845
851
852#pragma mark JITLoader
853
856
858 static JITLoaderInstances g_instances;
859 return g_instances;
860}
861
863 llvm::StringRef name, llvm::StringRef description,
864 JITLoaderCreateInstance create_callback,
865 DebuggerInitializeCallback debugger_init_callback) {
867 name, description, create_callback, debugger_init_callback);
868}
869
871 return GetJITLoaderInstances().UnregisterPlugin(create_callback);
872}
873
874llvm::SmallVector<JITLoaderCreateInstance>
878
879#pragma mark EmulateInstruction
880
884
886 static EmulateInstructionInstances g_instances;
887 return g_instances;
888}
889
891 llvm::StringRef name, llvm::StringRef description,
892 EmulateInstructionCreateInstance create_callback) {
893 return GetEmulateInstructionInstances().RegisterPlugin(name, description,
894 create_callback);
895}
896
901
902llvm::SmallVector<EmulateInstructionCreateInstance>
906
912
913#pragma mark OperatingSystem
914
917
919 static OperatingSystemInstances g_instances;
920 return g_instances;
921}
922
924 llvm::StringRef name, llvm::StringRef description,
925 OperatingSystemCreateInstance create_callback,
926 DebuggerInitializeCallback debugger_init_callback) {
928 name, description, create_callback, debugger_init_callback);
929}
930
935
936llvm::SmallVector<OperatingSystemCreateInstance>
940
946
947#pragma mark Language
948
951
953 static LanguageInstances g_instances;
954 return g_instances;
955}
956
958 llvm::StringRef name, llvm::StringRef description,
959 LanguageCreateInstance create_callback,
960 DebuggerInitializeCallback debugger_init_callback) {
962 name, description, create_callback, debugger_init_callback);
963}
964
966 return GetLanguageInstances().UnregisterPlugin(create_callback);
967}
968
969llvm::SmallVector<LanguageCreateInstance>
973
974#pragma mark LanguageRuntime
975
992
994
996 static LanguageRuntimeInstances g_instances;
997 return g_instances;
998}
999
1001 llvm::StringRef name, llvm::StringRef description,
1002 LanguageRuntimeCreateInstance create_callback,
1003 LanguageRuntimeGetCommandObject command_callback,
1004 LanguageRuntimeGetExceptionPrecondition precondition_callback) {
1006 name, description, create_callback, nullptr, command_callback,
1007 precondition_callback);
1008}
1009
1011 LanguageRuntimeCreateInstance create_callback) {
1012 return GetLanguageRuntimeInstances().UnregisterPlugin(create_callback);
1013}
1014
1015llvm::SmallVector<LanguageRuntimeCallbacks>
1017 auto instances = GetLanguageRuntimeInstances().GetSnapshot();
1018 llvm::SmallVector<LanguageRuntimeCallbacks> result;
1019 result.reserve(instances.size());
1020 for (auto &instance : instances)
1021 result.push_back({instance.create_callback, instance.command_callback,
1022 instance.precondition_callback});
1023 return result;
1024}
1025
1026#pragma mark SystemRuntime
1027
1030
1032 static SystemRuntimeInstances g_instances;
1033 return g_instances;
1034}
1035
1037 llvm::StringRef name, llvm::StringRef description,
1038 SystemRuntimeCreateInstance create_callback) {
1039 return GetSystemRuntimeInstances().RegisterPlugin(name, description,
1040 create_callback);
1041}
1042
1044 SystemRuntimeCreateInstance create_callback) {
1045 return GetSystemRuntimeInstances().UnregisterPlugin(create_callback);
1046}
1047
1048llvm::SmallVector<SystemRuntimeCreateInstance>
1052
1053#pragma mark ObjectFile
1054
1074
1076 static ObjectFileInstances g_instances;
1077 return g_instances;
1078}
1079
1081 if (name.empty())
1082 return false;
1083
1084 return GetObjectFileInstances().GetInstanceForName(name).has_value();
1085}
1086
1088 llvm::StringRef name, llvm::StringRef description,
1089 ObjectFileCreateInstance create_callback,
1090 ObjectFileCreateMemoryInstance create_memory_callback,
1091 ObjectFileGetModuleSpecifications get_module_specifications,
1092 ObjectFileSaveCore save_core,
1093 DebuggerInitializeCallback debugger_init_callback) {
1095 name, description, create_callback, create_memory_callback,
1096 get_module_specifications, save_core, debugger_init_callback);
1097}
1098
1100 return GetObjectFileInstances().UnregisterPlugin(create_callback);
1101}
1102
1103llvm::SmallVector<ObjectFileCallbacks> PluginManager::GetObjectFileCallbacks() {
1104 auto instances = GetObjectFileInstances().GetSnapshot();
1105 llvm::SmallVector<ObjectFileCallbacks> result;
1106 result.reserve(instances.size());
1107 for (auto &instance : instances)
1108 result.push_back({instance.create_callback, instance.create_memory_callback,
1109 instance.get_module_specifications, instance.save_core});
1110 return result;
1111}
1112
1115 llvm::StringRef name) {
1116 if (auto instance = GetObjectFileInstances().GetInstanceForName(name))
1117 return instance->create_memory_callback;
1118 return nullptr;
1119}
1120
1122 Status error;
1123 if (!options.GetOutputFile()) {
1124 error = Status::FromErrorString("No output file specified");
1125 return error;
1126 }
1127
1128 if (!options.GetProcess()) {
1129 error = Status::FromErrorString("Invalid process");
1130 return error;
1131 }
1132
1133 error = options.EnsureValidConfiguration();
1134 if (error.Fail())
1135 return error;
1136
1137 if (!options.GetPluginName().has_value()) {
1138 // Try saving core directly from the process plugin first.
1139 llvm::Expected<bool> ret =
1140 options.GetProcess()->SaveCore(options.GetOutputFile()->GetPath());
1141 if (!ret)
1142 return Status::FromError(ret.takeError());
1143 if (ret.get())
1144 return Status();
1145 }
1146
1147 // Fall back to object plugins.
1148 const auto &plugin_name = options.GetPluginName().value_or("");
1149 auto instances = GetObjectFileInstances().GetSnapshot();
1150 for (auto &instance : instances) {
1151 if (plugin_name.empty() || instance.name == plugin_name) {
1152 // TODO: Refactor the instance.save_core() to not require a process and
1153 // get it from options instead.
1154 if (instance.save_core &&
1155 instance.save_core(options.GetProcess(), options, error))
1156 return error;
1157 }
1158 }
1159
1160 // Check to see if any of the object file plugins tried and failed to save.
1161 // if any failure, return the error message.
1162 if (error.Fail())
1163 return error;
1164
1165 // Report only for the plugin that was specified.
1166 if (!plugin_name.empty())
1168 "The \"{}\" plugin is not able to save a core for this process.",
1169 plugin_name);
1170
1172 "no ObjectFile plugins were able to save a core for this process");
1173}
1174
1175llvm::SmallVector<llvm::StringRef> PluginManager::GetSaveCorePluginNames() {
1176 llvm::SmallVector<llvm::StringRef> plugin_names;
1177 auto instances = GetObjectFileInstances().GetSnapshot();
1178 for (auto &instance : instances) {
1179 if (instance.save_core)
1180 plugin_names.emplace_back(instance.name);
1181 }
1182 return plugin_names;
1183}
1184
1185#pragma mark ObjectContainer
1186
1203
1205 static ObjectContainerInstances g_instances;
1206 return g_instances;
1207}
1208
1210 llvm::StringRef name, llvm::StringRef description,
1211 ObjectContainerCreateInstance create_callback,
1212 ObjectFileGetModuleSpecifications get_module_specifications,
1213 ObjectContainerCreateMemoryInstance create_memory_callback) {
1215 name, description, create_callback, create_memory_callback,
1216 get_module_specifications);
1217}
1218
1220 ObjectContainerCreateInstance create_callback) {
1221 return GetObjectContainerInstances().UnregisterPlugin(create_callback);
1222}
1223
1224llvm::SmallVector<ObjectContainerCallbacks>
1226 auto instances = GetObjectContainerInstances().GetSnapshot();
1227 llvm::SmallVector<ObjectContainerCallbacks> result;
1228 result.reserve(instances.size());
1229 for (auto &instance : instances)
1230 result.push_back({instance.create_callback, instance.create_memory_callback,
1231 instance.get_module_specifications});
1232 return result;
1233}
1234
1235#pragma mark Platform
1236
1239
1241 static PlatformInstances g_platform_instances;
1242 return g_platform_instances;
1243}
1244
1246 llvm::StringRef name, llvm::StringRef description,
1247 PlatformCreateInstance create_callback,
1248 DebuggerInitializeCallback debugger_init_callback) {
1250 name, description, create_callback, debugger_init_callback);
1251}
1252
1254 return GetPlatformInstances().UnregisterPlugin(create_callback);
1255}
1256
1257llvm::StringRef PluginManager::GetPlatformPluginNameAtIndex(uint32_t idx) {
1259}
1260
1261llvm::StringRef
1265
1270
1271llvm::SmallVector<PlatformCreateInstance>
1275
1277 CompletionRequest &request) {
1278 for (const auto &instance : GetPlatformInstances().GetSnapshot()) {
1279 if (instance.name.starts_with(name))
1280 request.AddCompletion(instance.name);
1281 }
1282}
1283
1284#pragma mark Process
1285
1288
1290 static ProcessInstances g_instances;
1291 return g_instances;
1292}
1293
1295 llvm::StringRef name, llvm::StringRef description,
1296 ProcessCreateInstance create_callback,
1297 DebuggerInitializeCallback debugger_init_callback) {
1299 name, description, create_callback, debugger_init_callback);
1300}
1301
1303 return GetProcessInstances().UnregisterPlugin(create_callback);
1304}
1305
1306llvm::StringRef PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) {
1307 return GetProcessInstances().GetNameAtIndex(idx);
1308}
1309
1310llvm::StringRef
1314
1319
1320llvm::SmallVector<ProcessCreateInstance>
1324
1326 CompletionRequest &request) {
1327 for (const auto &instance : GetProcessInstances().GetSnapshot()) {
1328 if (instance.name.starts_with(name))
1329 request.AddCompletion(instance.name, instance.description);
1330 }
1331}
1332
1333#pragma mark ProtocolServer
1334
1337
1339 static ProtocolServerInstances g_instances;
1340 return g_instances;
1341}
1342
1344 llvm::StringRef name, llvm::StringRef description,
1345 ProtocolServerCreateInstance create_callback) {
1346 return GetProtocolServerInstances().RegisterPlugin(name, description,
1347 create_callback);
1348}
1349
1351 ProtocolServerCreateInstance create_callback) {
1352 return GetProtocolServerInstances().UnregisterPlugin(create_callback);
1353}
1354
1355llvm::StringRef
1359
1364
1365#pragma mark RegisterTypeBuilder
1366
1368 : public PluginInstance<RegisterTypeBuilderCreateInstance> {
1373};
1374
1375typedef PluginInstances<RegisterTypeBuilderInstance>
1377
1379 static RegisterTypeBuilderInstances g_instances;
1380 return g_instances;
1381}
1382
1384 llvm::StringRef name, llvm::StringRef description,
1385 RegisterTypeBuilderCreateInstance create_callback) {
1386 return GetRegisterTypeBuilderInstances().RegisterPlugin(name, description,
1387 create_callback);
1388}
1389
1394
1397 // We assume that RegisterTypeBuilderClang is the only instance of this plugin
1398 // type and is always present.
1400 assert(instance);
1401 return instance->create_callback(target);
1402}
1403
1404#pragma mark ScriptInterpreter
1405
1419
1421
1423 static ScriptInterpreterInstances g_instances;
1424 return g_instances;
1425}
1426
1428 llvm::StringRef name, llvm::StringRef description,
1429 lldb::ScriptLanguage script_language,
1430 ScriptInterpreterCreateInstance create_callback,
1431 ScriptInterpreterGetPath get_path_callback) {
1433 name, description, create_callback, script_language, get_path_callback);
1434}
1435
1440
1441llvm::SmallVector<ScriptInterpreterCreateInstance>
1445
1448 Debugger &debugger) {
1449 const auto instances = GetScriptInterpreterInstances().GetSnapshot();
1450 ScriptInterpreterCreateInstance none_instance = nullptr;
1451 for (const auto &instance : instances) {
1452 if (instance.language == lldb::eScriptLanguageNone)
1453 none_instance = instance.create_callback;
1454
1455 if (script_lang == instance.language)
1456 return instance.create_callback(debugger, script_lang);
1457 }
1458
1459 // If we didn't find one, return the ScriptInterpreter for the null language.
1460 assert(none_instance != nullptr);
1461 return none_instance(debugger, script_lang);
1462}
1463
1464namespace {
1465struct ScriptInterpreterErrors {
1466 std::mutex mutex;
1467 llvm::DenseMap<lldb::ScriptLanguage, Status> errors;
1468};
1469} // namespace
1470
1471static ScriptInterpreterErrors &GetScriptInterpreterErrors() {
1472 static ScriptInterpreterErrors g_errors;
1473 return g_errors;
1474}
1475
1477 ScriptInterpreterErrors &errors = GetScriptInterpreterErrors();
1478 std::lock_guard<std::mutex> guard(errors.mutex);
1479 errors.errors.clear();
1480}
1481
1483 llvm::Error error) {
1484 ScriptInterpreterErrors &errors = GetScriptInterpreterErrors();
1485 std::lock_guard<std::mutex> guard(errors.mutex);
1486 if (error)
1487 errors.errors[script_lang] = Status::FromError(std::move(error));
1488 else
1489 errors.errors.erase(script_lang);
1490}
1491
1492llvm::Error
1494 ScriptInterpreterErrors &errors = GetScriptInterpreterErrors();
1495 std::lock_guard<std::mutex> guard(errors.mutex);
1496 auto it = errors.errors.find(script_lang);
1497 if (it == errors.errors.end())
1498 return llvm::Error::success();
1499 return it->second.ToError();
1500}
1501
1503 lldb::ScriptLanguage script_lang) {
1504 const auto instances = GetScriptInterpreterInstances().GetSnapshot();
1505 for (const auto &instance : instances) {
1506 if (instance.language == script_lang && instance.get_path_callback)
1507 return instance.get_path_callback();
1508 }
1509 return FileSpec();
1510}
1511
1512#pragma mark SyntheticFrameProvider
1513
1522
1524 static SyntheticFrameProviderInstances g_instances;
1525 return g_instances;
1526}
1527
1529 static ScriptedFrameProviderInstances g_instances;
1530 return g_instances;
1531}
1532
1534 llvm::StringRef name, llvm::StringRef description,
1535 SyntheticFrameProviderCreateInstance create_native_callback,
1536 ScriptedFrameProviderCreateInstance create_scripted_callback) {
1537 if (create_native_callback)
1539 name, description, create_native_callback);
1540 else if (create_scripted_callback)
1542 name, description, create_scripted_callback);
1543 return false;
1544}
1545
1550
1555
1561
1562llvm::SmallVector<ScriptedFrameProviderCreateInstance>
1566
1567#pragma mark StructuredDataPlugin
1568
1582
1585
1587 static StructuredDataPluginInstances g_instances;
1588 return g_instances;
1589}
1590
1592 llvm::StringRef name, llvm::StringRef description,
1593 StructuredDataPluginCreateInstance create_callback,
1594 DebuggerInitializeCallback debugger_init_callback,
1595 StructuredDataFilterLaunchInfo filter_callback) {
1597 name, description, create_callback, debugger_init_callback,
1598 filter_callback);
1599}
1600
1605
1606llvm::SmallVector<StructuredDataPluginCallbacks>
1608 auto instances = GetStructuredDataPluginInstances().GetSnapshot();
1609 llvm::SmallVector<StructuredDataPluginCallbacks> result;
1610 result.reserve(instances.size());
1611 for (auto &instance : instances)
1612 result.push_back({instance.create_callback, instance.filter_callback});
1613 return result;
1614}
1615
1616#pragma mark SymbolFile
1617
1620
1622 static SymbolFileInstances g_instances;
1623 return g_instances;
1624}
1625
1627 llvm::StringRef name, llvm::StringRef description,
1628 SymbolFileCreateInstance create_callback,
1629 DebuggerInitializeCallback debugger_init_callback) {
1631 name, description, create_callback, debugger_init_callback);
1632}
1633
1635 return GetSymbolFileInstances().UnregisterPlugin(create_callback);
1636}
1637
1638llvm::SmallVector<SymbolFileCreateInstance>
1642
1643#pragma mark SymbolVendor
1644
1647
1649 static SymbolVendorInstances g_instances;
1650 return g_instances;
1651}
1652
1653bool PluginManager::RegisterPlugin(llvm::StringRef name,
1654 llvm::StringRef description,
1655 SymbolVendorCreateInstance create_callback) {
1656 return GetSymbolVendorInstances().RegisterPlugin(name, description,
1657 create_callback);
1658}
1659
1661 SymbolVendorCreateInstance create_callback) {
1662 return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
1663}
1664
1665llvm::SmallVector<SymbolVendorCreateInstance>
1669
1670#pragma mark SymbolLocator
1671
1695
1697 static SymbolLocatorInstances g_instances;
1698 return g_instances;
1699}
1700
1702 llvm::StringRef name, llvm::StringRef description,
1703 SymbolLocatorCreateInstance create_callback,
1704 SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
1705 SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
1706 SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file,
1707 SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle,
1708 DebuggerInitializeCallback debugger_init_callback) {
1710 name, description, create_callback, locate_executable_object_file,
1711 locate_executable_symbol_file, download_object_symbol_file,
1712 find_symbol_file_in_bundle, debugger_init_callback);
1713}
1714
1716 SymbolLocatorCreateInstance create_callback) {
1717 return GetSymbolLocatorInstances().UnregisterPlugin(create_callback);
1718}
1719
1720llvm::SmallVector<SymbolLocatorCreateInstance>
1724
1727 StatisticsMap &map) {
1728 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1729 for (auto &instance : instances) {
1730 if (instance.locate_executable_object_file) {
1731 StatsDuration time;
1732 std::optional<ModuleSpec> result;
1733 {
1734 ElapsedTime elapsed(time);
1735 result = instance.locate_executable_object_file(module_spec);
1736 }
1737 map.add(instance.name, time.get().count());
1738 if (result)
1739 return *result;
1740 }
1741 }
1742 return {};
1743}
1744
1746 const ModuleSpec &module_spec, const FileSpecList &default_search_paths,
1747 StatisticsMap &map) {
1748 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1749 for (auto &instance : instances) {
1750 if (instance.locate_executable_symbol_file) {
1751 StatsDuration time;
1752 std::optional<FileSpec> result;
1753 {
1754 ElapsedTime elapsed(time);
1755 result = instance.locate_executable_symbol_file(module_spec,
1756 default_search_paths);
1757 }
1758 map.add(instance.name, time.get().count());
1759 if (result)
1760 return *result;
1761 }
1762 }
1763 return {};
1764}
1765
1767 Status &error,
1768 bool force_lookup,
1769 bool copy_executable) {
1770 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1771 for (auto &instance : instances) {
1772 if (instance.download_object_symbol_file) {
1773 if (instance.download_object_symbol_file(module_spec, error, force_lookup,
1774 copy_executable))
1775 return true;
1776 }
1777 }
1778 return false;
1779}
1780
1782 const UUID *uuid,
1783 const ArchSpec *arch) {
1784 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1785 for (auto &instance : instances) {
1786 if (instance.find_symbol_file_in_bundle) {
1787 std::optional<FileSpec> result =
1788 instance.find_symbol_file_in_bundle(symfile_bundle, uuid, arch);
1789 if (result)
1790 return *result;
1791 }
1792 }
1793 return {};
1794}
1795
1796#pragma mark Trace
1797
1813
1815
1817 static TraceInstances g_instances;
1818 return g_instances;
1819}
1820
1822 llvm::StringRef name, llvm::StringRef description,
1823 TraceCreateInstanceFromBundle create_callback_from_bundle,
1824 TraceCreateInstanceForLiveProcess create_callback_for_live_process,
1825 llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) {
1827 name, description, create_callback_from_bundle,
1828 create_callback_for_live_process, schema, debugger_init_callback);
1829}
1830
1832 TraceCreateInstanceFromBundle create_callback_from_bundle) {
1834 create_callback_from_bundle);
1835}
1836
1838PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
1839 return GetTracePluginInstances().GetCallbackForName(plugin_name);
1840}
1841
1844 llvm::StringRef plugin_name) {
1845 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1846 return instance->create_callback_for_live_process;
1847
1848 return nullptr;
1849}
1850
1851llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
1852 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1853 return instance->schema;
1854 return llvm::StringRef();
1855}
1856
1857llvm::StringRef PluginManager::GetTraceSchema(size_t index) {
1858 if (auto instance = GetTracePluginInstances().GetInstanceAtIndex(index))
1859 return instance->schema;
1860 return llvm::StringRef();
1861}
1862
1863#pragma mark TraceExporter
1864
1878
1880
1882 static TraceExporterInstances g_instances;
1883 return g_instances;
1884}
1885
1887 llvm::StringRef name, llvm::StringRef description,
1888 TraceExporterCreateInstance create_callback,
1889 ThreadTraceExportCommandCreator create_thread_trace_export_command) {
1891 name, description, create_callback, create_thread_trace_export_command);
1892}
1893
1896 return GetTraceExporterInstances().GetCallbackForName(plugin_name);
1897}
1898
1900 TraceExporterCreateInstance create_callback) {
1901 return GetTraceExporterInstances().UnregisterPlugin(create_callback);
1902}
1903
1904llvm::SmallVector<TraceExporterCallbacks>
1906 auto instances = GetTraceExporterInstances().GetSnapshot();
1907 llvm::SmallVector<TraceExporterCallbacks> result;
1908 result.reserve(instances.size());
1909 for (auto &instance : instances)
1910 result.push_back({instance.name, instance.create_callback,
1911 instance.create_thread_trace_export_command});
1912 return result;
1913}
1914
1915#pragma mark UnwindAssembly
1916
1919
1921 static UnwindAssemblyInstances g_instances;
1922 return g_instances;
1923}
1924
1926 llvm::StringRef name, llvm::StringRef description,
1927 UnwindAssemblyCreateInstance create_callback) {
1928 return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
1929 create_callback);
1930}
1931
1933 UnwindAssemblyCreateInstance create_callback) {
1934 return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
1935}
1936
1937llvm::SmallVector<UnwindAssemblyCreateInstance>
1941
1942#pragma mark MemoryHistory
1943
1946
1948 static MemoryHistoryInstances g_instances;
1949 return g_instances;
1950}
1951
1953 llvm::StringRef name, llvm::StringRef description,
1954 MemoryHistoryCreateInstance create_callback) {
1955 return GetMemoryHistoryInstances().RegisterPlugin(name, description,
1956 create_callback);
1957}
1958
1960 MemoryHistoryCreateInstance create_callback) {
1961 return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
1962}
1963
1964llvm::SmallVector<MemoryHistoryCreateInstance>
1968
1969#pragma mark InstrumentationRuntime
1970
1983
1985 : public PluginInstances<InstrumentationRuntimeInstance> {
1986
1988 bool enabled_only) {
1989 if (auto instance = GetInstanceForName(name, enabled_only))
1990 return instance->get_type_callback;
1991 return nullptr;
1992 }
1993};
1994
1996 static InstrumentationRuntimeInstances g_instances;
1997 return g_instances;
1998}
1999
2001 llvm::StringRef name, llvm::StringRef description,
2003 InstrumentationRuntimeGetType get_type_callback) {
2005 name, description, create_callback, get_type_callback);
2006}
2007
2012
2013llvm::SmallVector<InstrumentationRuntimeCallbacks>
2015 auto instances =
2017 llvm::SmallVector<InstrumentationRuntimeCallbacks> result;
2018 result.reserve(instances.size());
2019 for (auto &instance : instances)
2020 result.push_back({instance.create_callback, instance.get_type_callback});
2021 return result;
2022}
2023
2024#pragma mark TypeSystem
2025
2041
2043
2045 static TypeSystemInstances g_instances;
2046 return g_instances;
2047}
2048
2050 llvm::StringRef name, llvm::StringRef description,
2051 TypeSystemCreateInstance create_callback,
2052 LanguageSet supported_languages_for_types,
2053 LanguageSet supported_languages_for_expressions,
2054 DebuggerInitializeCallback debugger_init_callback) {
2056 name, description, create_callback, supported_languages_for_types,
2057 supported_languages_for_expressions, debugger_init_callback);
2058}
2059
2061 return GetTypeSystemInstances().UnregisterPlugin(create_callback);
2062}
2063
2064llvm::SmallVector<TypeSystemCreateInstance>
2068
2070 const auto instances = GetTypeSystemInstances().GetSnapshot();
2071 LanguageSet all;
2072 for (unsigned i = 0; i < instances.size(); ++i)
2073 all.bitvector |= instances[i].supported_languages_for_types.bitvector;
2074 return all;
2075}
2076
2078 const auto instances = GetTypeSystemInstances().GetSnapshot();
2079 LanguageSet all;
2080 for (unsigned i = 0; i < instances.size(); ++i)
2081 all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
2082 return all;
2083}
2084
2085#pragma mark ScriptedInterfaces
2086
2088
2090 static ScriptedInterfaceInstances g_instances;
2091 return g_instances;
2092}
2093
2095 llvm::StringRef name, llvm::StringRef description,
2096 ScriptedInterfaceCreateInstance create_callback,
2098 ScriptedInterfaceUsages usages) {
2100 name, description, create_callback, extension, language, usages);
2101}
2102
2107
2111
2112llvm::StringRef PluginManager::GetScriptedInterfaceNameAtIndex(uint32_t index) {
2114}
2115
2116llvm::StringRef
2120
2123 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(index))
2124 return instance->extension;
2126}
2127
2130 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
2131 return instance->language;
2133}
2134
2137 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
2138 return instance->usages;
2139 return {};
2140}
2141
2143 llvm::function_ref<void(const ScriptedInterfaceInstance &)> callback,
2144 lldb::ScriptLanguage language) {
2145 llvm::SmallSet<lldb::ScriptedExtension, 16> emitted;
2146 for (size_t idx = 0; idx < GetNumScriptedInterfaces(); idx++) {
2148 if (!instance)
2149 continue;
2150 if (language != lldb::eScriptLanguageUnknown &&
2151 instance->language != language)
2152 continue;
2153 if (emitted.insert(instance->extension).second)
2154 callback(*instance);
2155 }
2156}
2157
2159 llvm::StringRef name, CompletionRequest &request,
2160 lldb::ScriptLanguage language) {
2162 [&](const ScriptedInterfaceInstance &instance) {
2163 llvm::StringLiteral extension_name =
2165 if (extension_name.starts_with(name))
2166 request.AddCompletion(extension_name);
2167 },
2168 language);
2169}
2170
2171#pragma mark REPL
2172
2181
2183
2185 static REPLInstances g_instances;
2186 return g_instances;
2187}
2188
2189bool PluginManager::RegisterPlugin(llvm::StringRef name,
2190 llvm::StringRef description,
2191 REPLCreateInstance create_callback,
2192 LanguageSet supported_languages) {
2193 return GetREPLInstances().RegisterPlugin(name, description, create_callback,
2194 supported_languages);
2195}
2196
2198 return GetREPLInstances().UnregisterPlugin(create_callback);
2199}
2200
2201llvm::SmallVector<REPLCallbacks> PluginManager::GetREPLCallbacks() {
2202 auto instances = GetREPLInstances().GetSnapshot();
2203 llvm::SmallVector<REPLCallbacks> result;
2204 result.reserve(instances.size());
2205 for (auto &instance : instances)
2206 result.push_back({instance.create_callback, instance.supported_languages});
2207 return result;
2208}
2209
2211 const auto instances = GetREPLInstances().GetSnapshot();
2212 LanguageSet all;
2213 for (unsigned i = 0; i < instances.size(); ++i)
2214 all.bitvector |= instances[i].supported_languages.bitvector;
2215 return all;
2216}
2217
2218#pragma mark Highlighter
2219
2220struct HighlighterInstance : public PluginInstance<HighlighterCreateInstance> {
2225};
2226
2228
2230 static HighlighterInstances g_instances;
2231 return g_instances;
2232}
2233
2234bool PluginManager::RegisterPlugin(llvm::StringRef name,
2235 llvm::StringRef description,
2236 HighlighterCreateInstance create_callback) {
2237 return GetHighlighterInstances().RegisterPlugin(name, description,
2238 create_callback);
2239}
2240
2242 HighlighterCreateInstance create_callback) {
2243 return GetHighlighterInstances().UnregisterPlugin(create_callback);
2244}
2245
2246llvm::SmallVector<HighlighterCreateInstance>
2250
2251#pragma mark PluginManager
2252
2268
2269// This is the preferred new way to register plugin specific settings. e.g.
2270// This will put a plugin's settings under e.g.
2271// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
2273 Debugger &debugger, llvm::StringRef plugin_type_name,
2274 llvm::StringRef plugin_type_desc, bool can_create) {
2275 lldb::OptionValuePropertiesSP parent_properties_sp(
2276 debugger.GetValueProperties());
2277 if (parent_properties_sp) {
2278 static constexpr llvm::StringLiteral g_property_name("plugin");
2279
2280 OptionValuePropertiesSP plugin_properties_sp =
2281 parent_properties_sp->GetSubProperty(nullptr, g_property_name);
2282 if (!plugin_properties_sp && can_create) {
2283 plugin_properties_sp =
2284 std::make_shared<OptionValueProperties>(g_property_name);
2285 plugin_properties_sp->SetExpectedPath("plugin");
2286 parent_properties_sp->AppendProperty(g_property_name,
2287 "Settings specify to plugins.", true,
2288 plugin_properties_sp);
2289 }
2290
2291 if (plugin_properties_sp) {
2292 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2293 plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2294 if (!plugin_type_properties_sp && can_create) {
2295 plugin_type_properties_sp =
2296 std::make_shared<OptionValueProperties>(plugin_type_name);
2297 plugin_type_properties_sp->SetExpectedPath(
2298 ("plugin." + plugin_type_name).str());
2299 plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2300 true, plugin_type_properties_sp);
2301 }
2302 return plugin_type_properties_sp;
2303 }
2304 }
2306}
2307
2308// This is deprecated way to register plugin specific settings. e.g.
2309// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
2310// generic settings would be under "platform.SETTINGNAME".
2312 Debugger &debugger, llvm::StringRef plugin_type_name,
2313 llvm::StringRef plugin_type_desc, bool can_create) {
2314 static constexpr llvm::StringLiteral g_property_name("plugin");
2315 lldb::OptionValuePropertiesSP parent_properties_sp(
2316 debugger.GetValueProperties());
2317 if (parent_properties_sp) {
2318 OptionValuePropertiesSP plugin_properties_sp =
2319 parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2320 if (!plugin_properties_sp && can_create) {
2321 plugin_properties_sp =
2322 std::make_shared<OptionValueProperties>(plugin_type_name);
2323 plugin_properties_sp->SetExpectedPath(plugin_type_name.str());
2324 parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2325 true, plugin_properties_sp);
2326 }
2327
2328 if (plugin_properties_sp) {
2329 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2330 plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
2331 if (!plugin_type_properties_sp && can_create) {
2332 plugin_type_properties_sp =
2333 std::make_shared<OptionValueProperties>(g_property_name);
2334 plugin_type_properties_sp->SetExpectedPath(
2335 (plugin_type_name + ".plugin").str());
2336 plugin_properties_sp->AppendProperty(g_property_name,
2337 "Settings specific to plugins",
2338 true, plugin_type_properties_sp);
2339 }
2340 return plugin_type_properties_sp;
2341 }
2342 }
2344}
2345
2346namespace {
2347
2349GetDebuggerPropertyForPluginsPtr(Debugger &, llvm::StringRef, llvm::StringRef,
2350 bool can_create);
2351}
2352
2354GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name,
2355 llvm::StringRef plugin_type_name,
2356 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2358 lldb::OptionValuePropertiesSP properties_sp;
2359 lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property(
2360 debugger, plugin_type_name,
2361 "", // not creating to so we don't need the description
2362 false));
2363 if (plugin_type_properties_sp)
2364 properties_sp =
2365 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2366 return properties_sp;
2367}
2368
2369static bool
2370CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name,
2371 llvm::StringRef plugin_type_desc,
2372 const lldb::OptionValuePropertiesSP &properties_sp,
2373 llvm::StringRef description, bool is_global_property,
2374 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2376 if (properties_sp) {
2377 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2378 get_debugger_property(debugger, plugin_type_name, plugin_type_desc,
2379 true));
2380 if (plugin_type_properties_sp) {
2381 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2382 description, is_global_property,
2383 properties_sp);
2384 return true;
2385 }
2386 }
2387 return false;
2388}
2389
2390static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader");
2391static constexpr llvm::StringLiteral kPlatformPluginName("platform");
2392static constexpr llvm::StringLiteral kProcessPluginName("process");
2393static constexpr llvm::StringLiteral kTracePluginName("trace");
2394static constexpr llvm::StringLiteral kObjectFilePluginName("object-file");
2395static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file");
2396static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator");
2397static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader");
2398static constexpr llvm::StringLiteral
2399 kStructuredDataPluginName("structured-data");
2400static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus");
2401
2404 llvm::StringRef setting_name) {
2405 return GetSettingForPlugin(debugger, setting_name, kDynamicLoaderPluginName);
2406}
2407
2409 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2410 llvm::StringRef description, bool is_global_property) {
2412 "Settings for dynamic loader plug-ins",
2413 properties_sp, description, is_global_property);
2414}
2415
2418 llvm::StringRef setting_name) {
2419 return GetSettingForPlugin(debugger, setting_name, kPlatformPluginName,
2421}
2422
2424 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2425 llvm::StringRef description, bool is_global_property) {
2427 "Settings for platform plug-ins", properties_sp,
2428 description, is_global_property,
2430}
2431
2434 llvm::StringRef setting_name) {
2435 return GetSettingForPlugin(debugger, setting_name, kProcessPluginName);
2436}
2437
2439 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2440 llvm::StringRef description, bool is_global_property) {
2442 "Settings for process plug-ins", properties_sp,
2443 description, is_global_property);
2444}
2445
2448 llvm::StringRef setting_name) {
2449 return GetSettingForPlugin(debugger, setting_name, kSymbolLocatorPluginName);
2450}
2451
2453 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2454 llvm::StringRef description, bool is_global_property) {
2456 "Settings for symbol locator plug-ins",
2457 properties_sp, description, is_global_property);
2458}
2459
2461 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2462 llvm::StringRef description, bool is_global_property) {
2464 "Settings for trace plug-ins", properties_sp,
2465 description, is_global_property);
2466}
2467
2470 llvm::StringRef setting_name) {
2471 return GetSettingForPlugin(debugger, setting_name, kObjectFilePluginName);
2472}
2473
2475 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2476 llvm::StringRef description, bool is_global_property) {
2478 "Settings for object file plug-ins",
2479 properties_sp, description, is_global_property);
2480}
2481
2484 llvm::StringRef setting_name) {
2485 return GetSettingForPlugin(debugger, setting_name, kSymbolFilePluginName);
2486}
2487
2489 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2490 llvm::StringRef description, bool is_global_property) {
2492 "Settings for symbol file plug-ins",
2493 properties_sp, description, is_global_property);
2494}
2495
2498 llvm::StringRef setting_name) {
2499 return GetSettingForPlugin(debugger, setting_name, kJITLoaderPluginName);
2500}
2501
2503 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2504 llvm::StringRef description, bool is_global_property) {
2506 "Settings for JIT loader plug-ins",
2507 properties_sp, description, is_global_property);
2508}
2509
2510static const char *kOperatingSystemPluginName("os");
2511
2513 Debugger &debugger, llvm::StringRef setting_name) {
2514 lldb::OptionValuePropertiesSP properties_sp;
2515 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2518 "", // not creating to so we don't need the description
2519 false));
2520 if (plugin_type_properties_sp)
2521 properties_sp =
2522 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2523 return properties_sp;
2524}
2525
2527 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2528 llvm::StringRef description, bool is_global_property) {
2529 if (properties_sp) {
2530 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2532 "Settings for operating system plug-ins",
2533 true));
2534 if (plugin_type_properties_sp) {
2535 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2536 description, is_global_property,
2537 properties_sp);
2538 return true;
2539 }
2540 }
2541 return false;
2542}
2543
2546 llvm::StringRef setting_name) {
2547 return GetSettingForPlugin(debugger, setting_name, kStructuredDataPluginName);
2548}
2549
2551 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2552 llvm::StringRef description, bool is_global_property) {
2554 "Settings for structured data plug-ins",
2555 properties_sp, description, is_global_property);
2556}
2557
2560 Debugger &debugger, llvm::StringRef setting_name) {
2561 return GetSettingForPlugin(debugger, setting_name, kCPlusPlusLanguagePlugin);
2562}
2563
2565 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2566 llvm::StringRef description, bool is_global_property) {
2568 "Settings for CPlusPlus language plug-ins",
2569 properties_sp, description, is_global_property);
2570}
2571
2572//
2573// Plugin Info+Enable Implementations
2574//
2575llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetABIPluginInfo() {
2577}
2578bool PluginManager::SetABIPluginEnabled(llvm::StringRef name, bool enable) {
2579 return GetABIInstances().SetInstanceEnabled(name, enable);
2580}
2581
2582llvm::SmallVector<RegisteredPluginInfo>
2587 bool enable) {
2588 return GetArchitectureInstances().SetInstanceEnabled(name, enable);
2589}
2590
2591llvm::SmallVector<RegisteredPluginInfo>
2596 bool enable) {
2597 return GetBugReporterInstances().SetInstanceEnabled(name, enable);
2598}
2599
2600llvm::SmallVector<RegisteredPluginInfo>
2605 bool enable) {
2606 return GetDisassemblerInstances().SetInstanceEnabled(name, enable);
2607}
2608
2609llvm::SmallVector<RegisteredPluginInfo>
2614 bool enable) {
2615 return GetDynamicLoaderInstances().SetInstanceEnabled(name, enable);
2616}
2617
2618llvm::SmallVector<RegisteredPluginInfo>
2623 bool enable) {
2625}
2626
2627llvm::SmallVector<RegisteredPluginInfo>
2631
2633 switch (kind) {
2635 return "global";
2637 return "debugger";
2639 return "target";
2640 }
2641 llvm_unreachable("unhandled PluginDomainKind");
2642}
2643
2645 llvm::StringRef name, bool enable, Debugger &requesting_debugger,
2646 PluginDomainKind domain) {
2647 if (domain != lldb::ePluginDomainKindGlobal)
2648 return llvm::createStringErrorV("{} domain is not supported",
2649 PluginDomainKindToStr(domain));
2650 if (!GetInstrumentationRuntimeInstances().SetInstanceEnabled(name, enable))
2651 return llvm::createStringError("plugin could not be found");
2652
2653 return llvm::Error::success();
2654}
2655
2656llvm::SmallVector<RegisteredPluginInfo>
2661 bool enable) {
2662 return GetJITLoaderInstances().SetInstanceEnabled(name, enable);
2663}
2664
2665llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetLanguagePluginInfo() {
2667}
2669 bool enable) {
2670 return GetLanguageInstances().SetInstanceEnabled(name, enable);
2671}
2672
2673llvm::SmallVector<RegisteredPluginInfo>
2678 bool enable) {
2679 return GetLanguageRuntimeInstances().SetInstanceEnabled(name, enable);
2680}
2681
2682llvm::SmallVector<RegisteredPluginInfo>
2687 bool enable) {
2688 return GetMemoryHistoryInstances().SetInstanceEnabled(name, enable);
2689}
2690
2691llvm::SmallVector<RegisteredPluginInfo>
2696 bool enable) {
2697 return GetObjectContainerInstances().SetInstanceEnabled(name, enable);
2698}
2699
2700llvm::SmallVector<RegisteredPluginInfo>
2705 bool enable) {
2706 return GetObjectFileInstances().SetInstanceEnabled(name, enable);
2707}
2708
2709llvm::SmallVector<RegisteredPluginInfo>
2714 bool enable) {
2715 return GetOperatingSystemInstances().SetInstanceEnabled(name, enable);
2716}
2717
2718llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetPlatformPluginInfo() {
2720}
2722 bool enable) {
2723 return GetPlatformInstances().SetInstanceEnabled(name, enable);
2724}
2725
2726llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetProcessPluginInfo() {
2728}
2729bool PluginManager::SetProcessPluginEnabled(llvm::StringRef name, bool enable) {
2730 return GetProcessInstances().SetInstanceEnabled(name, enable);
2731}
2732
2733llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetREPLPluginInfo() {
2735}
2736bool PluginManager::SetREPLPluginEnabled(llvm::StringRef name, bool enable) {
2737 return GetREPLInstances().SetInstanceEnabled(name, enable);
2738}
2739
2740llvm::SmallVector<RegisteredPluginInfo>
2745 bool enable) {
2747}
2748
2749llvm::SmallVector<RegisteredPluginInfo>
2754 bool enable) {
2756}
2757
2758llvm::SmallVector<RegisteredPluginInfo>
2763 bool enable) {
2765}
2766
2767llvm::SmallVector<RegisteredPluginInfo>
2772 bool enable) {
2774}
2775
2776llvm::SmallVector<RegisteredPluginInfo>
2781 bool enable) {
2782 return GetSymbolFileInstances().SetInstanceEnabled(name, enable);
2783}
2784
2785llvm::SmallVector<RegisteredPluginInfo>
2790 bool enable) {
2791 return GetSymbolLocatorInstances().SetInstanceEnabled(name, enable);
2792}
2793
2794llvm::SmallVector<RegisteredPluginInfo>
2799 bool enable) {
2800 return GetSymbolVendorInstances().SetInstanceEnabled(name, enable);
2801}
2802
2803llvm::SmallVector<RegisteredPluginInfo>
2808 bool enable) {
2809 return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable);
2810}
2811
2812llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetTracePluginInfo() {
2814}
2815bool PluginManager::SetTracePluginEnabled(llvm::StringRef name, bool enable) {
2816 return GetTracePluginInstances().SetInstanceEnabled(name, enable);
2817}
2818
2819llvm::SmallVector<RegisteredPluginInfo>
2824 bool enable) {
2825 return GetTraceExporterInstances().SetInstanceEnabled(name, enable);
2826}
2827
2828llvm::SmallVector<RegisteredPluginInfo>
2833 bool enable) {
2834 return GetTypeSystemInstances().SetInstanceEnabled(name, enable);
2835}
2836
2837llvm::SmallVector<RegisteredPluginInfo>
2842 bool enable) {
2843 return GetUnwindAssemblyInstances().SetInstanceEnabled(name, enable);
2844}
2845
2847 CompletionRequest &request) {
2848 // Split the name into the namespace and the plugin name.
2849 // If there is no dot then the ns_name will be equal to name and
2850 // plugin_prefix will be empty.
2851 llvm::StringRef ns_name, plugin_prefix;
2852 std::tie(ns_name, plugin_prefix) = name.split('.');
2853
2854 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
2855 // If the plugin namespace matches exactly then
2856 // add all the plugins in this namespace as completions if the
2857 // plugin names starts with the plugin_prefix. If the plugin_prefix
2858 // is empty then it will match all the plugins (empty string is a
2859 // prefix of everything).
2860 if (plugin_ns.name == ns_name) {
2861 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
2862 llvm::SmallString<128> buf;
2863 if (plugin.name.starts_with(plugin_prefix))
2864 request.AddCompletion(
2865 (plugin_ns.name + "." + plugin.name).toStringRef(buf));
2866 }
2867 } else if (plugin_ns.name.starts_with(name) &&
2868 !plugin_ns.get_info().empty()) {
2869 // Otherwise check if the namespace is a prefix of the full name.
2870 // Use a partial completion here so that we can either operate on the full
2871 // namespace or tab-complete to the next level.
2872 request.AddCompletion(plugin_ns.name, "", CompletionMode::Partial);
2873 }
2874 }
2875}
static llvm::raw_ostream & error(Stream &strm)
static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path)
Definition Debugger.cpp:907
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:405
static BugReporterInstances & GetBugReporterInstances()
static DisassemblerInstances & GetDisassemblerInstances()
PluginInstances< ProtocolServerInstance > ProtocolServerInstances
static TraceInstances & GetTracePluginInstances()
static ObjectContainerInstances & GetObjectContainerInstances()
PluginInstances< JITLoaderInstance > JITLoaderInstances
static MemoryHistoryInstances & GetMemoryHistoryInstances()
PluginInstance< PlatformCreateInstance > PlatformInstance
PluginInstances< HighlighterInstance > HighlighterInstances
static DynamicLoaderInstances & GetDynamicLoaderInstances()
PluginInstances< SymbolFileInstance > SymbolFileInstances
PluginInstances< TypeSystemInstance > TypeSystemInstances
PluginInstance< ABICreateInstance > ABIInstance
static SystemRuntimeInstances & GetSystemRuntimeInstances()
PluginInstances< TraceExporterInstance > TraceExporterInstances
static constexpr llvm::StringLiteral kPlatformPluginName("platform")
static constexpr llvm::StringLiteral g_plugin_prefix
PluginInstance< EmulateInstructionCreateInstance > EmulateInstructionInstance
static ScriptInterpreterErrors & GetScriptInterpreterErrors()
static ABIInstances & GetABIInstances()
static constexpr llvm::StringLiteral kProcessPluginName("process")
PluginInstances< SymbolVendorInstance > SymbolVendorInstances
static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader")
static lldb::OptionValuePropertiesSP GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name, llvm::StringRef plugin_type_name, GetDebuggerPropertyForPluginsPtr get_debugger_property=GetDebuggerPropertyForPlugins)
static ScriptInterpreterInstances & GetScriptInterpreterInstances()
PluginInstance< DynamicLoaderCreateInstance > DynamicLoaderInstance
PluginInstances< PlatformInstance > PlatformInstances
PluginInstance< JITLoaderCreateInstance > JITLoaderInstance
PluginInstance< ArchitectureCreateInstance > ArchitectureInstance
static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus")
PluginInstances< SystemRuntimeInstance > SystemRuntimeInstances
static TraceExporterInstances & GetTraceExporterInstances()
PluginInstance< LanguageCreateInstance > LanguageInstance
PluginInstances< BugReporterInstance > BugReporterInstances
PluginInstance< SymbolFileCreateInstance > SymbolFileInstance
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_name, llvm::StringRef plugin_type_desc, bool can_create)
static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator")
PluginInstances< ObjectFileInstance > ObjectFileInstances
static void ClearScriptInterpreterErrors()
void(* PluginTermCallback)()
static StructuredDataPluginInstances & GetStructuredDataPluginInstances()
static constexpr llvm::StringLiteral kObjectFilePluginName("object-file")
PluginInstances< MemoryHistoryInstance > MemoryHistoryInstances
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(Debugger &debugger, llvm::StringRef plugin_type_name, llvm::StringRef plugin_type_desc, bool can_create)
PluginInstances< DynamicLoaderInstance > DynamicLoaderInstances
PluginInstances< LanguageInstance > LanguageInstances
PluginInstances< TraceInstance > TraceInstances
PluginInstances< ArchitectureInstance > ArchitectureInstances
PluginInstances< StructuredDataPluginInstance > StructuredDataPluginInstances
static constexpr llvm::StringLiteral kStructuredDataPluginName("structured-data")
PluginInstance< MemoryHistoryCreateInstance > MemoryHistoryInstance
static const char * kOperatingSystemPluginName("os")
static SymbolLocatorInstances & GetSymbolLocatorInstances()
PluginInstance< ProtocolServerCreateInstance > ProtocolServerInstance
PluginInstance< OperatingSystemCreateInstance > OperatingSystemInstance
static ObjectFileInstances & GetObjectFileInstances()
static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file")
PluginInstances< SymbolLocatorInstance > SymbolLocatorInstances
PluginInstance< SystemRuntimeCreateInstance > SystemRuntimeInstance
PluginInstance< SymbolVendorCreateInstance > SymbolVendorInstance
static EmulateInstructionInstances & GetEmulateInstructionInstances()
PluginInstance< UnwindAssemblyCreateInstance > UnwindAssemblyInstance
static LanguageInstances & GetLanguageInstances()
static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader")
static ScriptedFrameProviderInstances & GetScriptedFrameProviderInstances()
PluginInstances< OperatingSystemInstance > OperatingSystemInstances
static LanguageRuntimeInstances & GetLanguageRuntimeInstances()
PluginInstances< LanguageRuntimeInstance > LanguageRuntimeInstances
static InstrumentationRuntimeInstances & GetInstrumentationRuntimeInstances()
PluginInstances< ProcessInstance > ProcessInstances
PluginInstances< SyntheticFrameProviderInstance > SyntheticFrameProviderInstances
PluginInstances< REPLInstance > REPLInstances
static ArchitectureInstances & GetArchitectureInstances()
static DynamicPluginMap & GetPluginMap()
PluginInstances< ScriptedFrameProviderInstance > ScriptedFrameProviderInstances
PluginInstance< BugReporterCreateInstance > BugReporterInstance
static PluginRegistry & GetPluginRegistry()
static RegisterTypeBuilderInstances & GetRegisterTypeBuilderInstances()
static std::recursive_mutex & GetPluginMapMutex()
llvm::SmallDenseMap< FileSpec, PluginInfo > DynamicPluginMap
static HighlighterInstances & GetHighlighterInstances()
static TypeSystemInstances & GetTypeSystemInstances()
static PlatformInstances & GetPlatformInstances()
static ScriptedInterfaceInstances & GetScriptedInterfaceInstances()
static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path)
PluginInstances< EmulateInstructionInstance > EmulateInstructionInstances
PluginInstance< SyntheticFrameProviderCreateInstance > SyntheticFrameProviderInstance
static JITLoaderInstances & GetJITLoaderInstances()
PluginInstances< DisassemblerInstance > DisassemblerInstances
PluginInstance< ProcessCreateInstance > ProcessInstance
static UnwindAssemblyInstances & GetUnwindAssemblyInstances()
static void SetPluginInfo(const FileSpec &plugin_file_spec, PluginInfo plugin_info)
PluginInstances< ScriptedInterfaceInstance > ScriptedInterfaceInstances
PluginInstances< UnwindAssemblyInstance > UnwindAssemblyInstances
static SymbolFileInstances & GetSymbolFileInstances()
static bool CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name, llvm::StringRef plugin_type_desc, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property, GetDebuggerPropertyForPluginsPtr get_debugger_property=GetDebuggerPropertyForPlugins)
PluginInstances< ABIInstance > ABIInstances
static FPtrTy CastToFPtr(void *VPtr)
static ProcessInstances & GetProcessInstances()
static bool PluginIsLoaded(const FileSpec &plugin_file_spec)
static OperatingSystemInstances & GetOperatingSystemInstances()
static constexpr llvm::StringLiteral kTracePluginName("trace")
PluginInstance< ScriptedFrameProviderCreateInstance > ScriptedFrameProviderInstance
PluginInstances< ScriptInterpreterInstance > ScriptInterpreterInstances
static SyntheticFrameProviderInstances & GetSyntheticFrameProviderInstances()
bool(* PluginInitCallback)()
PluginInstance< DisassemblerCreateInstance > DisassemblerInstance
static SymbolVendorInstances & GetSymbolVendorInstances()
PluginInstances< ObjectContainerInstance > ObjectContainerInstances
static ProtocolServerInstances & GetProtocolServerInstances()
PluginInstances< RegisterTypeBuilderInstance > RegisterTypeBuilderInstances
static REPLInstances & GetREPLInstances()
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
bool UnregisterPlugin(typename Instance::CallbackType callback)
std::optional< ABIInstance > FindInstance(std::function< bool(const ABIInstance &)> predicate) const
llvm::StringRef GetNameAtIndex(uint32_t idx)
llvm::SmallVector< ABIInstance > m_instances
llvm::StringRef GetDescriptionAtIndex(uint32_t idx)
llvm::SmallVector< typename Instance::CallbackType > GetCreateCallbacks()
std::optional< ABIInstance > GetInstanceAtIndex(uint32_t idx)
llvm::SmallVector< RegisteredPluginInfo > GetPluginInfoForAllInstances()
Instance::CallbackType GetCallbackForName(llvm::StringRef name)
llvm::SmallVector< ABIInstance > GetSnapshot(bool enabled_only=true) const
bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, typename Instance::CallbackType callback, Args &&...args)
void PerformDebuggerCallback(Debugger &debugger)
std::optional< ABIInstance > FindEnabledInstance(std::function< bool(const ABIInstance &)> predicate) const
std::optional< ABIInstance > GetInstanceForName(llvm::StringRef name, bool enabled_only=true)
bool SetInstanceEnabled(llvm::StringRef name, bool enable)
An architecture specification class.
Definition ArchSpec.h:32
A command line argument class.
Definition Args.h:33
"lldb/Utility/ArgCompletionRequest.h"
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
A class to manage flag bits.
Definition Debugger.h:103
A class that measures elapsed time in an exception safe way.
Definition Statistics.h:76
A file collection class.
A file utility class.
Definition FileSpec.h:56
llvm::StringRef GetFileNameStrippingExtension() const
Return the filename without the extension part.
Definition FileSpec.cpp:414
llvm::StringRef GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:248
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:380
llvm::StringRef GetFileNameExtension() const
Extract the extension of the file.
Definition FileSpec.cpp:410
void EnumerateDirectory(llvm::Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, void *callback_baton)
@ eEnumerateDirectoryResultEnter
Recurse into the current entry if it is a directory or symlink, or next if not.
Definition FileSystem.h:185
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
Definition FileSystem.h:182
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static bool SetArchitecturePluginEnabled(llvm::StringRef name, bool enable)
static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx)
static bool SetPlatformPluginEnabled(llvm::StringRef name, bool enable)
static bool SetScriptInterpreterPluginEnabled(llvm::StringRef name, bool enable)
static bool MatchPluginName(llvm::StringRef pattern, const PluginNamespace &plugin_ns, const RegisteredPluginInfo &plugin)
static lldb::OptionValuePropertiesSP GetSettingForStructuredDataPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool SetMemoryHistoryPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetSystemRuntimePluginInfo()
static llvm::SmallVector< RegisteredPluginInfo > GetTypeSystemPluginInfo()
static void AutoCompleteScriptedExtension(llvm::StringRef partial_name, CompletionRequest &request, lldb::ScriptLanguage language=lldb::eScriptLanguageUnknown)
static bool CreateSettingForJITLoaderPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool SetRegisterTypeBuilderPluginEnabled(llvm::StringRef name, bool enable)
static llvm::StringRef PluginDomainKindToStr(lldb::PluginDomainKind kind)
static bool SetTraceExporterPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetArchitecturePluginInfo()
static void ForEachScriptedExtension(llvm::function_ref< void(const ScriptedInterfaceInstance &)> callback, lldb::ScriptLanguage language=lldb::eScriptLanguageUnknown)
Invoke callback once per registered scripted extension, passing the first interface registered for it...
static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions()
static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static llvm::SmallVector< UnwindAssemblyCreateInstance > GetUnwindAssemblyCreateCallbacks()
static lldb::OptionValuePropertiesSP GetSettingForObjectFilePlugin(Debugger &debugger, llvm::StringRef setting_name)
static llvm::SmallVector< RegisteredPluginInfo > GetEmulateInstructionPluginInfo()
static void AutoCompletePlatformName(llvm::StringRef partial_name, CompletionRequest &request)
static TraceExporterCreateInstance GetTraceExporterCreateCallback(llvm::StringRef plugin_name)
static bool SetDynamicLoaderPluginEnabled(llvm::StringRef name, bool enable)
static llvm::json::Object GetJSON(llvm::StringRef pattern="")
static bool CreateSettingForObjectFilePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool SetScriptedInterfacePluginEnabled(llvm::StringRef name, bool enable)
static bool SetOperatingSystemPluginEnabled(llvm::StringRef name, bool enable)
static lldb::ScriptInterpreterSP GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, Debugger &debugger)
static llvm::SmallVector< ABICreateInstance > GetABICreateCallbacks()
static llvm::SmallVector< InstrumentationRuntimeCallbacks > GetInstrumentationRuntimeCallbacks(bool enabled_only=true)
static void AutoCompleteProcessName(llvm::StringRef partial_name, CompletionRequest &request)
static llvm::SmallVector< RegisteredPluginInfo > GetScriptInterpreterPluginInfo()
static bool SetBugReporterPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetABIPluginInfo()
static llvm::SmallVector< RegisteredPluginInfo > GetLanguagePluginInfo()
static LanguageSet GetREPLAllTypeSystemSupportedLanguages()
static llvm::SmallVector< OperatingSystemCreateInstance > GetOperatingSystemCreateCallbacks()
static bool CreateSettingForTracePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static llvm::SmallVector< RegisteredPluginInfo > GetDynamicLoaderPluginInfo()
static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger, llvm::StringRef setting_name)
static llvm::Error SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, bool enable, Debugger &requesting_debugger, lldb::PluginDomainKind domain)
static llvm::SmallVector< ProcessCreateInstance > GetProcessCreateCallbacks()
static llvm::SmallVector< RegisteredPluginInfo > GetObjectContainerPluginInfo()
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
static llvm::SmallVector< RegisteredPluginInfo > GetDisassemblerPluginInfo()
static llvm::SmallVector< LanguageRuntimeCallbacks > GetLanguageRuntimeCallbacks()
static llvm::SmallVector< SymbolFileCreateInstance > GetSymbolFileCreateCallbacks()
static bool SetLanguageRuntimePluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetObjectFilePluginInfo()
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t idx)
static void SetScriptInterpreterError(lldb::ScriptLanguage script_lang, llvm::Error error)
Records why no script interpreter for script_lang could be registered, for the fallback interpreter t...
static llvm::SmallVector< RegisteredPluginInfo > GetSymbolLocatorPluginInfo()
static llvm::StringRef GetTraceSchema(llvm::StringRef plugin_name)
Get the JSON schema for a trace bundle description file corresponding to the given plugin.
static llvm::SmallVector< SymbolVendorCreateInstance > GetSymbolVendorCreateCallbacks()
static bool SetUnwindAssemblyPluginEnabled(llvm::StringRef name, bool enable)
static lldb::OptionValuePropertiesSP GetSettingForCPlusPlusLanguagePlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool SetDisassemblerPluginEnabled(llvm::StringRef name, bool enable)
static bool SetSystemRuntimePluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetTracePluginInfo()
static llvm::SmallVector< JITLoaderCreateInstance > GetJITLoaderCreateCallbacks()
static llvm::SmallVector< RegisteredPluginInfo > GetProcessPluginInfo()
static TraceCreateInstanceForLiveProcess GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name)
static std::unique_ptr< Architecture > CreateArchitectureInstance(const ArchSpec &arch)
static llvm::SmallVector< DisassemblerCreateInstance > GetDisassemblerCreateCallbacks()
static lldb::OptionValuePropertiesSP GetSettingForSymbolLocatorPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool SetStructuredDataPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< ObjectFileCallbacks > GetObjectFileCallbacks()
static llvm::SmallVector< RegisteredPluginInfo > GetLanguageRuntimePluginInfo()
static bool SetObjectContainerPluginEnabled(llvm::StringRef name, bool enable)
static bool CreateSettingForProcessPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static llvm::SmallVector< RegisteredPluginInfo > GetPlatformPluginInfo()
static llvm::SmallVector< RegisteredPluginInfo > GetMemoryHistoryPluginInfo()
static llvm::SmallVector< TypeSystemCreateInstance > GetTypeSystemCreateCallbacks()
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, llvm::StringRef setting_name)
static llvm::SmallVector< RegisteredPluginInfo > GetSymbolFilePluginInfo()
static SyntheticFrameProviderCreateInstance GetSyntheticFrameProviderCreateCallbackForPluginName(llvm::StringRef name)
static llvm::SmallVector< SymbolLocatorCreateInstance > GetSymbolLocatorCreateCallbacks()
static llvm::ArrayRef< PluginNamespace > GetPluginNamespaces()
static bool SetTypeSystemPluginEnabled(llvm::StringRef name, bool enable)
static bool SetTracePluginEnabled(llvm::StringRef name, bool enable)
static Status SaveCore(lldb_private::SaveCoreOptions &core_options)
static llvm::SmallVector< RegisteredPluginInfo > GetTraceExporterPluginInfo()
static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec, const FileSpecList &default_search_paths, StatisticsMap &map)
static bool SetEmulateInstructionPluginEnabled(llvm::StringRef name, bool enable)
static lldb::OptionValuePropertiesSP GetSettingForJITLoaderPlugin(Debugger &debugger, llvm::StringRef setting_name)
static DisassemblerCreateInstance GetDisassemblerCreateCallbackForPluginName(llvm::StringRef name)
static bool SetJITLoaderPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetInstrumentationRuntimePluginInfo()
static llvm::SmallVector< REPLCallbacks > GetREPLCallbacks()
static bool CreateSettingForSymbolFilePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool CreateSettingForPlatformPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static OperatingSystemCreateInstance GetOperatingSystemCreateCallbackForPluginName(llvm::StringRef name)
static bool SetSymbolFilePluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< ScriptInterpreterCreateInstance > GetScriptInterpreterCreateCallbacks()
static llvm::SmallVector< RegisteredPluginInfo > GetRegisterTypeBuilderPluginInfo()
static EmulateInstructionCreateInstance GetEmulateInstructionCreateCallbackForPluginName(llvm::StringRef name)
static lldb::OptionValuePropertiesSP GetSettingForSymbolFilePlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForStructuredDataPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static size_t GetNumScriptedInterfaces()
static bool CreateSettingForCPlusPlusLanguagePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static llvm::SmallVector< TraceExporterCallbacks > GetTraceExporterCallbacks()
static llvm::SmallVector< RegisteredPluginInfo > GetSymbolVendorPluginInfo()
static llvm::SmallVector< RegisteredPluginInfo > GetBugReporterPluginInfo()
static DynamicLoaderCreateInstance GetDynamicLoaderCreateCallbackForPluginName(llvm::StringRef name)
static llvm::SmallVector< EmulateInstructionCreateInstance > GetEmulateInstructionCreateCallbacks()
static PlatformCreateInstance GetPlatformCreateCallbackForPluginName(llvm::StringRef name)
static bool SetProcessPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< llvm::StringRef > GetSaveCorePluginNames()
static llvm::SmallVector< RegisteredPluginInfo > GetOperatingSystemPluginInfo()
static llvm::SmallVector< ScriptedFrameProviderCreateInstance > GetScriptedFrameProviderCreateCallbacks()
static bool SetABIPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetScriptedInterfacePluginInfo()
static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin(Debugger &debugger, llvm::StringRef setting_name)
static ProcessCreateInstance GetProcessCreateCallbackForPluginName(llvm::StringRef name)
static lldb::ScriptedExtension GetScriptedInterfaceExtensionAtIndex(uint32_t idx)
static void AutoCompletePluginName(llvm::StringRef partial_name, CompletionRequest &request)
static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx)
static llvm::StringRef GetProcessPluginDescriptionAtIndex(uint32_t idx)
static llvm::StringRef GetProtocolServerPluginNameAtIndex(uint32_t idx)
static bool IsRegisteredObjectFilePluginName(llvm::StringRef name)
static lldb::OptionValuePropertiesSP GetSettingForDynamicLoaderPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForDynamicLoaderPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool SetLanguagePluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< RegisteredPluginInfo > GetREPLPluginInfo()
static bool SetREPLPluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< HighlighterCreateInstance > GetHighlighterCreateCallbacks()
static llvm::SmallVector< RegisteredPluginInfo > GetUnwindAssemblyPluginInfo()
static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx)
static bool SetSymbolVendorPluginEnabled(llvm::StringRef name, bool enable)
static TraceCreateInstanceFromBundle GetTraceCreateCallback(llvm::StringRef plugin_name)
static void DebuggerInitialize(Debugger &debugger)
static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx)
static llvm::SmallVector< ObjectContainerCallbacks > GetObjectContainerCallbacks()
static llvm::StringRef GetProcessPluginNameAtIndex(uint32_t idx)
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec, StatisticsMap &map)
static llvm::SmallVector< StructuredDataPluginCallbacks > GetStructuredDataPluginCallbacks()
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes()
static llvm::Error GetScriptInterpreterError(lldb::ScriptLanguage script_lang)
Returns the error recorded for script_lang, or success.
static llvm::SmallVector< SystemRuntimeCreateInstance > GetSystemRuntimeCreateCallbacks()
static FileSpec GetScriptInterpreterLibraryPath(lldb::ScriptLanguage script_lang)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
static llvm::SmallVector< RegisteredPluginInfo > GetStructuredDataPluginInfo()
static bool SetSymbolLocatorPluginEnabled(llvm::StringRef name, bool enable)
static ProtocolServerCreateInstance GetProtocolCreateCallbackForPluginName(llvm::StringRef name)
static llvm::SmallVector< LanguageCreateInstance > GetLanguageCreateCallbacks()
static std::unique_ptr< BugReporter > CreateBugReporterInstance(llvm::StringRef name={})
static llvm::SmallVector< DynamicLoaderCreateInstance > GetDynamicLoaderCreateCallbacks()
static lldb::RegisterTypeBuilderSP GetRegisterTypeBuilder(Target &target)
static llvm::SmallVector< MemoryHistoryCreateInstance > GetMemoryHistoryCreateCallbacks()
static ScriptedInterfaceUsages GetScriptedInterfaceUsagesAtIndex(uint32_t idx)
static ObjectFileCreateMemoryInstance GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name)
static bool CreateSettingForSymbolLocatorPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static llvm::SmallVector< RegisteredPluginInfo > GetJITLoaderPluginInfo()
static bool SetObjectFilePluginEnabled(llvm::StringRef name, bool enable)
static llvm::SmallVector< PlatformCreateInstance > GetPlatformCreateCallbacks()
lldb::OptionValuePropertiesSP GetValueProperties() const
const std::optional< lldb_private::FileSpec > GetOutputFile() const
std::optional< std::string > GetPluginName() const
lldb::ProcessSP GetProcess() const
static llvm::StringLiteral ExtensionToString(lldb::ScriptedExtension extension)
A class to count time for plugins.
Definition Statistics.h:94
void add(llvm::StringRef key, double value)
Definition Statistics.h:96
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:136
Represents UUID's of various sizes.
Definition UUID.h:27
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
SymbolVendor *(* SymbolVendorCreateInstance)(const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm)
bool(* ObjectFileSaveCore)(const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &options, Status &error)
llvm::Expected< lldb::TraceSP >(* TraceCreateInstanceForLiveProcess)(Process &process)
FileSpec(* ScriptInterpreterGetPath)()
lldb::ScriptInterpreterSP(* ScriptInterpreterCreateInstance)(Debugger &debugger, lldb::ScriptLanguage language)
lldb::RegisterTypeBuilderSP(* RegisterTypeBuilderCreateInstance)(Target &target)
lldb::ProtocolServerUP(* ProtocolServerCreateInstance)()
LanguageRuntime *(* LanguageRuntimeCreateInstance)(Process *process, lldb::LanguageType language)
lldb::InstrumentationRuntimeType(* InstrumentationRuntimeGetType)()
llvm::Expected< lldb::TraceSP >(* TraceCreateInstanceFromBundle)(const llvm::json::Value &trace_bundle_description, llvm::StringRef session_file_dir, lldb_private::Debugger &debugger)
Trace.
lldb::DisassemblerSP(* DisassemblerCreateInstance)(const ArchSpec &arch, const char *flavor, const char *cpu, const char *features)
std::optional< FileSpec >(* SymbolLocatorLocateExecutableSymbolFile)(const ModuleSpec &module_spec, const FileSpecList &default_search_paths)
EmulateInstruction *(* EmulateInstructionCreateInstance)(const ArchSpec &arch, InstructionType inst_type)
ObjectContainer *(* ObjectContainerCreateMemoryInstance)(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset)
void(* DebuggerInitializeCallback)(Debugger &debugger)
std::unique_ptr< Architecture >(* ArchitectureCreateInstance)(const ArchSpec &arch)
lldb::PlatformSP(* PlatformCreateInstance)(bool force, const ArchSpec *arch)
bool(* ScriptedInterfaceCreateInstance)(lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
SystemRuntime *(* SystemRuntimeCreateInstance)(Process *process)
lldb::ProcessSP(* ProcessCreateInstance)(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
UnwindAssembly *(* UnwindAssemblyCreateInstance)(const ArchSpec &arch)
lldb::TypeSystemSP(* TypeSystemCreateInstance)(lldb::LanguageType language, Module *module, Target *target)
lldb::BreakpointPreconditionSP(* LanguageRuntimeGetExceptionPrecondition)(lldb::LanguageType language, bool throw_bp)
ObjectContainer *(* ObjectContainerCreateInstance)(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
lldb::MemoryHistorySP(* MemoryHistoryCreateInstance)(const lldb::ProcessSP &process_sp)
ObjectFile *(* ObjectFileCreateMemoryInstance)(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset)
SymbolLocator *(* SymbolLocatorCreateInstance)()
std::unique_ptr< BugReporter >(* BugReporterCreateInstance)()
std::optional< ModuleSpec >(* SymbolLocatorLocateExecutableObjectFile)(const ModuleSpec &module_spec)
@ Partial
The current token has been partially completed.
lldb::CommandObjectSP(* LanguageRuntimeGetCommandObject)(CommandInterpreter &interpreter)
DynamicLoader *(* DynamicLoaderCreateInstance)(Process *process, bool force)
lldb::StructuredDataPluginSP(* StructuredDataPluginCreateInstance)(Process &process)
lldb::JITLoaderSP(* JITLoaderCreateInstance)(Process *process, bool force)
llvm::Expected< lldb::SyntheticFrameProviderSP >(* SyntheticFrameProviderCreateInstance)(lldb::StackFrameListSP input_frames, const std::vector< lldb_private::ThreadSpec > &thread_specs)
OperatingSystem *(* OperatingSystemCreateInstance)(Process *process, bool force)
lldb::REPLSP(* REPLCreateInstance)(Status &error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
SymbolFile *(* SymbolFileCreateInstance)(lldb::ObjectFileSP objfile_sp)
llvm::Expected< lldb::TraceExporterUP >(* TraceExporterCreateInstance)()
Highlighter *(* HighlighterCreateInstance)(lldb::LanguageType language)
std::optional< FileSpec >(* SymbolLocatorFindSymbolFileInBundle)(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
bool(* SymbolLocatorDownloadObjectAndSymbolFile)(ModuleSpec &module_spec, Status &error, bool force_lookup, bool copy_executable)
Language *(* LanguageCreateInstance)(lldb::LanguageType language)
Status(* StructuredDataFilterLaunchInfo)(ProcessLaunchInfo &launch_info, Target *target)
ObjectFile *(* ObjectFileCreateInstance)(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
ModuleSpecList(* ObjectFileGetModuleSpecifications)(const FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
lldb::ABISP(* ABICreateInstance)(lldb::ProcessSP process_sp, const ArchSpec &arch)
llvm::Expected< lldb::SyntheticFrameProviderSP >(* ScriptedFrameProviderCreateInstance)(lldb::StackFrameListSP input_frames, const lldb_private::ScriptedFrameProviderDescriptor &descriptor)
lldb::CommandObjectSP(* ThreadTraceExportCommandCreator)(CommandInterpreter &interpreter)
lldb::InstrumentationRuntimeSP(* InstrumentationRuntimeCreateInstance)(const lldb::ProcessSP &process_sp)
ScriptLanguage
Script interpreter types.
@ eScriptLanguageUnknown
@ eScriptLanguageNone
std::shared_ptr< lldb_private::OptionValueProperties > OptionValuePropertiesSP
ScriptedExtension
Scripting extension types.
@ eScriptedExtensionInvalid
std::shared_ptr< lldb_private::ScriptInterpreter > ScriptInterpreterSP
@ ePluginDomainKindTarget
@ ePluginDomainKindGlobal
@ ePluginDomainKindDebugger
std::shared_ptr< lldb_private::RegisterTypeBuilder > RegisterTypeBuilderSP
HighlighterInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback)
InstrumentationRuntimeGetType get_type_callback
InstrumentationRuntimeInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, InstrumentationRuntimeGetType get_type_callback)
InstrumentationRuntimeGetType GetTypeCallbackForName(llvm::StringRef name, bool enabled_only)
LanguageRuntimeGetExceptionPrecondition precondition_callback
LanguageRuntimeInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, DebuggerInitializeCallback debugger_init_callback, LanguageRuntimeGetCommandObject command_callback, LanguageRuntimeGetExceptionPrecondition precondition_callback)
LanguageRuntimeGetCommandObject command_callback
ObjectFileGetModuleSpecifications get_module_specifications
ObjectContainerInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, ObjectContainerCreateMemoryInstance create_memory_callback, ObjectFileGetModuleSpecifications get_module_specifications)
ObjectContainerCreateMemoryInstance create_memory_callback
ObjectFileCreateMemoryInstance create_memory_callback
ObjectFileGetModuleSpecifications get_module_specifications
ObjectFileInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, ObjectFileCreateMemoryInstance create_memory_callback, ObjectFileGetModuleSpecifications get_module_specifications, ObjectFileSaveCore save_core, DebuggerInitializeCallback debugger_init_callback)
ObjectFileSaveCore save_core
PluginDir(FileSpec path, LoadPolicy policy)
const LoadPolicy policy
Filter when looking for plugins.
const FileSpec path
The path to the plugin directory.
@ LoadOnlyWithLLDBPrefix
Only load shared libraries who's filename start with g_plugin_prefix.
@ LoadAnyDylib
Try to load anything that looks like a shared library.
PluginTermCallback plugin_term_callback
PluginInfo()=default
llvm::sys::DynamicLibrary library
PluginInfo & operator=(PluginInfo &&other)
PluginInitCallback plugin_init_callback
PluginInfo(const PluginInfo &)=delete
PluginInfo(PluginInfo &&other)
static llvm::Expected< PluginInfo > Create(const FileSpec &path)
PluginInfo & operator=(const PluginInfo &)=delete
LanguageSet supported_languages
REPLInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, LanguageSet supported_languages)
RegisterTypeBuilderInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback)
ScriptInterpreterInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, lldb::ScriptLanguage language, ScriptInterpreterGetPath get_path_callback)
lldb::ScriptLanguage language
ScriptInterpreterGetPath get_path_callback
StructuredDataPluginInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, DebuggerInitializeCallback debugger_init_callback, StructuredDataFilterLaunchInfo filter_callback)
StructuredDataFilterLaunchInfo filter_callback
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle
SymbolLocatorInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, SymbolLocatorLocateExecutableObjectFile locate_executable_object_file, SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file, SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file, SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle, DebuggerInitializeCallback debugger_init_callback)
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file
SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file
ThreadTraceExportCommandCreator create_thread_trace_export_command
TraceExporterInstance(llvm::StringRef name, llvm::StringRef description, TraceExporterCreateInstance create_instance, ThreadTraceExportCommandCreator create_thread_trace_export_command)
llvm::StringRef schema
TraceInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback_from_bundle, TraceCreateInstanceForLiveProcess create_callback_for_live_process, llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback)
TraceCreateInstanceForLiveProcess create_callback_for_live_process
LanguageSet supported_languages_for_expressions
TypeSystemInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, LanguageSet supported_languages_for_types, LanguageSet supported_languages_for_expressions, DebuggerInitializeCallback debugger_init_callback)
LanguageSet supported_languages_for_types
A SmallBitVector that represents a set of source languages (lldb::LanguageType).