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 <map>
32#include <memory>
33#include <mutex>
34#include <string>
35#include <utility>
36#if defined(_WIN32)
38#endif
39
40using namespace lldb;
41using namespace lldb_private;
42
44typedef void (*PluginTermCallback)();
45
46struct PluginInfo {
47 PluginInfo() = default;
48
49 PluginInfo(const PluginInfo &) = delete;
50 PluginInfo &operator=(const PluginInfo &) = delete;
51
53 : library(std::move(other.library)),
55 std::exchange(other.plugin_init_callback, nullptr)),
57 std::exchange(other.plugin_term_callback, nullptr)) {}
58
60 library = std::move(other.library);
61 plugin_init_callback = std::exchange(other.plugin_init_callback, nullptr);
62 plugin_term_callback = std::exchange(other.plugin_term_callback, nullptr);
63 return *this;
64 }
65
67 if (!library.isValid())
68 return;
70 return;
72 }
73
74 static llvm::Expected<PluginInfo> Create(const FileSpec &path);
75
76private:
77 llvm::sys::DynamicLibrary library;
80};
81
82typedef llvm::SmallDenseMap<FileSpec, PluginInfo> DynamicPluginMap;
83
84namespace {
85enum class PluginLifecycle { Uninitialized, Initialized, Terminated };
86
87struct PluginRegistry {
88 std::recursive_mutex mutex;
90
91 void Initialize() {
92 std::lock_guard<std::recursive_mutex> guard(mutex);
93 lifecycle = PluginLifecycle::Initialized;
94 }
95
96 void Terminate() {
97 std::lock_guard<std::recursive_mutex> guard(mutex);
98 lifecycle = PluginLifecycle::Terminated;
99 map.clear();
100 }
101
102 // Only after Terminate() is a leftover PluginInstances registration a bug;
103 // exiting in any other state (e.g. `import lldb`, which never calls
104 // Terminate()) is supported and leaves plugins registered.
105 bool IsTerminated() const { return lifecycle == PluginLifecycle::Terminated; }
106
107private:
108 PluginLifecycle lifecycle = PluginLifecycle::Uninitialized;
109};
110} // namespace
111
112// Never destroyed: at static-destruction time the PluginInstances containers
113// (separate statics, arbitrary teardown order) still call IsTerminated(), and
114// the map's PluginInfo terminate callbacks must not run when the containers
115// they unregister from may already be gone. Terminate() clears the map
116// explicitly while everything is alive. The static pointer keeps it reachable,
117// so this is not a LeakSanitizer leak.
118static PluginRegistry &GetPluginRegistry() {
119 static PluginRegistry *g_registry = new PluginRegistry();
120 return *g_registry;
121}
122
123static std::recursive_mutex &GetPluginMapMutex() {
124 return GetPluginRegistry().mutex;
125}
126
128
129static bool PluginIsLoaded(const FileSpec &plugin_file_spec) {
130 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
131 return GetPluginMap().contains(plugin_file_spec);
132}
133
134static void SetPluginInfo(const FileSpec &plugin_file_spec,
135 PluginInfo plugin_info) {
136 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
137 DynamicPluginMap &plugin_map = GetPluginMap();
138 assert(!plugin_map.contains(plugin_file_spec));
139 plugin_map.try_emplace(plugin_file_spec, std::move(plugin_info));
140}
141
142template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
143 return reinterpret_cast<FPtrTy>(VPtr);
144}
145
146static constexpr llvm::StringLiteral g_plugin_prefix = "liblldbPlugin";
147struct PluginDir {
149 /// Try to load anything that looks like a shared library.
151
152 /// Only load shared libraries who's filename start with g_plugin_prefix.
154 };
155
158
159 explicit operator bool() const { return FileSystem::Instance().Exists(path); }
160
161 /// The path to the plugin directory.
163
164 /// Filter when looking for plugins.
166};
167
168llvm::Expected<PluginInfo> PluginInfo::Create(const FileSpec &path) {
169 PluginInfo plugin_info;
170 std::string error;
171 plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary(
172 path.GetPath().c_str(), &error);
173 if (!plugin_info.library.isValid())
174 return llvm::createStringError(error);
175
176 // Look for files that follow the convention <g_plugin_prefix><name>.<ext>, in
177 // which case we need to call lldb_initialize_<name> and
178 // lldb_terminate_<name>.
179 llvm::StringRef file_name = path.GetFileNameStrippingExtension();
180 if (file_name.starts_with(g_plugin_prefix)) {
181 llvm::StringRef plugin_name = file_name.substr(g_plugin_prefix.size());
182 std::string init_symbol =
183 llvm::Twine("lldb_initialize_" + plugin_name).str();
184
185 if (auto *init_fn = CastToFPtr<PluginInitCallback>(
186 plugin_info.library.getAddressOfSymbol(init_symbol.c_str()))) {
187 if (!init_fn())
188 return llvm::createStringErrorV("initializer '{0}' returned false",
189 init_symbol);
190 const std::string term_symbol =
191 llvm::Twine("lldb_terminate_" + plugin_name).str();
193 plugin_info.library.getAddressOfSymbol(term_symbol.c_str()));
194 }
195 return plugin_info;
196 }
197
198 // Look for the legacy LLDBPluginInitialize/LLDBPluginTerminate symbols.
199 if (auto *init_fn = CastToFPtr<PluginInitCallback>(
200 plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"))) {
201 if (!init_fn())
202 return llvm::createStringError(
203 "initializer 'LLDBPluginInitialize' returned false");
204
205 plugin_info.plugin_init_callback = init_fn;
207 plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
208 return plugin_info;
209 }
210
211 return llvm::createStringError("no initialize symbol found");
212}
213
215LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
216 llvm::StringRef path) {
217 namespace fs = llvm::sys::fs;
218
219 static constexpr std::array<llvm::StringLiteral, 3>
220 g_shared_library_extension = {".dylib", ".so", ".dll"};
221
222 // If we have a regular file, a symbolic link or unknown file type, try and
223 // process the file. We must handle unknown as sometimes the directory
224 // enumeration might be enumerating a file system that doesn't have correct
225 // file type information.
226 if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
227 ft == fs::file_type::type_unknown) {
228 FileSpec plugin_file_spec(path);
229 FileSystem::Instance().Resolve(plugin_file_spec);
230
231 // Don't try to load unknown extensions.
232 if (!llvm::is_contained(g_shared_library_extension,
233 plugin_file_spec.GetFileNameExtension()))
235
236 // Don't try to load libraries that don't start with g_plugin_prefix if so
237 // requested.
239 if (*policy == PluginDir::LoadOnlyWithLLDBPrefix &&
240 !plugin_file_spec.GetFilename().starts_with(g_plugin_prefix))
242
243 // Don't try to load an already loaded plugin again.
244 if (PluginIsLoaded(plugin_file_spec))
246
247 llvm::Expected<PluginInfo> plugin_info =
248 PluginInfo::Create(plugin_file_spec);
249 if (plugin_info) {
250 SetPluginInfo(plugin_file_spec, std::move(*plugin_info));
251 } else {
252 // Cache an empty plugin info so we don't try to load it again and again.
253 SetPluginInfo(plugin_file_spec, PluginInfo());
254
255 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), plugin_info.takeError(),
256 "could not load plugin: {0}");
257 }
258
260 }
261
262 if (ft == fs::file_type::directory_file ||
263 ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
264 // Try and recurse into anything that a directory or symbolic link. We must
265 // also do this for unknown as sometimes the directory enumeration might be
266 // enumerating a file system that doesn't have correct file type
267 // information.
269 }
270
272}
273
275 GetPluginRegistry().Initialize();
276
277 static const bool find_directories = true;
278 static const bool find_files = true;
279 static const bool find_other = true;
280
281 // Directories to scan for plugins. Unlike the plugin directories, which are
282 // meant exclusively for LLDB, the shared library directory is likely to
283 // contain unrelated shared libraries that we do not want to load. Therefore,
284 // limit the scan to libraries that start with g_plugin_prefix.
285 const std::array<PluginDir, 3> plugin_dirs = {
286 PluginDir(HostInfo::GetShlibDir(), PluginDir::LoadOnlyWithLLDBPrefix),
287 PluginDir(HostInfo::GetSystemPluginDir(), PluginDir::LoadAnyDylib),
288 PluginDir(HostInfo::GetUserPluginDir(), PluginDir::LoadAnyDylib)};
289
290 for (const PluginDir &plugin_dir : plugin_dirs) {
291 if (plugin_dir) {
293 plugin_dir.path.GetPath().c_str(), find_directories, find_files,
294 find_other, LoadPluginCallback, (void *)&plugin_dir.policy);
295 }
296 }
297}
298
299static void ClearScriptInterpreterErrors();
300
305
306llvm::ArrayRef<PluginNamespace> PluginManager::GetPluginNamespaces() {
307 static PluginNamespace PluginNamespaces[] = {
308
309 {
310 "abi",
313 },
314
315 {
316 "architecture",
319 },
320
321 {
322 "bug-reporter",
325 },
326
327 {
328 "disassembler",
331 },
332
333 {
334 "dynamic-loader",
337 },
338
339 {
340 "emulate-instruction",
343 },
344
345 {
346 "instrumentation-runtime",
349 },
350
351 {
352 "jit-loader",
355 },
356
357 {
358 "language",
361 },
362
363 {
364 "language-runtime",
367 },
368
369 {
370 "memory-history",
373 },
374
375 {
376 "object-container",
379 },
380
381 {
382 "object-file",
385 },
386
387 {
388 "operating-system",
391 },
392
393 {
394 "platform",
397 },
398
399 {
400 "process",
403 },
404
405 {
406 "repl",
409 },
410
411 {
412 "register-type-builder",
415 },
416
417 {
418 "script-interpreter",
421 },
422
423 {
424 "scripted-interface",
427 },
428
429 {
430 "structured-data",
433 },
434
435 {
436 "symbol-file",
439 },
440
441 {
442 "symbol-locator",
445 },
446
447 {
448 "symbol-vendor",
451 },
452
453 {
454 "system-runtime",
457 },
458
459 {
460 "trace",
463 },
464
465 {
466 "trace-exporter",
469 },
470
471 {
472 "type-system",
475 },
476
477 {
478 "unwind-assembly",
481 },
482 };
483
484 return PluginNamespaces;
485}
486
487llvm::json::Object PluginManager::GetJSON(llvm::StringRef pattern) {
488 llvm::json::Object plugin_stats;
489
490 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
491 llvm::json::Array namespace_stats;
492
493 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
494 if (MatchPluginName(pattern, plugin_ns, plugin)) {
495 llvm::json::Object plugin_json;
496 plugin_json.try_emplace("name", plugin.name);
497 plugin_json.try_emplace("enabled", plugin.enabled);
498 namespace_stats.emplace_back(std::move(plugin_json));
499 }
500 }
501 if (!namespace_stats.empty())
502 plugin_stats.try_emplace(plugin_ns.name, std::move(namespace_stats));
503 }
504
505 return plugin_stats;
506}
507
508bool PluginManager::MatchPluginName(llvm::StringRef pattern,
509 const PluginNamespace &plugin_ns,
510 const RegisteredPluginInfo &plugin_info) {
511 // The empty pattern matches all plugins.
512 if (pattern.empty())
513 return true;
514
515 // Check if the pattern matches the namespace.
516 if (pattern == plugin_ns.name)
517 return true;
518
519 // Check if the pattern matches the qualified name.
520 std::string qualified_name = (plugin_ns.name + "." + plugin_info.name).str();
521 return pattern == qualified_name;
522}
523
524template <typename Instance> class PluginInstances {
525public:
527 // Only meaningful after a real teardown; see PluginRegistry::IsTerminated.
528 if (!GetPluginRegistry().IsTerminated())
529 return;
530#ifndef NDEBUG
531 for (const auto &instance : m_instances)
532 llvm::errs() << llvm::formatv("Use `image lookup -va {0:x}` to find out "
533 "which callback was not removed\n",
534 instance.create_callback);
535#endif
536 assert(m_instances.empty() && "forgot to unregister plugin?");
537 }
538
539 template <typename... Args>
540 bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
541 typename Instance::CallbackType callback,
542 Args &&...args) {
543 if (!callback)
544 return false;
545 assert(!name.empty());
546
547 std::lock_guard<std::mutex> guard(m_mutex);
548 m_instances.emplace_back(name, description, callback,
549 std::forward<Args>(args)...);
550 return true;
551 }
552
553 bool UnregisterPlugin(typename Instance::CallbackType callback) {
554 if (!callback)
555 return false;
556
557 std::lock_guard<std::mutex> guard(m_mutex);
558 auto pos = m_instances.begin();
559 auto end = m_instances.end();
560 for (; pos != end; ++pos) {
561 if (pos->create_callback == callback) {
562 m_instances.erase(pos);
563 return true;
564 }
565 }
566 return false;
567 }
568
569 llvm::StringRef GetDescriptionAtIndex(uint32_t idx) {
570 if (auto instance = GetInstanceAtIndex(idx))
571 return instance->description;
572 return "";
573 }
574
575 llvm::StringRef GetNameAtIndex(uint32_t idx) {
576 if (auto instance = GetInstanceAtIndex(idx))
577 return instance->name;
578 return "";
579 }
580
581 typename Instance::CallbackType GetCallbackForName(llvm::StringRef name) {
582 if (auto instance = GetInstanceForName(name))
583 return instance->create_callback;
584 return nullptr;
585 }
586
587 llvm::SmallVector<typename Instance::CallbackType> GetCreateCallbacks() {
588 llvm::SmallVector<Instance> snapshot = GetSnapshot();
589 llvm::SmallVector<typename Instance::CallbackType> result;
590 result.reserve(snapshot.size());
591 for (const auto &instance : snapshot)
592 result.push_back(instance.create_callback);
593 return result;
594 }
595
597 for (const auto &instance : GetSnapshot()) {
598 if (instance.debugger_init_callback)
599 instance.debugger_init_callback(debugger);
600 }
601 }
602
603 // Return a copy of all the enabled instances.
604 // Note that this is a copy of the internal state so modifications
605 // to the returned instances will not be reflected back to instances
606 // stored by the PluginInstances object.
607 llvm::SmallVector<Instance> GetSnapshot(bool enabled_only = true) const {
608 std::lock_guard<std::mutex> guard(m_mutex);
609
610 llvm::SmallVector<Instance> enabled_instances;
611 enabled_instances.reserve(m_instances.size());
612 for (const auto &instance : m_instances) {
613 if (!enabled_only || instance.enabled)
614 enabled_instances.push_back(instance);
615 }
616 return enabled_instances;
617 }
618
619 std::optional<Instance> GetInstanceAtIndex(uint32_t idx) {
620 uint32_t count = 0;
621
622 return FindEnabledInstance(
623 [&](const Instance &instance) { return count++ == idx; });
624 }
625
626 std::optional<Instance> GetInstanceForName(llvm::StringRef name,
627 bool enabled_only = true) {
628 if (name.empty())
629 return std::nullopt;
630
631 auto predicate = [&](const Instance &instance) {
632 return instance.name == name;
633 };
634 if (enabled_only)
635 return FindEnabledInstance(predicate);
636
637 return FindInstance(predicate);
638 }
639
640 std::optional<Instance>
641 FindEnabledInstance(std::function<bool(const Instance &)> predicate) const {
642 for (const auto &instance : GetSnapshot()) {
643 if (predicate(instance))
644 return instance;
645 }
646 return std::nullopt;
647 }
648
649 std::optional<Instance>
650 FindInstance(std::function<bool(const Instance &)> predicate) const {
651 std::lock_guard<std::mutex> guard(m_mutex);
652 for (const auto &instance : m_instances) {
653 if (predicate(instance))
654 return instance;
655 }
656 return std::nullopt;
657 }
658
659 // Return a list of all the registered plugin instances. This includes both
660 // enabled and disabled instances. The instances are listed in the order they
661 // were registered which is the order they would be queried if they were all
662 // enabled.
663 llvm::SmallVector<RegisteredPluginInfo> GetPluginInfoForAllInstances() {
664 std::lock_guard<std::mutex> guard(m_mutex);
665
666 // Lookup the plugin info for each instance in the sorted order.
667 llvm::SmallVector<RegisteredPluginInfo> plugin_infos;
668 plugin_infos.reserve(m_instances.size());
669
670 for (const Instance &instance : m_instances)
671 plugin_infos.push_back(
672 {instance.name, instance.description, instance.enabled});
673
674 return plugin_infos;
675 }
676
677 bool SetInstanceEnabled(llvm::StringRef name, bool enable) {
678 std::lock_guard<std::mutex> guard(m_mutex);
679 auto it = llvm::find_if(m_instances, [&](const Instance &instance) {
680 return instance.name == name;
681 });
682
683 if (it == m_instances.end())
684 return false;
685
686 it->enabled = enable;
687 return true;
688 }
689
690private:
691 mutable std::mutex m_mutex;
692 llvm::SmallVector<Instance> m_instances;
693};
694
695#pragma mark ABI
696
699
701 static ABIInstances g_instances;
702 return g_instances;
703}
704
705bool PluginManager::RegisterPlugin(llvm::StringRef name,
706 llvm::StringRef description,
707 ABICreateInstance create_callback) {
708 return GetABIInstances().RegisterPlugin(name, description, create_callback);
709}
710
712 return GetABIInstances().UnregisterPlugin(create_callback);
713}
714
715llvm::SmallVector<ABICreateInstance> PluginManager::GetABICreateCallbacks() {
717}
718
719#pragma mark Architecture
720
723
725 static ArchitectureInstances g_instances;
726 return g_instances;
727}
728
729void PluginManager::RegisterPlugin(llvm::StringRef name,
730 llvm::StringRef description,
731 ArchitectureCreateInstance create_callback) {
732 GetArchitectureInstances().RegisterPlugin(name, description, create_callback);
733}
734
736 ArchitectureCreateInstance create_callback) {
737 auto &instances = GetArchitectureInstances();
738 instances.UnregisterPlugin(create_callback);
739}
740
741std::unique_ptr<Architecture>
743 for (const auto &instances : GetArchitectureInstances().GetSnapshot()) {
744 if (auto plugin_up = instances.create_callback(arch))
745 return plugin_up;
746 }
747 return nullptr;
748}
749
750#pragma mark BugReporter
751
754
756 static BugReporterInstances g_instances;
757 return g_instances;
758}
759
760void PluginManager::RegisterPlugin(llvm::StringRef name,
761 llvm::StringRef description,
762 BugReporterCreateInstance create_callback) {
763 GetBugReporterInstances().RegisterPlugin(name, description, create_callback);
764}
765
770
771std::unique_ptr<BugReporter>
773 if (!name.empty()) {
774 if (auto create_callback =
775 GetBugReporterInstances().GetCallbackForName(name))
776 return create_callback();
777 return nullptr;
778 }
779 for (const auto &instance : GetBugReporterInstances().GetSnapshot()) {
780 if (auto plugin_up = instance.create_callback())
781 return plugin_up;
782 }
783 return nullptr;
784}
785
786#pragma mark Disassembler
787
790
792 static DisassemblerInstances g_instances;
793 return g_instances;
794}
795
796bool PluginManager::RegisterPlugin(llvm::StringRef name,
797 llvm::StringRef description,
798 DisassemblerCreateInstance create_callback) {
799 return GetDisassemblerInstances().RegisterPlugin(name, description,
800 create_callback);
801}
802
804 DisassemblerCreateInstance create_callback) {
805 return GetDisassemblerInstances().UnregisterPlugin(create_callback);
806}
807
808llvm::SmallVector<DisassemblerCreateInstance>
812
818
819#pragma mark DynamicLoader
820
823
825 static DynamicLoaderInstances g_instances;
826 return g_instances;
827}
828
830 llvm::StringRef name, llvm::StringRef description,
831 DynamicLoaderCreateInstance create_callback,
832 DebuggerInitializeCallback debugger_init_callback) {
834 name, description, create_callback, debugger_init_callback);
835}
836
838 DynamicLoaderCreateInstance create_callback) {
839 return GetDynamicLoaderInstances().UnregisterPlugin(create_callback);
840}
841
842llvm::SmallVector<DynamicLoaderCreateInstance>
846
852
853#pragma mark JITLoader
854
857
859 static JITLoaderInstances g_instances;
860 return g_instances;
861}
862
864 llvm::StringRef name, llvm::StringRef description,
865 JITLoaderCreateInstance create_callback,
866 DebuggerInitializeCallback debugger_init_callback) {
868 name, description, create_callback, debugger_init_callback);
869}
870
872 return GetJITLoaderInstances().UnregisterPlugin(create_callback);
873}
874
875llvm::SmallVector<JITLoaderCreateInstance>
879
880#pragma mark EmulateInstruction
881
885
887 static EmulateInstructionInstances g_instances;
888 return g_instances;
889}
890
892 llvm::StringRef name, llvm::StringRef description,
893 EmulateInstructionCreateInstance create_callback) {
894 return GetEmulateInstructionInstances().RegisterPlugin(name, description,
895 create_callback);
896}
897
902
903llvm::SmallVector<EmulateInstructionCreateInstance>
907
913
914#pragma mark OperatingSystem
915
918
920 static OperatingSystemInstances g_instances;
921 return g_instances;
922}
923
925 llvm::StringRef name, llvm::StringRef description,
926 OperatingSystemCreateInstance create_callback,
927 DebuggerInitializeCallback debugger_init_callback) {
929 name, description, create_callback, debugger_init_callback);
930}
931
936
937llvm::SmallVector<OperatingSystemCreateInstance>
941
947
948#pragma mark Language
949
952
954 static LanguageInstances g_instances;
955 return g_instances;
956}
957
958namespace {
959/// The Language instances that the language plugins create. Callers cache
960/// these instances, so they are never destroyed.
961class LanguageInstanceCache {
962public:
963 Language *Get(lldb::LanguageType language) {
964 std::lock_guard<std::mutex> guard(m_mutex);
965 return Lookup(language);
966 }
967
968 std::vector<Language *> GetAll() {
969 std::lock_guard<std::mutex> guard(m_mutex);
970 std::vector<Language *> instances;
971 for (unsigned lang = eLanguageTypeUnknown; lang < eNumLanguageTypes;
972 ++lang) {
973 if (Language *instance = Lookup(static_cast<lldb::LanguageType>(lang)))
974 instances.push_back(instance);
975 }
976 return instances;
977 }
978
979 /// Call this whenever a language plugin is registered, unregistered,
980 /// enabled, or disabled.
981 void Invalidate() {
982 std::lock_guard<std::mutex> guard(m_mutex);
983 m_active.clear();
984 }
985
986private:
987 /// Returns the instance of the first enabled plugin that supports
988 /// \p language, or nullptr. The caller must hold m_mutex.
990 auto [active, inserted] = m_active.try_emplace(language, nullptr);
991 if (!inserted)
992 return active->second;
993 for (LanguageCreateInstance create_callback :
994 GetLanguageInstances().GetCreateCallbacks()) {
995 auto [created, is_new] =
996 m_created.try_emplace({create_callback, language}, nullptr);
997 if (is_new)
998 created->second = create_callback(language);
999 if (created->second)
1000 return active->second = created->second;
1001 }
1002 return nullptr;
1003 }
1004
1005 std::mutex m_mutex;
1006 /// The instance of the first enabled plugin that supports each language,
1007 /// or nullptr if none does.
1008 std::map<lldb::LanguageType, Language *> m_active;
1009 /// The result of every create callback for every language, so that each
1010 /// callback is called once per language and a plugin that is registered or
1011 /// enabled again gets the same instances. This assumes that a create
1012 /// callback's result only depends on the language.
1013 std::map<std::pair<LanguageCreateInstance, lldb::LanguageType>, Language *>
1014 m_created;
1015};
1016} // namespace
1017
1018// Language instances are never destroyed, so neither is this cache.
1019static LanguageInstanceCache &GetLanguageInstanceCache() {
1020 static LanguageInstanceCache *g_cache = new LanguageInstanceCache();
1021 return *g_cache;
1022}
1023
1025 llvm::StringRef name, llvm::StringRef description,
1026 LanguageCreateInstance create_callback,
1027 DebuggerInitializeCallback debugger_init_callback) {
1028 bool registered = GetLanguageInstances().RegisterPlugin(
1029 name, description, create_callback, debugger_init_callback);
1030 if (registered)
1031 GetLanguageInstanceCache().Invalidate();
1032 return registered;
1033}
1034
1036 bool unregistered = GetLanguageInstances().UnregisterPlugin(create_callback);
1037 if (unregistered)
1038 GetLanguageInstanceCache().Invalidate();
1039 return unregistered;
1040}
1041
1045
1047 return GetLanguageInstanceCache().GetAll();
1048}
1049
1050#pragma mark LanguageRuntime
1051
1068
1070
1072 static LanguageRuntimeInstances g_instances;
1073 return g_instances;
1074}
1075
1077 llvm::StringRef name, llvm::StringRef description,
1078 LanguageRuntimeCreateInstance create_callback,
1079 LanguageRuntimeGetCommandObject command_callback,
1080 LanguageRuntimeGetExceptionPrecondition precondition_callback) {
1082 name, description, create_callback, nullptr, command_callback,
1083 precondition_callback);
1084}
1085
1087 LanguageRuntimeCreateInstance create_callback) {
1088 return GetLanguageRuntimeInstances().UnregisterPlugin(create_callback);
1089}
1090
1091llvm::SmallVector<LanguageRuntimeCallbacks>
1093 auto instances = GetLanguageRuntimeInstances().GetSnapshot();
1094 llvm::SmallVector<LanguageRuntimeCallbacks> result;
1095 result.reserve(instances.size());
1096 for (auto &instance : instances)
1097 result.push_back({instance.create_callback, instance.command_callback,
1098 instance.precondition_callback});
1099 return result;
1100}
1101
1102#pragma mark SystemRuntime
1103
1106
1108 static SystemRuntimeInstances g_instances;
1109 return g_instances;
1110}
1111
1113 llvm::StringRef name, llvm::StringRef description,
1114 SystemRuntimeCreateInstance create_callback) {
1115 return GetSystemRuntimeInstances().RegisterPlugin(name, description,
1116 create_callback);
1117}
1118
1120 SystemRuntimeCreateInstance create_callback) {
1121 return GetSystemRuntimeInstances().UnregisterPlugin(create_callback);
1122}
1123
1124llvm::SmallVector<SystemRuntimeCreateInstance>
1128
1129#pragma mark ObjectFile
1130
1150
1152 static ObjectFileInstances g_instances;
1153 return g_instances;
1154}
1155
1157 if (name.empty())
1158 return false;
1159
1160 return GetObjectFileInstances().GetInstanceForName(name).has_value();
1161}
1162
1164 llvm::StringRef name, llvm::StringRef description,
1165 ObjectFileCreateInstance create_callback,
1166 ObjectFileCreateMemoryInstance create_memory_callback,
1167 ObjectFileGetModuleSpecifications get_module_specifications,
1168 ObjectFileSaveCore save_core,
1169 DebuggerInitializeCallback debugger_init_callback) {
1171 name, description, create_callback, create_memory_callback,
1172 get_module_specifications, save_core, debugger_init_callback);
1173}
1174
1176 return GetObjectFileInstances().UnregisterPlugin(create_callback);
1177}
1178
1179llvm::SmallVector<ObjectFileCallbacks> PluginManager::GetObjectFileCallbacks() {
1180 auto instances = GetObjectFileInstances().GetSnapshot();
1181 llvm::SmallVector<ObjectFileCallbacks> result;
1182 result.reserve(instances.size());
1183 for (auto &instance : instances)
1184 result.push_back({instance.create_callback, instance.create_memory_callback,
1185 instance.get_module_specifications, instance.save_core});
1186 return result;
1187}
1188
1191 llvm::StringRef name) {
1192 if (auto instance = GetObjectFileInstances().GetInstanceForName(name))
1193 return instance->create_memory_callback;
1194 return nullptr;
1195}
1196
1198 Status error;
1199 if (!options.GetOutputFile()) {
1200 error = Status::FromErrorString("No output file specified");
1201 return error;
1202 }
1203
1204 if (!options.GetProcess()) {
1205 error = Status::FromErrorString("Invalid process");
1206 return error;
1207 }
1208
1209 error = options.EnsureValidConfiguration();
1210 if (error.Fail())
1211 return error;
1212
1213 if (!options.GetPluginName().has_value()) {
1214 // Try saving core directly from the process plugin first.
1215 llvm::Expected<bool> ret =
1216 options.GetProcess()->SaveCore(options.GetOutputFile()->GetPath());
1217 if (!ret)
1218 return Status::FromError(ret.takeError());
1219 if (ret.get())
1220 return Status();
1221 }
1222
1223 // Fall back to object plugins.
1224 const auto &plugin_name = options.GetPluginName().value_or("");
1225 auto instances = GetObjectFileInstances().GetSnapshot();
1226 for (auto &instance : instances) {
1227 if (plugin_name.empty() || instance.name == plugin_name) {
1228 // TODO: Refactor the instance.save_core() to not require a process and
1229 // get it from options instead.
1230 if (instance.save_core &&
1231 instance.save_core(options.GetProcess(), options, error))
1232 return error;
1233 }
1234 }
1235
1236 // Check to see if any of the object file plugins tried and failed to save.
1237 // if any failure, return the error message.
1238 if (error.Fail())
1239 return error;
1240
1241 // Report only for the plugin that was specified.
1242 if (!plugin_name.empty())
1244 "The \"{}\" plugin is not able to save a core for this process.",
1245 plugin_name);
1246
1248 "no ObjectFile plugins were able to save a core for this process");
1249}
1250
1251llvm::SmallVector<llvm::StringRef> PluginManager::GetSaveCorePluginNames() {
1252 llvm::SmallVector<llvm::StringRef> plugin_names;
1253 auto instances = GetObjectFileInstances().GetSnapshot();
1254 for (auto &instance : instances) {
1255 if (instance.save_core)
1256 plugin_names.emplace_back(instance.name);
1257 }
1258 return plugin_names;
1259}
1260
1261#pragma mark ObjectContainer
1262
1279
1281 static ObjectContainerInstances g_instances;
1282 return g_instances;
1283}
1284
1286 llvm::StringRef name, llvm::StringRef description,
1287 ObjectContainerCreateInstance create_callback,
1288 ObjectFileGetModuleSpecifications get_module_specifications,
1289 ObjectContainerCreateMemoryInstance create_memory_callback) {
1291 name, description, create_callback, create_memory_callback,
1292 get_module_specifications);
1293}
1294
1296 ObjectContainerCreateInstance create_callback) {
1297 return GetObjectContainerInstances().UnregisterPlugin(create_callback);
1298}
1299
1300llvm::SmallVector<ObjectContainerCallbacks>
1302 auto instances = GetObjectContainerInstances().GetSnapshot();
1303 llvm::SmallVector<ObjectContainerCallbacks> result;
1304 result.reserve(instances.size());
1305 for (auto &instance : instances)
1306 result.push_back({instance.create_callback, instance.create_memory_callback,
1307 instance.get_module_specifications});
1308 return result;
1309}
1310
1311#pragma mark Platform
1312
1315
1317 static PlatformInstances g_platform_instances;
1318 return g_platform_instances;
1319}
1320
1322 llvm::StringRef name, llvm::StringRef description,
1323 PlatformCreateInstance create_callback,
1324 DebuggerInitializeCallback debugger_init_callback) {
1326 name, description, create_callback, debugger_init_callback);
1327}
1328
1330 return GetPlatformInstances().UnregisterPlugin(create_callback);
1331}
1332
1333llvm::StringRef PluginManager::GetPlatformPluginNameAtIndex(uint32_t idx) {
1335}
1336
1337llvm::StringRef
1341
1346
1347llvm::SmallVector<PlatformCreateInstance>
1351
1353 CompletionRequest &request) {
1354 for (const auto &instance : GetPlatformInstances().GetSnapshot()) {
1355 if (instance.name.starts_with(name))
1356 request.AddCompletion(instance.name);
1357 }
1358}
1359
1360#pragma mark Process
1361
1364
1366 static ProcessInstances g_instances;
1367 return g_instances;
1368}
1369
1371 llvm::StringRef name, llvm::StringRef description,
1372 ProcessCreateInstance create_callback,
1373 DebuggerInitializeCallback debugger_init_callback) {
1375 name, description, create_callback, debugger_init_callback);
1376}
1377
1379 return GetProcessInstances().UnregisterPlugin(create_callback);
1380}
1381
1382llvm::StringRef PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) {
1383 return GetProcessInstances().GetNameAtIndex(idx);
1384}
1385
1386llvm::StringRef
1390
1395
1396llvm::SmallVector<ProcessCreateInstance>
1400
1402 CompletionRequest &request) {
1403 for (const auto &instance : GetProcessInstances().GetSnapshot()) {
1404 if (instance.name.starts_with(name))
1405 request.AddCompletion(instance.name, instance.description);
1406 }
1407}
1408
1409#pragma mark ProtocolServer
1410
1413
1415 static ProtocolServerInstances g_instances;
1416 return g_instances;
1417}
1418
1420 llvm::StringRef name, llvm::StringRef description,
1421 ProtocolServerCreateInstance create_callback) {
1422 return GetProtocolServerInstances().RegisterPlugin(name, description,
1423 create_callback);
1424}
1425
1427 ProtocolServerCreateInstance create_callback) {
1428 return GetProtocolServerInstances().UnregisterPlugin(create_callback);
1429}
1430
1431llvm::StringRef
1435
1440
1441#pragma mark RegisterTypeBuilder
1442
1444 : public PluginInstance<RegisterTypeBuilderCreateInstance> {
1449};
1450
1451typedef PluginInstances<RegisterTypeBuilderInstance>
1453
1455 static RegisterTypeBuilderInstances g_instances;
1456 return g_instances;
1457}
1458
1460 llvm::StringRef name, llvm::StringRef description,
1461 RegisterTypeBuilderCreateInstance create_callback) {
1462 return GetRegisterTypeBuilderInstances().RegisterPlugin(name, description,
1463 create_callback);
1464}
1465
1470
1473 // We assume that RegisterTypeBuilderClang is the only instance of this plugin
1474 // type and is always present.
1476 assert(instance);
1477 return instance->create_callback(target);
1478}
1479
1480#pragma mark ScriptInterpreter
1481
1495
1497
1499 static ScriptInterpreterInstances g_instances;
1500 return g_instances;
1501}
1502
1504 llvm::StringRef name, llvm::StringRef description,
1505 lldb::ScriptLanguage script_language,
1506 ScriptInterpreterCreateInstance create_callback,
1507 ScriptInterpreterGetPath get_path_callback) {
1509 name, description, create_callback, script_language, get_path_callback);
1510}
1511
1516
1517llvm::SmallVector<ScriptInterpreterCreateInstance>
1521
1524 Debugger &debugger) {
1525 const auto instances = GetScriptInterpreterInstances().GetSnapshot();
1526 ScriptInterpreterCreateInstance none_instance = nullptr;
1527 for (const auto &instance : instances) {
1528 if (instance.language == lldb::eScriptLanguageNone)
1529 none_instance = instance.create_callback;
1530
1531 if (script_lang == instance.language)
1532 return instance.create_callback(debugger, script_lang);
1533 }
1534
1535 // If we didn't find one, return the ScriptInterpreter for the null language.
1536 assert(none_instance != nullptr);
1537 return none_instance(debugger, script_lang);
1538}
1539
1540namespace {
1541struct ScriptInterpreterErrors {
1542 std::mutex mutex;
1543 llvm::DenseMap<lldb::ScriptLanguage, Status> errors;
1544};
1545} // namespace
1546
1547static ScriptInterpreterErrors &GetScriptInterpreterErrors() {
1548 static ScriptInterpreterErrors g_errors;
1549 return g_errors;
1550}
1551
1553 ScriptInterpreterErrors &errors = GetScriptInterpreterErrors();
1554 std::lock_guard<std::mutex> guard(errors.mutex);
1555 errors.errors.clear();
1556}
1557
1559 llvm::Error error) {
1560 ScriptInterpreterErrors &errors = GetScriptInterpreterErrors();
1561 std::lock_guard<std::mutex> guard(errors.mutex);
1562 if (error)
1563 errors.errors[script_lang] = Status::FromError(std::move(error));
1564 else
1565 errors.errors.erase(script_lang);
1566}
1567
1568llvm::Error
1570 ScriptInterpreterErrors &errors = GetScriptInterpreterErrors();
1571 std::lock_guard<std::mutex> guard(errors.mutex);
1572 auto it = errors.errors.find(script_lang);
1573 if (it == errors.errors.end())
1574 return llvm::Error::success();
1575 return it->second.ToError();
1576}
1577
1579 lldb::ScriptLanguage script_lang) {
1580 const auto instances = GetScriptInterpreterInstances().GetSnapshot();
1581 for (const auto &instance : instances) {
1582 if (instance.language == script_lang && instance.get_path_callback)
1583 return instance.get_path_callback();
1584 }
1585 return FileSpec();
1586}
1587
1588#pragma mark SyntheticFrameProvider
1589
1598
1600 static SyntheticFrameProviderInstances g_instances;
1601 return g_instances;
1602}
1603
1605 static ScriptedFrameProviderInstances g_instances;
1606 return g_instances;
1607}
1608
1610 llvm::StringRef name, llvm::StringRef description,
1611 SyntheticFrameProviderCreateInstance create_native_callback,
1612 ScriptedFrameProviderCreateInstance create_scripted_callback) {
1613 if (create_native_callback)
1615 name, description, create_native_callback);
1616 else if (create_scripted_callback)
1618 name, description, create_scripted_callback);
1619 return false;
1620}
1621
1626
1631
1637
1638llvm::SmallVector<ScriptedFrameProviderCreateInstance>
1642
1643#pragma mark StructuredDataPlugin
1644
1658
1661
1663 static StructuredDataPluginInstances g_instances;
1664 return g_instances;
1665}
1666
1668 llvm::StringRef name, llvm::StringRef description,
1669 StructuredDataPluginCreateInstance create_callback,
1670 DebuggerInitializeCallback debugger_init_callback,
1671 StructuredDataFilterLaunchInfo filter_callback) {
1673 name, description, create_callback, debugger_init_callback,
1674 filter_callback);
1675}
1676
1681
1682llvm::SmallVector<StructuredDataPluginCallbacks>
1684 auto instances = GetStructuredDataPluginInstances().GetSnapshot();
1685 llvm::SmallVector<StructuredDataPluginCallbacks> result;
1686 result.reserve(instances.size());
1687 for (auto &instance : instances)
1688 result.push_back({instance.create_callback, instance.filter_callback});
1689 return result;
1690}
1691
1692#pragma mark SymbolFile
1693
1696
1698 static SymbolFileInstances g_instances;
1699 return g_instances;
1700}
1701
1703 llvm::StringRef name, llvm::StringRef description,
1704 SymbolFileCreateInstance create_callback,
1705 DebuggerInitializeCallback debugger_init_callback) {
1707 name, description, create_callback, debugger_init_callback);
1708}
1709
1711 return GetSymbolFileInstances().UnregisterPlugin(create_callback);
1712}
1713
1714llvm::SmallVector<SymbolFileCreateInstance>
1718
1719#pragma mark SymbolVendor
1720
1723
1725 static SymbolVendorInstances g_instances;
1726 return g_instances;
1727}
1728
1729bool PluginManager::RegisterPlugin(llvm::StringRef name,
1730 llvm::StringRef description,
1731 SymbolVendorCreateInstance create_callback) {
1732 return GetSymbolVendorInstances().RegisterPlugin(name, description,
1733 create_callback);
1734}
1735
1737 SymbolVendorCreateInstance create_callback) {
1738 return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
1739}
1740
1741llvm::SmallVector<SymbolVendorCreateInstance>
1745
1746#pragma mark SymbolLocator
1747
1771
1773 static SymbolLocatorInstances g_instances;
1774 return g_instances;
1775}
1776
1778 llvm::StringRef name, llvm::StringRef description,
1779 SymbolLocatorCreateInstance create_callback,
1780 SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
1781 SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
1782 SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file,
1783 SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle,
1784 DebuggerInitializeCallback debugger_init_callback) {
1786 name, description, create_callback, locate_executable_object_file,
1787 locate_executable_symbol_file, download_object_symbol_file,
1788 find_symbol_file_in_bundle, debugger_init_callback);
1789}
1790
1792 SymbolLocatorCreateInstance create_callback) {
1793 return GetSymbolLocatorInstances().UnregisterPlugin(create_callback);
1794}
1795
1796llvm::SmallVector<SymbolLocatorCreateInstance>
1800
1803 StatisticsMap &map) {
1804 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1805 for (auto &instance : instances) {
1806 if (instance.locate_executable_object_file) {
1807 StatsDuration time;
1808 std::optional<ModuleSpec> result;
1809 {
1810 ElapsedTime elapsed(time);
1811 result = instance.locate_executable_object_file(module_spec);
1812 }
1813 map.add(instance.name, time.get().count());
1814 if (result)
1815 return *result;
1816 }
1817 }
1818 return {};
1819}
1820
1822 const ModuleSpec &module_spec, const FileSpecList &default_search_paths,
1823 StatisticsMap &map) {
1824 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1825 for (auto &instance : instances) {
1826 if (instance.locate_executable_symbol_file) {
1827 StatsDuration time;
1828 std::optional<FileSpec> result;
1829 {
1830 ElapsedTime elapsed(time);
1831 result = instance.locate_executable_symbol_file(module_spec,
1832 default_search_paths);
1833 }
1834 map.add(instance.name, time.get().count());
1835 if (result)
1836 return *result;
1837 }
1838 }
1839 return {};
1840}
1841
1843 Status &error,
1844 bool force_lookup,
1845 bool copy_executable) {
1846 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1847 for (auto &instance : instances) {
1848 if (instance.download_object_symbol_file) {
1849 if (instance.download_object_symbol_file(module_spec, error, force_lookup,
1850 copy_executable))
1851 return true;
1852 }
1853 }
1854 return false;
1855}
1856
1858 const UUID *uuid,
1859 const ArchSpec *arch) {
1860 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1861 for (auto &instance : instances) {
1862 if (instance.find_symbol_file_in_bundle) {
1863 std::optional<FileSpec> result =
1864 instance.find_symbol_file_in_bundle(symfile_bundle, uuid, arch);
1865 if (result)
1866 return *result;
1867 }
1868 }
1869 return {};
1870}
1871
1872#pragma mark Trace
1873
1889
1891
1893 static TraceInstances g_instances;
1894 return g_instances;
1895}
1896
1898 llvm::StringRef name, llvm::StringRef description,
1899 TraceCreateInstanceFromBundle create_callback_from_bundle,
1900 TraceCreateInstanceForLiveProcess create_callback_for_live_process,
1901 llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) {
1903 name, description, create_callback_from_bundle,
1904 create_callback_for_live_process, schema, debugger_init_callback);
1905}
1906
1908 TraceCreateInstanceFromBundle create_callback_from_bundle) {
1910 create_callback_from_bundle);
1911}
1912
1914PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
1915 return GetTracePluginInstances().GetCallbackForName(plugin_name);
1916}
1917
1920 llvm::StringRef plugin_name) {
1921 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1922 return instance->create_callback_for_live_process;
1923
1924 return nullptr;
1925}
1926
1927llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
1928 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1929 return instance->schema;
1930 return llvm::StringRef();
1931}
1932
1933llvm::StringRef PluginManager::GetTraceSchema(size_t index) {
1934 if (auto instance = GetTracePluginInstances().GetInstanceAtIndex(index))
1935 return instance->schema;
1936 return llvm::StringRef();
1937}
1938
1939#pragma mark TraceExporter
1940
1954
1956
1958 static TraceExporterInstances g_instances;
1959 return g_instances;
1960}
1961
1963 llvm::StringRef name, llvm::StringRef description,
1964 TraceExporterCreateInstance create_callback,
1965 ThreadTraceExportCommandCreator create_thread_trace_export_command) {
1967 name, description, create_callback, create_thread_trace_export_command);
1968}
1969
1972 return GetTraceExporterInstances().GetCallbackForName(plugin_name);
1973}
1974
1976 TraceExporterCreateInstance create_callback) {
1977 return GetTraceExporterInstances().UnregisterPlugin(create_callback);
1978}
1979
1980llvm::SmallVector<TraceExporterCallbacks>
1982 auto instances = GetTraceExporterInstances().GetSnapshot();
1983 llvm::SmallVector<TraceExporterCallbacks> result;
1984 result.reserve(instances.size());
1985 for (auto &instance : instances)
1986 result.push_back({instance.name, instance.create_callback,
1987 instance.create_thread_trace_export_command});
1988 return result;
1989}
1990
1991#pragma mark UnwindAssembly
1992
1995
1997 static UnwindAssemblyInstances g_instances;
1998 return g_instances;
1999}
2000
2002 llvm::StringRef name, llvm::StringRef description,
2003 UnwindAssemblyCreateInstance create_callback) {
2004 return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
2005 create_callback);
2006}
2007
2009 UnwindAssemblyCreateInstance create_callback) {
2010 return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
2011}
2012
2013llvm::SmallVector<UnwindAssemblyCreateInstance>
2017
2018#pragma mark MemoryHistory
2019
2022
2024 static MemoryHistoryInstances g_instances;
2025 return g_instances;
2026}
2027
2029 llvm::StringRef name, llvm::StringRef description,
2030 MemoryHistoryCreateInstance create_callback) {
2031 return GetMemoryHistoryInstances().RegisterPlugin(name, description,
2032 create_callback);
2033}
2034
2036 MemoryHistoryCreateInstance create_callback) {
2037 return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
2038}
2039
2040llvm::SmallVector<MemoryHistoryCreateInstance>
2044
2045#pragma mark InstrumentationRuntime
2046
2059
2061 : public PluginInstances<InstrumentationRuntimeInstance> {
2062
2064 bool enabled_only) {
2065 if (auto instance = GetInstanceForName(name, enabled_only))
2066 return instance->get_type_callback;
2067 return nullptr;
2068 }
2069};
2070
2072 static InstrumentationRuntimeInstances g_instances;
2073 return g_instances;
2074}
2075
2077 llvm::StringRef name, llvm::StringRef description,
2079 InstrumentationRuntimeGetType get_type_callback) {
2081 name, description, create_callback, get_type_callback);
2082}
2083
2088
2089llvm::SmallVector<InstrumentationRuntimeCallbacks>
2091 auto instances =
2093 llvm::SmallVector<InstrumentationRuntimeCallbacks> result;
2094 result.reserve(instances.size());
2095 for (auto &instance : instances)
2096 result.push_back({instance.create_callback, instance.get_type_callback});
2097 return result;
2098}
2099
2100#pragma mark TypeSystem
2101
2117
2119
2121 static TypeSystemInstances g_instances;
2122 return g_instances;
2123}
2124
2126 llvm::StringRef name, llvm::StringRef description,
2127 TypeSystemCreateInstance create_callback,
2128 LanguageSet supported_languages_for_types,
2129 LanguageSet supported_languages_for_expressions,
2130 DebuggerInitializeCallback debugger_init_callback) {
2132 name, description, create_callback, supported_languages_for_types,
2133 supported_languages_for_expressions, debugger_init_callback);
2134}
2135
2137 return GetTypeSystemInstances().UnregisterPlugin(create_callback);
2138}
2139
2140llvm::SmallVector<TypeSystemCreateInstance>
2144
2146 const auto instances = GetTypeSystemInstances().GetSnapshot();
2147 LanguageSet all;
2148 for (unsigned i = 0; i < instances.size(); ++i)
2149 all.bitvector |= instances[i].supported_languages_for_types.bitvector;
2150 return all;
2151}
2152
2154 const auto instances = GetTypeSystemInstances().GetSnapshot();
2155 LanguageSet all;
2156 for (unsigned i = 0; i < instances.size(); ++i)
2157 all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
2158 return all;
2159}
2160
2161#pragma mark ScriptedInterfaces
2162
2164
2166 static ScriptedInterfaceInstances g_instances;
2167 return g_instances;
2168}
2169
2171 llvm::StringRef name, llvm::StringRef description,
2172 ScriptedInterfaceCreateInstance create_callback,
2174 ScriptedInterfaceUsages usages) {
2176 name, description, create_callback, extension, language, usages);
2177}
2178
2183
2187
2188llvm::StringRef PluginManager::GetScriptedInterfaceNameAtIndex(uint32_t index) {
2190}
2191
2192llvm::StringRef
2196
2199 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(index))
2200 return instance->extension;
2202}
2203
2206 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
2207 return instance->language;
2209}
2210
2213 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
2214 return instance->usages;
2215 return {};
2216}
2217
2219 llvm::function_ref<void(const ScriptedInterfaceInstance &)> callback,
2220 lldb::ScriptLanguage language) {
2221 llvm::SmallSet<lldb::ScriptedExtension, 16> emitted;
2222 for (size_t idx = 0; idx < GetNumScriptedInterfaces(); idx++) {
2224 if (!instance)
2225 continue;
2226 if (language != lldb::eScriptLanguageUnknown &&
2227 instance->language != language)
2228 continue;
2229 if (emitted.insert(instance->extension).second)
2230 callback(*instance);
2231 }
2232}
2233
2235 llvm::StringRef name, CompletionRequest &request,
2236 lldb::ScriptLanguage language) {
2238 [&](const ScriptedInterfaceInstance &instance) {
2239 llvm::StringLiteral extension_name =
2241 if (extension_name.starts_with(name))
2242 request.AddCompletion(extension_name);
2243 },
2244 language);
2245}
2246
2247#pragma mark REPL
2248
2257
2259
2261 static REPLInstances g_instances;
2262 return g_instances;
2263}
2264
2265bool PluginManager::RegisterPlugin(llvm::StringRef name,
2266 llvm::StringRef description,
2267 REPLCreateInstance create_callback,
2268 LanguageSet supported_languages) {
2269 return GetREPLInstances().RegisterPlugin(name, description, create_callback,
2270 supported_languages);
2271}
2272
2274 return GetREPLInstances().UnregisterPlugin(create_callback);
2275}
2276
2277llvm::SmallVector<REPLCallbacks> PluginManager::GetREPLCallbacks() {
2278 auto instances = GetREPLInstances().GetSnapshot();
2279 llvm::SmallVector<REPLCallbacks> result;
2280 result.reserve(instances.size());
2281 for (auto &instance : instances)
2282 result.push_back({instance.create_callback, instance.supported_languages});
2283 return result;
2284}
2285
2287 const auto instances = GetREPLInstances().GetSnapshot();
2288 LanguageSet all;
2289 for (unsigned i = 0; i < instances.size(); ++i)
2290 all.bitvector |= instances[i].supported_languages.bitvector;
2291 return all;
2292}
2293
2294#pragma mark Highlighter
2295
2296struct HighlighterInstance : public PluginInstance<HighlighterCreateInstance> {
2301};
2302
2304
2306 static HighlighterInstances g_instances;
2307 return g_instances;
2308}
2309
2310bool PluginManager::RegisterPlugin(llvm::StringRef name,
2311 llvm::StringRef description,
2312 HighlighterCreateInstance create_callback) {
2313 return GetHighlighterInstances().RegisterPlugin(name, description,
2314 create_callback);
2315}
2316
2318 HighlighterCreateInstance create_callback) {
2319 return GetHighlighterInstances().UnregisterPlugin(create_callback);
2320}
2321
2322llvm::SmallVector<HighlighterCreateInstance>
2326
2327#pragma mark PluginManager
2328
2344
2345// This is the preferred new way to register plugin specific settings. e.g.
2346// This will put a plugin's settings under e.g.
2347// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
2349 Debugger &debugger, llvm::StringRef plugin_type_name,
2350 llvm::StringRef plugin_type_desc, bool can_create) {
2351 lldb::OptionValuePropertiesSP parent_properties_sp(
2352 debugger.GetValueProperties());
2353 if (parent_properties_sp) {
2354 static constexpr llvm::StringLiteral g_property_name("plugin");
2355
2356 OptionValuePropertiesSP plugin_properties_sp =
2357 parent_properties_sp->GetSubProperty(nullptr, g_property_name);
2358 if (!plugin_properties_sp && can_create) {
2359 plugin_properties_sp =
2360 std::make_shared<OptionValueProperties>(g_property_name);
2361 plugin_properties_sp->SetExpectedPath("plugin");
2362 parent_properties_sp->AppendProperty(g_property_name,
2363 "Settings specify to plugins.", true,
2364 plugin_properties_sp);
2365 }
2366
2367 if (plugin_properties_sp) {
2368 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2369 plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2370 if (!plugin_type_properties_sp && can_create) {
2371 plugin_type_properties_sp =
2372 std::make_shared<OptionValueProperties>(plugin_type_name);
2373 plugin_type_properties_sp->SetExpectedPath(
2374 ("plugin." + plugin_type_name).str());
2375 plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2376 true, plugin_type_properties_sp);
2377 }
2378 return plugin_type_properties_sp;
2379 }
2380 }
2382}
2383
2384// This is deprecated way to register plugin specific settings. e.g.
2385// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
2386// generic settings would be under "platform.SETTINGNAME".
2388 Debugger &debugger, llvm::StringRef plugin_type_name,
2389 llvm::StringRef plugin_type_desc, bool can_create) {
2390 static constexpr llvm::StringLiteral g_property_name("plugin");
2391 lldb::OptionValuePropertiesSP parent_properties_sp(
2392 debugger.GetValueProperties());
2393 if (parent_properties_sp) {
2394 OptionValuePropertiesSP plugin_properties_sp =
2395 parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2396 if (!plugin_properties_sp && can_create) {
2397 plugin_properties_sp =
2398 std::make_shared<OptionValueProperties>(plugin_type_name);
2399 plugin_properties_sp->SetExpectedPath(plugin_type_name.str());
2400 parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2401 true, plugin_properties_sp);
2402 }
2403
2404 if (plugin_properties_sp) {
2405 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2406 plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
2407 if (!plugin_type_properties_sp && can_create) {
2408 plugin_type_properties_sp =
2409 std::make_shared<OptionValueProperties>(g_property_name);
2410 plugin_type_properties_sp->SetExpectedPath(
2411 (plugin_type_name + ".plugin").str());
2412 plugin_properties_sp->AppendProperty(g_property_name,
2413 "Settings specific to plugins",
2414 true, plugin_type_properties_sp);
2415 }
2416 return plugin_type_properties_sp;
2417 }
2418 }
2420}
2421
2422namespace {
2423
2425GetDebuggerPropertyForPluginsPtr(Debugger &, llvm::StringRef, llvm::StringRef,
2426 bool can_create);
2427}
2428
2430GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name,
2431 llvm::StringRef plugin_type_name,
2432 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2434 lldb::OptionValuePropertiesSP properties_sp;
2435 lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property(
2436 debugger, plugin_type_name,
2437 "", // not creating to so we don't need the description
2438 false));
2439 if (plugin_type_properties_sp)
2440 properties_sp =
2441 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2442 return properties_sp;
2443}
2444
2445static bool
2446CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name,
2447 llvm::StringRef plugin_type_desc,
2448 const lldb::OptionValuePropertiesSP &properties_sp,
2449 llvm::StringRef description, bool is_global_property,
2450 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2452 if (properties_sp) {
2453 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2454 get_debugger_property(debugger, plugin_type_name, plugin_type_desc,
2455 true));
2456 if (plugin_type_properties_sp) {
2457 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2458 description, is_global_property,
2459 properties_sp);
2460 return true;
2461 }
2462 }
2463 return false;
2464}
2465
2466static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader");
2467static constexpr llvm::StringLiteral kPlatformPluginName("platform");
2468static constexpr llvm::StringLiteral kProcessPluginName("process");
2469static constexpr llvm::StringLiteral kTracePluginName("trace");
2470static constexpr llvm::StringLiteral kObjectFilePluginName("object-file");
2471static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file");
2472static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator");
2473static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader");
2474static constexpr llvm::StringLiteral
2475 kStructuredDataPluginName("structured-data");
2476static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus");
2477
2480 llvm::StringRef setting_name) {
2481 return GetSettingForPlugin(debugger, setting_name, kDynamicLoaderPluginName);
2482}
2483
2485 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2486 llvm::StringRef description, bool is_global_property) {
2488 "Settings for dynamic loader plug-ins",
2489 properties_sp, description, is_global_property);
2490}
2491
2494 llvm::StringRef setting_name) {
2495 return GetSettingForPlugin(debugger, setting_name, kPlatformPluginName,
2497}
2498
2500 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2501 llvm::StringRef description, bool is_global_property) {
2503 "Settings for platform plug-ins", properties_sp,
2504 description, is_global_property,
2506}
2507
2510 llvm::StringRef setting_name) {
2511 return GetSettingForPlugin(debugger, setting_name, kProcessPluginName);
2512}
2513
2515 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2516 llvm::StringRef description, bool is_global_property) {
2518 "Settings for process plug-ins", properties_sp,
2519 description, is_global_property);
2520}
2521
2524 llvm::StringRef setting_name) {
2525 return GetSettingForPlugin(debugger, setting_name, kSymbolLocatorPluginName);
2526}
2527
2529 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2530 llvm::StringRef description, bool is_global_property) {
2532 "Settings for symbol locator plug-ins",
2533 properties_sp, description, is_global_property);
2534}
2535
2537 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2538 llvm::StringRef description, bool is_global_property) {
2540 "Settings for trace plug-ins", properties_sp,
2541 description, is_global_property);
2542}
2543
2546 llvm::StringRef setting_name) {
2547 return GetSettingForPlugin(debugger, setting_name, kObjectFilePluginName);
2548}
2549
2551 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2552 llvm::StringRef description, bool is_global_property) {
2554 "Settings for object file plug-ins",
2555 properties_sp, description, is_global_property);
2556}
2557
2560 llvm::StringRef setting_name) {
2561 return GetSettingForPlugin(debugger, setting_name, kSymbolFilePluginName);
2562}
2563
2565 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2566 llvm::StringRef description, bool is_global_property) {
2568 "Settings for symbol file plug-ins",
2569 properties_sp, description, is_global_property);
2570}
2571
2574 llvm::StringRef setting_name) {
2575 return GetSettingForPlugin(debugger, setting_name, kJITLoaderPluginName);
2576}
2577
2579 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2580 llvm::StringRef description, bool is_global_property) {
2582 "Settings for JIT loader plug-ins",
2583 properties_sp, description, is_global_property);
2584}
2585
2586static const char *kOperatingSystemPluginName("os");
2587
2589 Debugger &debugger, llvm::StringRef setting_name) {
2590 lldb::OptionValuePropertiesSP properties_sp;
2591 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2594 "", // not creating to so we don't need the description
2595 false));
2596 if (plugin_type_properties_sp)
2597 properties_sp =
2598 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2599 return properties_sp;
2600}
2601
2603 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2604 llvm::StringRef description, bool is_global_property) {
2605 if (properties_sp) {
2606 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2608 "Settings for operating system plug-ins",
2609 true));
2610 if (plugin_type_properties_sp) {
2611 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2612 description, is_global_property,
2613 properties_sp);
2614 return true;
2615 }
2616 }
2617 return false;
2618}
2619
2622 llvm::StringRef setting_name) {
2623 return GetSettingForPlugin(debugger, setting_name, kStructuredDataPluginName);
2624}
2625
2627 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2628 llvm::StringRef description, bool is_global_property) {
2630 "Settings for structured data plug-ins",
2631 properties_sp, description, is_global_property);
2632}
2633
2636 Debugger &debugger, llvm::StringRef setting_name) {
2637 return GetSettingForPlugin(debugger, setting_name, kCPlusPlusLanguagePlugin);
2638}
2639
2641 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2642 llvm::StringRef description, bool is_global_property) {
2644 "Settings for CPlusPlus language plug-ins",
2645 properties_sp, description, is_global_property);
2646}
2647
2648//
2649// Plugin Info+Enable Implementations
2650//
2651llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetABIPluginInfo() {
2653}
2654bool PluginManager::SetABIPluginEnabled(llvm::StringRef name, bool enable) {
2655 return GetABIInstances().SetInstanceEnabled(name, enable);
2656}
2657
2658llvm::SmallVector<RegisteredPluginInfo>
2663 bool enable) {
2664 return GetArchitectureInstances().SetInstanceEnabled(name, enable);
2665}
2666
2667llvm::SmallVector<RegisteredPluginInfo>
2672 bool enable) {
2673 return GetBugReporterInstances().SetInstanceEnabled(name, enable);
2674}
2675
2676llvm::SmallVector<RegisteredPluginInfo>
2681 bool enable) {
2682 return GetDisassemblerInstances().SetInstanceEnabled(name, enable);
2683}
2684
2685llvm::SmallVector<RegisteredPluginInfo>
2690 bool enable) {
2691 return GetDynamicLoaderInstances().SetInstanceEnabled(name, enable);
2692}
2693
2694llvm::SmallVector<RegisteredPluginInfo>
2699 bool enable) {
2701}
2702
2703llvm::SmallVector<RegisteredPluginInfo>
2707
2709 switch (kind) {
2711 return "global";
2713 return "debugger";
2715 return "target";
2716 }
2717 llvm_unreachable("unhandled PluginDomainKind");
2718}
2719
2721 llvm::StringRef name, bool enable, Debugger &requesting_debugger,
2722 PluginDomainKind domain) {
2723 if (domain != lldb::ePluginDomainKindGlobal)
2724 return llvm::createStringErrorV("{} domain is not supported",
2725 PluginDomainKindToStr(domain));
2726 if (!GetInstrumentationRuntimeInstances().SetInstanceEnabled(name, enable))
2727 return llvm::createStringError("plugin could not be found");
2728
2729 return llvm::Error::success();
2730}
2731
2732llvm::SmallVector<RegisteredPluginInfo>
2737 bool enable) {
2738 return GetJITLoaderInstances().SetInstanceEnabled(name, enable);
2739}
2740
2741llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetLanguagePluginInfo() {
2743}
2745 bool enable) {
2746 bool found = GetLanguageInstances().SetInstanceEnabled(name, enable);
2747 if (found)
2748 GetLanguageInstanceCache().Invalidate();
2749 return found;
2750}
2751
2752llvm::SmallVector<RegisteredPluginInfo>
2757 bool enable) {
2758 return GetLanguageRuntimeInstances().SetInstanceEnabled(name, enable);
2759}
2760
2761llvm::SmallVector<RegisteredPluginInfo>
2766 bool enable) {
2767 return GetMemoryHistoryInstances().SetInstanceEnabled(name, enable);
2768}
2769
2770llvm::SmallVector<RegisteredPluginInfo>
2775 bool enable) {
2776 return GetObjectContainerInstances().SetInstanceEnabled(name, enable);
2777}
2778
2779llvm::SmallVector<RegisteredPluginInfo>
2784 bool enable) {
2785 return GetObjectFileInstances().SetInstanceEnabled(name, enable);
2786}
2787
2788llvm::SmallVector<RegisteredPluginInfo>
2793 bool enable) {
2794 return GetOperatingSystemInstances().SetInstanceEnabled(name, enable);
2795}
2796
2797llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetPlatformPluginInfo() {
2799}
2801 bool enable) {
2802 return GetPlatformInstances().SetInstanceEnabled(name, enable);
2803}
2804
2805llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetProcessPluginInfo() {
2807}
2808bool PluginManager::SetProcessPluginEnabled(llvm::StringRef name, bool enable) {
2809 return GetProcessInstances().SetInstanceEnabled(name, enable);
2810}
2811
2812llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetREPLPluginInfo() {
2814}
2815bool PluginManager::SetREPLPluginEnabled(llvm::StringRef name, bool enable) {
2816 return GetREPLInstances().SetInstanceEnabled(name, enable);
2817}
2818
2819llvm::SmallVector<RegisteredPluginInfo>
2824 bool enable) {
2826}
2827
2828llvm::SmallVector<RegisteredPluginInfo>
2833 bool enable) {
2835}
2836
2837llvm::SmallVector<RegisteredPluginInfo>
2842 bool enable) {
2844}
2845
2846llvm::SmallVector<RegisteredPluginInfo>
2851 bool enable) {
2853}
2854
2855llvm::SmallVector<RegisteredPluginInfo>
2860 bool enable) {
2861 return GetSymbolFileInstances().SetInstanceEnabled(name, enable);
2862}
2863
2864llvm::SmallVector<RegisteredPluginInfo>
2869 bool enable) {
2870 return GetSymbolLocatorInstances().SetInstanceEnabled(name, enable);
2871}
2872
2873llvm::SmallVector<RegisteredPluginInfo>
2878 bool enable) {
2879 return GetSymbolVendorInstances().SetInstanceEnabled(name, enable);
2880}
2881
2882llvm::SmallVector<RegisteredPluginInfo>
2887 bool enable) {
2888 return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable);
2889}
2890
2891llvm::SmallVector<RegisteredPluginInfo> PluginManager::GetTracePluginInfo() {
2893}
2894bool PluginManager::SetTracePluginEnabled(llvm::StringRef name, bool enable) {
2895 return GetTracePluginInstances().SetInstanceEnabled(name, enable);
2896}
2897
2898llvm::SmallVector<RegisteredPluginInfo>
2903 bool enable) {
2904 return GetTraceExporterInstances().SetInstanceEnabled(name, enable);
2905}
2906
2907llvm::SmallVector<RegisteredPluginInfo>
2912 bool enable) {
2913 return GetTypeSystemInstances().SetInstanceEnabled(name, enable);
2914}
2915
2916llvm::SmallVector<RegisteredPluginInfo>
2921 bool enable) {
2922 return GetUnwindAssemblyInstances().SetInstanceEnabled(name, enable);
2923}
2924
2926 CompletionRequest &request) {
2927 // Split the name into the namespace and the plugin name.
2928 // If there is no dot then the ns_name will be equal to name and
2929 // plugin_prefix will be empty.
2930 llvm::StringRef ns_name, plugin_prefix;
2931 std::tie(ns_name, plugin_prefix) = name.split('.');
2932
2933 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
2934 // If the plugin namespace matches exactly then
2935 // add all the plugins in this namespace as completions if the
2936 // plugin names starts with the plugin_prefix. If the plugin_prefix
2937 // is empty then it will match all the plugins (empty string is a
2938 // prefix of everything).
2939 if (plugin_ns.name == ns_name) {
2940 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
2941 llvm::SmallString<128> buf;
2942 if (plugin.name.starts_with(plugin_prefix))
2943 request.AddCompletion(
2944 (plugin_ns.name + "." + plugin.name).toStringRef(buf));
2945 }
2946 } else if (plugin_ns.name.starts_with(name) &&
2947 !plugin_ns.get_info().empty()) {
2948 // Otherwise check if the namespace is a prefix of the full name.
2949 // Use a partial completion here so that we can either operate on the full
2950 // namespace or tab-complete to the next level.
2951 request.AddCompletion(plugin_ns.name, "", CompletionMode::Partial);
2952 }
2953 }
2954}
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:908
#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 LanguageInstanceCache & GetLanguageInstanceCache()
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)
static std::optional< V > Lookup(StringMap< V > &map, StringRef k)
Helper functions for fetching data in maps and returning Optionals or pointers instead of iterators f...
Definition Trace.cpp:53
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:106
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 Language * GetLanguageInstance(lldb::LanguageType language)
Returns the instance of the enabled language plugin that supports language, creating it on first use,...
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 std::vector< Language * > GetAllLanguageInstances()
Returns GetLanguageInstance() for every language type that an enabled language plugin supports,...
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 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
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
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).