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
11#include "lldb/Core/Debugger.h"
13#include "lldb/Host/HostInfo.h"
15#include "lldb/Target/Process.h"
18#include "lldb/Utility/Status.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/DynamicLibrary.h"
22#include "llvm/Support/FileSystem.h"
23#include "llvm/Support/raw_ostream.h"
24#include <cassert>
25#include <map>
26#include <memory>
27#include <mutex>
28#include <string>
29#include <utility>
30#include <vector>
31#if defined(_WIN32)
33#endif
34
35using namespace lldb;
36using namespace lldb_private;
37
38typedef bool (*PluginInitCallback)();
39typedef void (*PluginTermCallback)();
40
41struct PluginInfo {
42 PluginInfo() = default;
43
44 llvm::sys::DynamicLibrary library;
47};
48
49typedef std::map<FileSpec, PluginInfo> PluginTerminateMap;
50
51static std::recursive_mutex &GetPluginMapMutex() {
52 static std::recursive_mutex g_plugin_map_mutex;
53 return g_plugin_map_mutex;
54}
55
57 static PluginTerminateMap g_plugin_map;
58 return g_plugin_map;
59}
60
61static bool PluginIsLoaded(const FileSpec &plugin_file_spec) {
62 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
63 PluginTerminateMap &plugin_map = GetPluginMap();
64 return plugin_map.find(plugin_file_spec) != plugin_map.end();
65}
66
67static void SetPluginInfo(const FileSpec &plugin_file_spec,
68 const PluginInfo &plugin_info) {
69 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
70 PluginTerminateMap &plugin_map = GetPluginMap();
71 assert(plugin_map.find(plugin_file_spec) == plugin_map.end());
72 plugin_map[plugin_file_spec] = plugin_info;
73}
74
75template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
76 return reinterpret_cast<FPtrTy>(VPtr);
77}
78
80LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
81 llvm::StringRef path) {
83
84 namespace fs = llvm::sys::fs;
85 // If we have a regular file, a symbolic link or unknown file type, try and
86 // process the file. We must handle unknown as sometimes the directory
87 // enumeration might be enumerating a file system that doesn't have correct
88 // file type information.
89 if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
90 ft == fs::file_type::type_unknown) {
91 FileSpec plugin_file_spec(path);
92 FileSystem::Instance().Resolve(plugin_file_spec);
93
94 if (PluginIsLoaded(plugin_file_spec))
96 else {
97 PluginInfo plugin_info;
98
99 std::string pluginLoadError;
100 plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary(
101 plugin_file_spec.GetPath().c_str(), &pluginLoadError);
102 if (plugin_info.library.isValid()) {
103 bool success = false;
104 plugin_info.plugin_init_callback = CastToFPtr<PluginInitCallback>(
105 plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"));
106 if (plugin_info.plugin_init_callback) {
107 // Call the plug-in "bool LLDBPluginInitialize(void)" function
108 success = plugin_info.plugin_init_callback();
109 }
110
111 if (success) {
112 // It is ok for the "LLDBPluginTerminate" symbol to be nullptr
113 plugin_info.plugin_term_callback = CastToFPtr<PluginTermCallback>(
114 plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
115 } else {
116 // The initialize function returned FALSE which means the plug-in
117 // might not be compatible, or might be too new or too old, or might
118 // not want to run on this machine. Set it to a default-constructed
119 // instance to invalidate it.
120 plugin_info = PluginInfo();
121 }
122
123 // Regardless of success or failure, cache the plug-in load in our
124 // plug-in info so we don't try to load it again and again.
125 SetPluginInfo(plugin_file_spec, plugin_info);
126
128 }
129 }
130 }
131
132 if (ft == fs::file_type::directory_file ||
133 ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
134 // Try and recurse into anything that a directory or symbolic link. We must
135 // also do this for unknown as sometimes the directory enumeration might be
136 // enumerating a file system that doesn't have correct file type
137 // information.
139 }
140
142}
143
145 const bool find_directories = true;
146 const bool find_files = true;
147 const bool find_other = true;
148 char dir_path[PATH_MAX];
149 if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) {
150 if (FileSystem::Instance().Exists(dir_spec) &&
151 dir_spec.GetPath(dir_path, sizeof(dir_path))) {
152 FileSystem::Instance().EnumerateDirectory(dir_path, find_directories,
153 find_files, find_other,
154 LoadPluginCallback, nullptr);
155 }
156 }
157
158 if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) {
159 if (FileSystem::Instance().Exists(dir_spec) &&
160 dir_spec.GetPath(dir_path, sizeof(dir_path))) {
161 FileSystem::Instance().EnumerateDirectory(dir_path, find_directories,
162 find_files, find_other,
163 LoadPluginCallback, nullptr);
164 }
165 }
166}
167
169 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
170 PluginTerminateMap &plugin_map = GetPluginMap();
171
172 PluginTerminateMap::const_iterator pos, end = plugin_map.end();
173 for (pos = plugin_map.begin(); pos != end; ++pos) {
174 // Call the plug-in "void LLDBPluginTerminate (void)" function if there is
175 // one (if the symbol was not nullptr).
176 if (pos->second.library.isValid()) {
177 if (pos->second.plugin_term_callback)
178 pos->second.plugin_term_callback();
179 }
180 }
181 plugin_map.clear();
182}
183
184template <typename Callback> struct PluginInstance {
185 typedef Callback CallbackType;
186
187 PluginInstance() = default;
188 PluginInstance(llvm::StringRef name, llvm::StringRef description,
189 Callback create_callback,
190 DebuggerInitializeCallback debugger_init_callback = nullptr)
191 : name(name), description(description), create_callback(create_callback),
192 debugger_init_callback(debugger_init_callback) {}
193
194 llvm::StringRef name;
195 llvm::StringRef description;
198};
199
200template <typename Instance> class PluginInstances {
201public:
202 template <typename... Args>
203 bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
204 typename Instance::CallbackType callback,
205 Args &&...args) {
206 if (!callback)
207 return false;
208 assert(!name.empty());
209 Instance instance =
210 Instance(name, description, callback, std::forward<Args>(args)...);
211 m_instances.push_back(instance);
212 return false;
213 }
214
215 bool UnregisterPlugin(typename Instance::CallbackType callback) {
216 if (!callback)
217 return false;
218 auto pos = m_instances.begin();
219 auto end = m_instances.end();
220 for (; pos != end; ++pos) {
221 if (pos->create_callback == callback) {
222 m_instances.erase(pos);
223 return true;
224 }
225 }
226 return false;
227 }
228
229 typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) {
230 if (Instance *instance = GetInstanceAtIndex(idx))
231 return instance->create_callback;
232 return nullptr;
233 }
234
235 llvm::StringRef GetDescriptionAtIndex(uint32_t idx) {
236 if (Instance *instance = GetInstanceAtIndex(idx))
237 return instance->description;
238 return "";
239 }
240
241 llvm::StringRef GetNameAtIndex(uint32_t idx) {
242 if (Instance *instance = GetInstanceAtIndex(idx))
243 return instance->name;
244 return "";
245 }
246
247 typename Instance::CallbackType GetCallbackForName(llvm::StringRef name) {
248 if (name.empty())
249 return nullptr;
250 for (auto &instance : m_instances) {
251 if (name == instance.name)
252 return instance.create_callback;
253 }
254 return nullptr;
255 }
256
258 for (auto &instance : m_instances) {
259 if (instance.debugger_init_callback)
260 instance.debugger_init_callback(debugger);
261 }
262 }
263
264 const std::vector<Instance> &GetInstances() const { return m_instances; }
265 std::vector<Instance> &GetInstances() { return m_instances; }
266
268 if (idx < m_instances.size())
269 return &m_instances[idx];
270 return nullptr;
271 }
272
273private:
274 std::vector<Instance> m_instances;
275};
276
277#pragma mark ABI
278
281
283 static ABIInstances g_instances;
284 return g_instances;
285}
286
287bool PluginManager::RegisterPlugin(llvm::StringRef name,
288 llvm::StringRef description,
289 ABICreateInstance create_callback) {
290 return GetABIInstances().RegisterPlugin(name, description, create_callback);
291}
292
293bool PluginManager::UnregisterPlugin(ABICreateInstance create_callback) {
294 return GetABIInstances().UnregisterPlugin(create_callback);
295}
296
299}
300
301#pragma mark Architecture
302
304typedef std::vector<ArchitectureInstance> ArchitectureInstances;
305
307 static ArchitectureInstances g_instances;
308 return g_instances;
309}
310
311void PluginManager::RegisterPlugin(llvm::StringRef name,
312 llvm::StringRef description,
313 ArchitectureCreateInstance create_callback) {
314 GetArchitectureInstances().push_back({name, description, create_callback});
315}
316
318 ArchitectureCreateInstance create_callback) {
319 auto &instances = GetArchitectureInstances();
320
321 for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) {
322 if (pos->create_callback == create_callback) {
323 instances.erase(pos);
324 return;
325 }
326 }
327 llvm_unreachable("Plugin not found");
328}
329
330std::unique_ptr<Architecture>
332 for (const auto &instances : GetArchitectureInstances()) {
333 if (auto plugin_up = instances.create_callback(arch))
334 return plugin_up;
335 }
336 return nullptr;
337}
338
339#pragma mark Disassembler
340
343
345 static DisassemblerInstances g_instances;
346 return g_instances;
347}
348
349bool PluginManager::RegisterPlugin(llvm::StringRef name,
350 llvm::StringRef description,
351 DisassemblerCreateInstance create_callback) {
352 return GetDisassemblerInstances().RegisterPlugin(name, description,
353 create_callback);
354}
355
357 DisassemblerCreateInstance create_callback) {
358 return GetDisassemblerInstances().UnregisterPlugin(create_callback);
359}
360
361DisassemblerCreateInstance
364}
365
366DisassemblerCreateInstance
368 llvm::StringRef name) {
370}
371
372#pragma mark DynamicLoader
373
376
378 static DynamicLoaderInstances g_instances;
379 return g_instances;
380}
381
383 llvm::StringRef name, llvm::StringRef description,
384 DynamicLoaderCreateInstance create_callback,
385 DebuggerInitializeCallback debugger_init_callback) {
387 name, description, create_callback, debugger_init_callback);
388}
389
391 DynamicLoaderCreateInstance create_callback) {
392 return GetDynamicLoaderInstances().UnregisterPlugin(create_callback);
393}
394
395DynamicLoaderCreateInstance
398}
399
400DynamicLoaderCreateInstance
402 llvm::StringRef name) {
404}
405
406#pragma mark JITLoader
407
410
412 static JITLoaderInstances g_instances;
413 return g_instances;
414}
415
417 llvm::StringRef name, llvm::StringRef description,
418 JITLoaderCreateInstance create_callback,
419 DebuggerInitializeCallback debugger_init_callback) {
421 name, description, create_callback, debugger_init_callback);
422}
423
424bool PluginManager::UnregisterPlugin(JITLoaderCreateInstance create_callback) {
425 return GetJITLoaderInstances().UnregisterPlugin(create_callback);
426}
427
428JITLoaderCreateInstance
431}
432
433#pragma mark EmulateInstruction
434
438
440 static EmulateInstructionInstances g_instances;
441 return g_instances;
442}
443
445 llvm::StringRef name, llvm::StringRef description,
446 EmulateInstructionCreateInstance create_callback) {
447 return GetEmulateInstructionInstances().RegisterPlugin(name, description,
448 create_callback);
449}
450
452 EmulateInstructionCreateInstance create_callback) {
453 return GetEmulateInstructionInstances().UnregisterPlugin(create_callback);
454}
455
456EmulateInstructionCreateInstance
459}
460
461EmulateInstructionCreateInstance
463 llvm::StringRef name) {
465}
466
467#pragma mark OperatingSystem
468
471
473 static OperatingSystemInstances g_instances;
474 return g_instances;
475}
476
478 llvm::StringRef name, llvm::StringRef description,
479 OperatingSystemCreateInstance create_callback,
480 DebuggerInitializeCallback debugger_init_callback) {
482 name, description, create_callback, debugger_init_callback);
483}
484
486 OperatingSystemCreateInstance create_callback) {
487 return GetOperatingSystemInstances().UnregisterPlugin(create_callback);
488}
489
490OperatingSystemCreateInstance
493}
494
495OperatingSystemCreateInstance
497 llvm::StringRef name) {
499}
500
501#pragma mark Language
502
505
507 static LanguageInstances g_instances;
508 return g_instances;
509}
510
511bool PluginManager::RegisterPlugin(llvm::StringRef name,
512 llvm::StringRef description,
513 LanguageCreateInstance create_callback) {
514 return GetLanguageInstances().RegisterPlugin(name, description,
515 create_callback);
516}
517
518bool PluginManager::UnregisterPlugin(LanguageCreateInstance create_callback) {
519 return GetLanguageInstances().UnregisterPlugin(create_callback);
520}
521
522LanguageCreateInstance
525}
526
527#pragma mark LanguageRuntime
528
530 : public PluginInstance<LanguageRuntimeCreateInstance> {
532 llvm::StringRef name, llvm::StringRef description,
533 CallbackType create_callback,
534 DebuggerInitializeCallback debugger_init_callback,
535 LanguageRuntimeGetCommandObject command_callback,
536 LanguageRuntimeGetExceptionPrecondition precondition_callback)
538 name, description, create_callback, debugger_init_callback),
539 command_callback(command_callback),
540 precondition_callback(precondition_callback) {}
541
542 LanguageRuntimeGetCommandObject command_callback;
543 LanguageRuntimeGetExceptionPrecondition precondition_callback;
544};
545
547
549 static LanguageRuntimeInstances g_instances;
550 return g_instances;
551}
552
554 llvm::StringRef name, llvm::StringRef description,
555 LanguageRuntimeCreateInstance create_callback,
556 LanguageRuntimeGetCommandObject command_callback,
557 LanguageRuntimeGetExceptionPrecondition precondition_callback) {
559 name, description, create_callback, nullptr, command_callback,
560 precondition_callback);
561}
562
564 LanguageRuntimeCreateInstance create_callback) {
565 return GetLanguageRuntimeInstances().UnregisterPlugin(create_callback);
566}
567
571}
572
573LanguageRuntimeGetCommandObject
575 const auto &instances = GetLanguageRuntimeInstances().GetInstances();
576 if (idx < instances.size())
577 return instances[idx].command_callback;
578 return nullptr;
579}
580
581LanguageRuntimeGetExceptionPrecondition
583 const auto &instances = GetLanguageRuntimeInstances().GetInstances();
584 if (idx < instances.size())
585 return instances[idx].precondition_callback;
586 return nullptr;
587}
588
589#pragma mark SystemRuntime
590
593
595 static SystemRuntimeInstances g_instances;
596 return g_instances;
597}
598
600 llvm::StringRef name, llvm::StringRef description,
601 SystemRuntimeCreateInstance create_callback) {
602 return GetSystemRuntimeInstances().RegisterPlugin(name, description,
603 create_callback);
604}
605
607 SystemRuntimeCreateInstance create_callback) {
608 return GetSystemRuntimeInstances().UnregisterPlugin(create_callback);
609}
610
611SystemRuntimeCreateInstance
614}
615
616#pragma mark ObjectFile
617
618struct ObjectFileInstance : public PluginInstance<ObjectFileCreateInstance> {
620 llvm::StringRef name, llvm::StringRef description,
621 CallbackType create_callback,
622 ObjectFileCreateMemoryInstance create_memory_callback,
623 ObjectFileGetModuleSpecifications get_module_specifications,
624 ObjectFileSaveCore save_core,
625 DebuggerInitializeCallback debugger_init_callback)
627 name, description, create_callback, debugger_init_callback),
628 create_memory_callback(create_memory_callback),
629 get_module_specifications(get_module_specifications),
630 save_core(save_core) {}
631
632 ObjectFileCreateMemoryInstance create_memory_callback;
633 ObjectFileGetModuleSpecifications get_module_specifications;
634 ObjectFileSaveCore save_core;
635};
637
639 static ObjectFileInstances g_instances;
640 return g_instances;
641}
642
644 llvm::StringRef name, llvm::StringRef description,
645 ObjectFileCreateInstance create_callback,
646 ObjectFileCreateMemoryInstance create_memory_callback,
647 ObjectFileGetModuleSpecifications get_module_specifications,
648 ObjectFileSaveCore save_core,
649 DebuggerInitializeCallback debugger_init_callback) {
651 name, description, create_callback, create_memory_callback,
652 get_module_specifications, save_core, debugger_init_callback);
653}
654
656 return GetObjectFileInstances().UnregisterPlugin(create_callback);
657}
658
662}
663
664ObjectFileCreateMemoryInstance
666 const auto &instances = GetObjectFileInstances().GetInstances();
667 if (idx < instances.size())
668 return instances[idx].create_memory_callback;
669 return nullptr;
670}
671
672ObjectFileGetModuleSpecifications
674 uint32_t idx) {
675 const auto &instances = GetObjectFileInstances().GetInstances();
676 if (idx < instances.size())
677 return instances[idx].get_module_specifications;
678 return nullptr;
679}
680
681ObjectFileCreateMemoryInstance
683 llvm::StringRef name) {
684 const auto &instances = GetObjectFileInstances().GetInstances();
685 for (auto &instance : instances) {
686 if (instance.name == name)
687 return instance.create_memory_callback;
688 }
689 return nullptr;
690}
691
692Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp,
693 const FileSpec &outfile,
694 lldb::SaveCoreStyle &core_style,
695 llvm::StringRef plugin_name) {
696 if (plugin_name.empty()) {
697 // Try saving core directly from the process plugin first.
698 llvm::Expected<bool> ret = process_sp->SaveCore(outfile.GetPath());
699 if (!ret)
700 return Status(ret.takeError());
701 if (ret.get())
702 return Status();
703 }
704
705 // Fall back to object plugins.
707 auto &instances = GetObjectFileInstances().GetInstances();
708 for (auto &instance : instances) {
709 if (plugin_name.empty() || instance.name == plugin_name) {
710 if (instance.save_core &&
711 instance.save_core(process_sp, outfile, core_style, error))
712 return error;
713 }
714 }
715 error.SetErrorString(
716 "no ObjectFile plugins were able to save a core for this process");
717 return error;
718}
719
720#pragma mark ObjectContainer
721
723 : public PluginInstance<ObjectContainerCreateInstance> {
725 llvm::StringRef name, llvm::StringRef description,
726 CallbackType create_callback,
727 ObjectContainerCreateMemoryInstance create_memory_callback,
728 ObjectFileGetModuleSpecifications get_module_specifications)
730 create_callback),
731 create_memory_callback(create_memory_callback),
732 get_module_specifications(get_module_specifications) {}
733
734 ObjectContainerCreateMemoryInstance create_memory_callback;
735 ObjectFileGetModuleSpecifications get_module_specifications;
736};
738
740 static ObjectContainerInstances g_instances;
741 return g_instances;
742}
743
745 llvm::StringRef name, llvm::StringRef description,
746 ObjectContainerCreateInstance create_callback,
747 ObjectFileGetModuleSpecifications get_module_specifications,
748 ObjectContainerCreateMemoryInstance create_memory_callback) {
750 name, description, create_callback, create_memory_callback,
751 get_module_specifications);
752}
753
755 ObjectContainerCreateInstance create_callback) {
756 return GetObjectContainerInstances().UnregisterPlugin(create_callback);
757}
758
762}
763
764ObjectContainerCreateMemoryInstance
766 const auto &instances = GetObjectContainerInstances().GetInstances();
767 if (idx < instances.size())
768 return instances[idx].create_memory_callback;
769 return nullptr;
770}
771
772ObjectFileGetModuleSpecifications
774 uint32_t idx) {
775 const auto &instances = GetObjectContainerInstances().GetInstances();
776 if (idx < instances.size())
777 return instances[idx].get_module_specifications;
778 return nullptr;
779}
780
781#pragma mark Platform
782
785
787 static PlatformInstances g_platform_instances;
788 return g_platform_instances;
789}
790
792 llvm::StringRef name, llvm::StringRef description,
793 PlatformCreateInstance create_callback,
794 DebuggerInitializeCallback debugger_init_callback) {
796 name, description, create_callback, debugger_init_callback);
797}
798
799bool PluginManager::UnregisterPlugin(PlatformCreateInstance create_callback) {
800 return GetPlatformInstances().UnregisterPlugin(create_callback);
801}
802
805}
806
807llvm::StringRef
810}
811
812PlatformCreateInstance
815}
816
817PlatformCreateInstance
820}
821
823 CompletionRequest &request) {
824 for (const auto &instance : GetPlatformInstances().GetInstances()) {
825 if (instance.name.startswith(name))
826 request.AddCompletion(instance.name);
827 }
828}
829
830#pragma mark Process
831
834
836 static ProcessInstances g_instances;
837 return g_instances;
838}
839
841 llvm::StringRef name, llvm::StringRef description,
842 ProcessCreateInstance create_callback,
843 DebuggerInitializeCallback debugger_init_callback) {
845 name, description, create_callback, debugger_init_callback);
846}
847
848bool PluginManager::UnregisterPlugin(ProcessCreateInstance create_callback) {
849 return GetProcessInstances().UnregisterPlugin(create_callback);
850}
851
854}
855
858}
859
860ProcessCreateInstance
863}
864
865ProcessCreateInstance
868}
869
871 CompletionRequest &request) {
872 for (const auto &instance : GetProcessInstances().GetInstances()) {
873 if (instance.name.startswith(name))
874 request.AddCompletion(instance.name, instance.description);
875 }
876}
877
878#pragma mark RegisterTypeBuilder
879
881 : public PluginInstance<RegisterTypeBuilderCreateInstance> {
882 RegisterTypeBuilderInstance(llvm::StringRef name, llvm::StringRef description,
883 CallbackType create_callback)
885 create_callback) {}
886};
887
890
892 static RegisterTypeBuilderInstances g_instances;
893 return g_instances;
894}
895
897 llvm::StringRef name, llvm::StringRef description,
898 RegisterTypeBuilderCreateInstance create_callback) {
899 return GetRegisterTypeBuilderInstances().RegisterPlugin(name, description,
900 create_callback);
901}
902
904 RegisterTypeBuilderCreateInstance create_callback) {
905 return GetRegisterTypeBuilderInstances().UnregisterPlugin(create_callback);
906}
907
908lldb::RegisterTypeBuilderSP
910 const auto &instances = GetRegisterTypeBuilderInstances().GetInstances();
911 // We assume that RegisterTypeBuilderClang is the only instance of this plugin
912 // type and is always present.
913 assert(instances.size());
914 return instances[0].create_callback(target);
915}
916
917#pragma mark ScriptInterpreter
918
920 : public PluginInstance<ScriptInterpreterCreateInstance> {
921 ScriptInterpreterInstance(llvm::StringRef name, llvm::StringRef description,
922 CallbackType create_callback,
923 lldb::ScriptLanguage language)
925 create_callback),
926 language(language) {}
927
929};
930
932
934 static ScriptInterpreterInstances g_instances;
935 return g_instances;
936}
937
939 llvm::StringRef name, llvm::StringRef description,
940 lldb::ScriptLanguage script_language,
941 ScriptInterpreterCreateInstance create_callback) {
943 name, description, create_callback, script_language);
944}
945
947 ScriptInterpreterCreateInstance create_callback) {
948 return GetScriptInterpreterInstances().UnregisterPlugin(create_callback);
949}
950
954}
955
956lldb::ScriptInterpreterSP
958 Debugger &debugger) {
959 const auto &instances = GetScriptInterpreterInstances().GetInstances();
960 ScriptInterpreterCreateInstance none_instance = nullptr;
961 for (const auto &instance : instances) {
962 if (instance.language == lldb::eScriptLanguageNone)
963 none_instance = instance.create_callback;
964
965 if (script_lang == instance.language)
966 return instance.create_callback(debugger);
967 }
968
969 // If we didn't find one, return the ScriptInterpreter for the null language.
970 assert(none_instance != nullptr);
971 return none_instance(debugger);
972}
973
974#pragma mark StructuredDataPlugin
975
977 : public PluginInstance<StructuredDataPluginCreateInstance> {
979 llvm::StringRef name, llvm::StringRef description,
980 CallbackType create_callback,
981 DebuggerInitializeCallback debugger_init_callback,
982 StructuredDataFilterLaunchInfo filter_callback)
984 name, description, create_callback, debugger_init_callback),
985 filter_callback(filter_callback) {}
986
987 StructuredDataFilterLaunchInfo filter_callback = nullptr;
988};
989
992
994 static StructuredDataPluginInstances g_instances;
995 return g_instances;
996}
997
999 llvm::StringRef name, llvm::StringRef description,
1000 StructuredDataPluginCreateInstance create_callback,
1001 DebuggerInitializeCallback debugger_init_callback,
1002 StructuredDataFilterLaunchInfo filter_callback) {
1004 name, description, create_callback, debugger_init_callback,
1005 filter_callback);
1006}
1007
1009 StructuredDataPluginCreateInstance create_callback) {
1010 return GetStructuredDataPluginInstances().UnregisterPlugin(create_callback);
1011}
1012
1016}
1017
1018StructuredDataFilterLaunchInfo
1020 uint32_t idx, bool &iteration_complete) {
1021 const auto &instances = GetStructuredDataPluginInstances().GetInstances();
1022 if (idx < instances.size()) {
1023 iteration_complete = false;
1024 return instances[idx].filter_callback;
1025 } else {
1026 iteration_complete = true;
1027 }
1028 return nullptr;
1029}
1030
1031#pragma mark SymbolFile
1032
1035
1037 static SymbolFileInstances g_instances;
1038 return g_instances;
1039}
1040
1042 llvm::StringRef name, llvm::StringRef description,
1043 SymbolFileCreateInstance create_callback,
1044 DebuggerInitializeCallback debugger_init_callback) {
1046 name, description, create_callback, debugger_init_callback);
1047}
1048
1049bool PluginManager::UnregisterPlugin(SymbolFileCreateInstance create_callback) {
1050 return GetSymbolFileInstances().UnregisterPlugin(create_callback);
1051}
1052
1053SymbolFileCreateInstance
1056}
1057
1058#pragma mark SymbolVendor
1059
1062
1064 static SymbolVendorInstances g_instances;
1065 return g_instances;
1066}
1067
1068bool PluginManager::RegisterPlugin(llvm::StringRef name,
1069 llvm::StringRef description,
1070 SymbolVendorCreateInstance create_callback) {
1071 return GetSymbolVendorInstances().RegisterPlugin(name, description,
1072 create_callback);
1073}
1074
1076 SymbolVendorCreateInstance create_callback) {
1077 return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
1078}
1079
1080SymbolVendorCreateInstance
1083}
1084
1085#pragma mark Trace
1086
1088 : public PluginInstance<TraceCreateInstanceFromBundle> {
1090 llvm::StringRef name, llvm::StringRef description,
1091 CallbackType create_callback_from_bundle,
1092 TraceCreateInstanceForLiveProcess create_callback_for_live_process,
1093 llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback)
1095 name, description, create_callback_from_bundle,
1096 debugger_init_callback),
1097 schema(schema),
1098 create_callback_for_live_process(create_callback_for_live_process) {}
1099
1100 llvm::StringRef schema;
1101 TraceCreateInstanceForLiveProcess create_callback_for_live_process;
1102};
1103
1105
1107 static TraceInstances g_instances;
1108 return g_instances;
1109}
1110
1112 llvm::StringRef name, llvm::StringRef description,
1113 TraceCreateInstanceFromBundle create_callback_from_bundle,
1114 TraceCreateInstanceForLiveProcess create_callback_for_live_process,
1115 llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) {
1117 name, description, create_callback_from_bundle,
1118 create_callback_for_live_process, schema, debugger_init_callback);
1119}
1120
1122 TraceCreateInstanceFromBundle create_callback_from_bundle) {
1124 create_callback_from_bundle);
1125}
1126
1128PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
1129 return GetTracePluginInstances().GetCallbackForName(plugin_name);
1130}
1131
1132TraceCreateInstanceForLiveProcess
1134 for (const TraceInstance &instance : GetTracePluginInstances().GetInstances())
1135 if (instance.name == plugin_name)
1136 return instance.create_callback_for_live_process;
1137 return nullptr;
1138}
1139
1140llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
1141 for (const TraceInstance &instance : GetTracePluginInstances().GetInstances())
1142 if (instance.name == plugin_name)
1143 return instance.schema;
1144 return llvm::StringRef();
1145}
1146
1147llvm::StringRef PluginManager::GetTraceSchema(size_t index) {
1148 if (TraceInstance *instance =
1149 GetTracePluginInstances().GetInstanceAtIndex(index))
1150 return instance->schema;
1151 return llvm::StringRef();
1152}
1153
1154#pragma mark TraceExporter
1155
1157 : public PluginInstance<TraceExporterCreateInstance> {
1159 llvm::StringRef name, llvm::StringRef description,
1160 TraceExporterCreateInstance create_instance,
1161 ThreadTraceExportCommandCreator create_thread_trace_export_command)
1162 : PluginInstance<TraceExporterCreateInstance>(name, description,
1163 create_instance),
1164 create_thread_trace_export_command(create_thread_trace_export_command) {
1165 }
1166
1167 ThreadTraceExportCommandCreator create_thread_trace_export_command;
1168};
1169
1171
1173 static TraceExporterInstances g_instances;
1174 return g_instances;
1175}
1176
1178 llvm::StringRef name, llvm::StringRef description,
1179 TraceExporterCreateInstance create_callback,
1180 ThreadTraceExportCommandCreator create_thread_trace_export_command) {
1182 name, description, create_callback, create_thread_trace_export_command);
1183}
1184
1187 return GetTraceExporterInstances().GetCallbackForName(plugin_name);
1188}
1189
1191 TraceExporterCreateInstance create_callback) {
1192 return GetTraceExporterInstances().UnregisterPlugin(create_callback);
1193}
1194
1195ThreadTraceExportCommandCreator
1197 if (TraceExporterInstance *instance =
1198 GetTraceExporterInstances().GetInstanceAtIndex(index))
1199 return instance->create_thread_trace_export_command;
1200 return nullptr;
1201}
1202
1203llvm::StringRef
1206}
1207
1208#pragma mark UnwindAssembly
1209
1212
1214 static UnwindAssemblyInstances g_instances;
1215 return g_instances;
1216}
1217
1219 llvm::StringRef name, llvm::StringRef description,
1220 UnwindAssemblyCreateInstance create_callback) {
1221 return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
1222 create_callback);
1223}
1224
1226 UnwindAssemblyCreateInstance create_callback) {
1227 return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
1228}
1229
1230UnwindAssemblyCreateInstance
1233}
1234
1235#pragma mark MemoryHistory
1236
1239
1241 static MemoryHistoryInstances g_instances;
1242 return g_instances;
1243}
1244
1246 llvm::StringRef name, llvm::StringRef description,
1247 MemoryHistoryCreateInstance create_callback) {
1248 return GetMemoryHistoryInstances().RegisterPlugin(name, description,
1249 create_callback);
1250}
1251
1253 MemoryHistoryCreateInstance create_callback) {
1254 return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
1255}
1256
1257MemoryHistoryCreateInstance
1260}
1261
1262#pragma mark InstrumentationRuntime
1263
1265 : public PluginInstance<InstrumentationRuntimeCreateInstance> {
1267 llvm::StringRef name, llvm::StringRef description,
1268 CallbackType create_callback,
1269 InstrumentationRuntimeGetType get_type_callback)
1271 create_callback),
1272 get_type_callback(get_type_callback) {}
1273
1274 InstrumentationRuntimeGetType get_type_callback = nullptr;
1275};
1276
1279
1281 static InstrumentationRuntimeInstances g_instances;
1282 return g_instances;
1283}
1284
1286 llvm::StringRef name, llvm::StringRef description,
1288 InstrumentationRuntimeGetType get_type_callback) {
1290 name, description, create_callback, get_type_callback);
1291}
1292
1294 InstrumentationRuntimeCreateInstance create_callback) {
1295 return GetInstrumentationRuntimeInstances().UnregisterPlugin(create_callback);
1296}
1297
1298InstrumentationRuntimeGetType
1300 const auto &instances = GetInstrumentationRuntimeInstances().GetInstances();
1301 if (idx < instances.size())
1302 return instances[idx].get_type_callback;
1303 return nullptr;
1304}
1305
1309}
1310
1311#pragma mark TypeSystem
1312
1313struct TypeSystemInstance : public PluginInstance<TypeSystemCreateInstance> {
1314 TypeSystemInstance(llvm::StringRef name, llvm::StringRef description,
1315 CallbackType create_callback,
1316 LanguageSet supported_languages_for_types,
1317 LanguageSet supported_languages_for_expressions)
1318 : PluginInstance<TypeSystemCreateInstance>(name, description,
1319 create_callback),
1320 supported_languages_for_types(supported_languages_for_types),
1321 supported_languages_for_expressions(
1322 supported_languages_for_expressions) {}
1323
1326};
1327
1329
1331 static TypeSystemInstances g_instances;
1332 return g_instances;
1333}
1334
1336 llvm::StringRef name, llvm::StringRef description,
1337 TypeSystemCreateInstance create_callback,
1338 LanguageSet supported_languages_for_types,
1339 LanguageSet supported_languages_for_expressions) {
1341 name, description, create_callback, supported_languages_for_types,
1342 supported_languages_for_expressions);
1343}
1344
1346 return GetTypeSystemInstances().UnregisterPlugin(create_callback);
1347}
1348
1352}
1353
1355 const auto &instances = GetTypeSystemInstances().GetInstances();
1356 LanguageSet all;
1357 for (unsigned i = 0; i < instances.size(); ++i)
1358 all.bitvector |= instances[i].supported_languages_for_types.bitvector;
1359 return all;
1360}
1361
1363 const auto &instances = GetTypeSystemInstances().GetInstances();
1364 LanguageSet all;
1365 for (unsigned i = 0; i < instances.size(); ++i)
1366 all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
1367 return all;
1368}
1369
1370#pragma mark REPL
1371
1372struct REPLInstance : public PluginInstance<REPLCreateInstance> {
1373 REPLInstance(llvm::StringRef name, llvm::StringRef description,
1374 CallbackType create_callback, LanguageSet supported_languages)
1375 : PluginInstance<REPLCreateInstance>(name, description, create_callback),
1376 supported_languages(supported_languages) {}
1377
1379};
1380
1382
1384 static REPLInstances g_instances;
1385 return g_instances;
1386}
1387
1388bool PluginManager::RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
1389 REPLCreateInstance create_callback,
1390 LanguageSet supported_languages) {
1391 return GetREPLInstances().RegisterPlugin(name, description, create_callback,
1392 supported_languages);
1393}
1394
1396 return GetREPLInstances().UnregisterPlugin(create_callback);
1397}
1398
1401}
1402
1404 const auto &instances = GetREPLInstances().GetInstances();
1405 return idx < instances.size() ? instances[idx].supported_languages
1406 : LanguageSet();
1407}
1408
1410 const auto &instances = GetREPLInstances().GetInstances();
1411 LanguageSet all;
1412 for (unsigned i = 0; i < instances.size(); ++i)
1413 all.bitvector |= instances[i].supported_languages.bitvector;
1414 return all;
1415}
1416
1417#pragma mark PluginManager
1418
1429}
1430
1431// This is the preferred new way to register plugin specific settings. e.g.
1432// This will put a plugin's settings under e.g.
1433// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
1434static lldb::OptionValuePropertiesSP
1436 llvm::StringRef plugin_type_desc,
1437 bool can_create) {
1438 lldb::OptionValuePropertiesSP parent_properties_sp(
1439 debugger.GetValueProperties());
1440 if (parent_properties_sp) {
1441 static ConstString g_property_name("plugin");
1442
1443 OptionValuePropertiesSP plugin_properties_sp =
1444 parent_properties_sp->GetSubProperty(nullptr, g_property_name);
1445 if (!plugin_properties_sp && can_create) {
1446 plugin_properties_sp =
1447 std::make_shared<OptionValueProperties>(g_property_name);
1448 parent_properties_sp->AppendProperty(g_property_name,
1449 "Settings specify to plugins.", true,
1450 plugin_properties_sp);
1451 }
1452
1453 if (plugin_properties_sp) {
1454 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
1455 plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
1456 if (!plugin_type_properties_sp && can_create) {
1457 plugin_type_properties_sp =
1458 std::make_shared<OptionValueProperties>(plugin_type_name);
1459 plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
1460 true, plugin_type_properties_sp);
1461 }
1462 return plugin_type_properties_sp;
1463 }
1464 }
1465 return lldb::OptionValuePropertiesSP();
1466}
1467
1468// This is deprecated way to register plugin specific settings. e.g.
1469// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
1470// generic settings would be under "platform.SETTINGNAME".
1471static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
1472 Debugger &debugger, ConstString plugin_type_name,
1473 llvm::StringRef plugin_type_desc, bool can_create) {
1474 static ConstString g_property_name("plugin");
1475 lldb::OptionValuePropertiesSP parent_properties_sp(
1476 debugger.GetValueProperties());
1477 if (parent_properties_sp) {
1478 OptionValuePropertiesSP plugin_properties_sp =
1479 parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
1480 if (!plugin_properties_sp && can_create) {
1481 plugin_properties_sp =
1482 std::make_shared<OptionValueProperties>(plugin_type_name);
1483 parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
1484 true, plugin_properties_sp);
1485 }
1486
1487 if (plugin_properties_sp) {
1488 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
1489 plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
1490 if (!plugin_type_properties_sp && can_create) {
1491 plugin_type_properties_sp =
1492 std::make_shared<OptionValueProperties>(g_property_name);
1493 plugin_properties_sp->AppendProperty(g_property_name,
1494 "Settings specific to plugins",
1495 true, plugin_type_properties_sp);
1496 }
1497 return plugin_type_properties_sp;
1498 }
1499 }
1500 return lldb::OptionValuePropertiesSP();
1501}
1502
1503namespace {
1504
1505typedef lldb::OptionValuePropertiesSP
1506GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString, llvm::StringRef,
1507 bool can_create);
1508}
1509
1510static lldb::OptionValuePropertiesSP
1512 ConstString plugin_type_name,
1513 GetDebuggerPropertyForPluginsPtr get_debugger_property =
1515 lldb::OptionValuePropertiesSP properties_sp;
1516 lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property(
1517 debugger, plugin_type_name,
1518 "", // not creating to so we don't need the description
1519 false));
1520 if (plugin_type_properties_sp)
1521 properties_sp =
1522 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
1523 return properties_sp;
1524}
1525
1526static bool
1527CreateSettingForPlugin(Debugger &debugger, ConstString plugin_type_name,
1528 llvm::StringRef plugin_type_desc,
1529 const lldb::OptionValuePropertiesSP &properties_sp,
1530 llvm::StringRef description, bool is_global_property,
1531 GetDebuggerPropertyForPluginsPtr get_debugger_property =
1533 if (properties_sp) {
1534 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
1535 get_debugger_property(debugger, plugin_type_name, plugin_type_desc,
1536 true));
1537 if (plugin_type_properties_sp) {
1538 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
1539 description, is_global_property,
1540 properties_sp);
1541 return true;
1542 }
1543 }
1544 return false;
1545}
1546
1547static const char *kDynamicLoaderPluginName("dynamic-loader");
1548static const char *kPlatformPluginName("platform");
1549static const char *kProcessPluginName("process");
1550static const char *kTracePluginName("trace");
1551static const char *kObjectFilePluginName("object-file");
1552static const char *kSymbolFilePluginName("symbol-file");
1553static const char *kJITLoaderPluginName("jit-loader");
1554static const char *kStructuredDataPluginName("structured-data");
1555
1556lldb::OptionValuePropertiesSP
1558 ConstString setting_name) {
1559 return GetSettingForPlugin(debugger, setting_name,
1561}
1562
1564 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1565 llvm::StringRef description, bool is_global_property) {
1567 "Settings for dynamic loader plug-ins",
1568 properties_sp, description, is_global_property);
1569}
1570
1571lldb::OptionValuePropertiesSP
1573 ConstString setting_name) {
1574 return GetSettingForPlugin(debugger, setting_name,
1577}
1578
1580 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1581 llvm::StringRef description, bool is_global_property) {
1583 "Settings for platform plug-ins", properties_sp,
1584 description, is_global_property,
1586}
1587
1588lldb::OptionValuePropertiesSP
1590 ConstString setting_name) {
1591 return GetSettingForPlugin(debugger, setting_name,
1593}
1594
1596 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1597 llvm::StringRef description, bool is_global_property) {
1599 "Settings for process plug-ins", properties_sp,
1600 description, is_global_property);
1601}
1602
1604 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1605 llvm::StringRef description, bool is_global_property) {
1607 "Settings for trace plug-ins", properties_sp,
1608 description, is_global_property);
1609}
1610
1611lldb::OptionValuePropertiesSP
1613 ConstString setting_name) {
1614 return GetSettingForPlugin(debugger, setting_name,
1616}
1617
1619 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1620 llvm::StringRef description, bool is_global_property) {
1622 "Settings for object file plug-ins",
1623 properties_sp, description, is_global_property);
1624}
1625
1626lldb::OptionValuePropertiesSP
1628 ConstString setting_name) {
1629 return GetSettingForPlugin(debugger, setting_name,
1631}
1632
1634 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1635 llvm::StringRef description, bool is_global_property) {
1637 "Settings for symbol file plug-ins",
1638 properties_sp, description, is_global_property);
1639}
1640
1641lldb::OptionValuePropertiesSP
1643 ConstString setting_name) {
1644 return GetSettingForPlugin(debugger, setting_name,
1646}
1647
1649 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1650 llvm::StringRef description, bool is_global_property) {
1652 "Settings for JIT loader plug-ins",
1653 properties_sp, description, is_global_property);
1654}
1655
1656static const char *kOperatingSystemPluginName("os");
1657
1658lldb::OptionValuePropertiesSP
1660 ConstString setting_name) {
1661 lldb::OptionValuePropertiesSP properties_sp;
1662 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
1665 "", // not creating to so we don't need the description
1666 false));
1667 if (plugin_type_properties_sp)
1668 properties_sp =
1669 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
1670 return properties_sp;
1671}
1672
1674 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1675 llvm::StringRef description, bool is_global_property) {
1676 if (properties_sp) {
1677 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
1680 "Settings for operating system plug-ins", true));
1681 if (plugin_type_properties_sp) {
1682 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
1683 description, is_global_property,
1684 properties_sp);
1685 return true;
1686 }
1687 }
1688 return false;
1689}
1690
1691lldb::OptionValuePropertiesSP
1693 ConstString setting_name) {
1694 return GetSettingForPlugin(debugger, setting_name,
1696}
1697
1699 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
1700 llvm::StringRef description, bool is_global_property) {
1701 return CreateSettingForPlugin(debugger,
1703 "Settings for structured data plug-ins",
1704 properties_sp, description, is_global_property);
1705}
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:625
static DisassemblerInstances & GetDisassemblerInstances()
static TraceInstances & GetTracePluginInstances()
static ObjectContainerInstances & GetObjectContainerInstances()
PluginInstances< JITLoaderInstance > JITLoaderInstances
static MemoryHistoryInstances & GetMemoryHistoryInstances()
PluginInstance< PlatformCreateInstance > PlatformInstance
PluginInstances< InstrumentationRuntimeInstance > InstrumentationRuntimeInstances
static DynamicLoaderInstances & GetDynamicLoaderInstances()
PluginInstances< SymbolFileInstance > SymbolFileInstances
std::map< FileSpec, PluginInfo > PluginTerminateMap
PluginInstances< TypeSystemInstance > TypeSystemInstances
PluginInstance< ABICreateInstance > ABIInstance
static SystemRuntimeInstances & GetSystemRuntimeInstances()
PluginInstances< TraceExporterInstance > TraceExporterInstances
PluginInstance< EmulateInstructionCreateInstance > EmulateInstructionInstance
static ABIInstances & GetABIInstances()
PluginInstances< SymbolVendorInstance > SymbolVendorInstances
static ScriptInterpreterInstances & GetScriptInterpreterInstances()
static const char * kPlatformPluginName("platform")
PluginInstance< DynamicLoaderCreateInstance > DynamicLoaderInstance
PluginInstances< PlatformInstance > PlatformInstances
PluginInstance< JITLoaderCreateInstance > JITLoaderInstance
PluginInstance< ArchitectureCreateInstance > ArchitectureInstance
PluginInstances< SystemRuntimeInstance > SystemRuntimeInstances
static const char * kDynamicLoaderPluginName("dynamic-loader")
static TraceExporterInstances & GetTraceExporterInstances()
static void SetPluginInfo(const FileSpec &plugin_file_spec, const PluginInfo &plugin_info)
static PluginTerminateMap & GetPluginMap()
static const char * kJITLoaderPluginName("jit-loader")
PluginInstance< LanguageCreateInstance > LanguageInstance
PluginInstance< SymbolFileCreateInstance > SymbolFileInstance
PluginInstances< ObjectFileInstance > ObjectFileInstances
void(* PluginTermCallback)()
static StructuredDataPluginInstances & GetStructuredDataPluginInstances()
PluginInstances< MemoryHistoryInstance > MemoryHistoryInstances
PluginInstances< DynamicLoaderInstance > DynamicLoaderInstances
PluginInstances< LanguageInstance > LanguageInstances
PluginInstances< TraceInstance > TraceInstances
PluginInstances< StructuredDataPluginInstance > StructuredDataPluginInstances
PluginInstance< MemoryHistoryCreateInstance > MemoryHistoryInstance
static const char * kOperatingSystemPluginName("os")
PluginInstance< OperatingSystemCreateInstance > OperatingSystemInstance
static ObjectFileInstances & GetObjectFileInstances()
PluginInstance< SystemRuntimeCreateInstance > SystemRuntimeInstance
PluginInstance< SymbolVendorCreateInstance > SymbolVendorInstance
static EmulateInstructionInstances & GetEmulateInstructionInstances()
PluginInstance< UnwindAssemblyCreateInstance > UnwindAssemblyInstance
static LanguageInstances & GetLanguageInstances()
static const char * kObjectFilePluginName("object-file")
PluginInstances< OperatingSystemInstance > OperatingSystemInstances
static LanguageRuntimeInstances & GetLanguageRuntimeInstances()
PluginInstances< LanguageRuntimeInstance > LanguageRuntimeInstances
static InstrumentationRuntimeInstances & GetInstrumentationRuntimeInstances()
PluginInstances< ProcessInstance > ProcessInstances
PluginInstances< REPLInstance > REPLInstances
std::vector< ArchitectureInstance > ArchitectureInstances
static ArchitectureInstances & GetArchitectureInstances()
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(Debugger &debugger, ConstString plugin_type_name, llvm::StringRef plugin_type_desc, bool can_create)
static lldb::OptionValuePropertiesSP GetSettingForPlugin(Debugger &debugger, ConstString setting_name, ConstString plugin_type_name, GetDebuggerPropertyForPluginsPtr get_debugger_property=GetDebuggerPropertyForPlugins)
static RegisterTypeBuilderInstances & GetRegisterTypeBuilderInstances()
static std::recursive_mutex & GetPluginMapMutex()
static const char * kProcessPluginName("process")
static TypeSystemInstances & GetTypeSystemInstances()
static PlatformInstances & GetPlatformInstances()
static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path)
static const char * kTracePluginName("trace")
PluginInstances< EmulateInstructionInstance > EmulateInstructionInstances
static JITLoaderInstances & GetJITLoaderInstances()
static bool CreateSettingForPlugin(Debugger &debugger, ConstString 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< DisassemblerInstance > DisassemblerInstances
PluginInstance< ProcessCreateInstance > ProcessInstance
static UnwindAssemblyInstances & GetUnwindAssemblyInstances()
PluginInstances< UnwindAssemblyInstance > UnwindAssemblyInstances
static SymbolFileInstances & GetSymbolFileInstances()
PluginInstances< ABIInstance > ABIInstances
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(Debugger &debugger, ConstString plugin_type_name, llvm::StringRef plugin_type_desc, bool can_create)
static FPtrTy CastToFPtr(void *VPtr)
static ProcessInstances & GetProcessInstances()
static bool PluginIsLoaded(const FileSpec &plugin_file_spec)
static OperatingSystemInstances & GetOperatingSystemInstances()
PluginInstances< ScriptInterpreterInstance > ScriptInterpreterInstances
bool(* PluginInitCallback)()
PluginInstance< DisassemblerCreateInstance > DisassemblerInstance
static const char * kSymbolFilePluginName("symbol-file")
static SymbolVendorInstances & GetSymbolVendorInstances()
PluginInstances< ObjectContainerInstance > ObjectContainerInstances
static const char * kStructuredDataPluginName("structured-data")
PluginInstances< RegisterTypeBuilderInstance > RegisterTypeBuilderInstances
static REPLInstances & GetREPLInstances()
bool UnregisterPlugin(typename Instance::CallbackType callback)
llvm::StringRef GetNameAtIndex(uint32_t idx)
Instance::CallbackType GetCallbackAtIndex(uint32_t idx)
llvm::StringRef GetDescriptionAtIndex(uint32_t idx)
Instance * GetInstanceAtIndex(uint32_t idx)
Instance::CallbackType GetCallbackForName(llvm::StringRef name)
bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, typename Instance::CallbackType callback, Args &&...args)
std::vector< Instance > m_instances
const std::vector< Instance > & GetInstances() const
void PerformDebuggerCallback(Debugger &debugger)
std::vector< Instance > & GetInstances()
An architecture specification class.
Definition: ArchSpec.h:31
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 uniqued constant string class.
Definition: ConstString.h:40
A class to manage flag bits.
Definition: Debugger.h:78
A file utility class.
Definition: FileSpec.h:56
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:366
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
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:171
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
Definition: FileSystem.h:168
static FileSystem & Instance()
static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx)
static lldb::OptionValuePropertiesSP GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name)
static llvm::StringRef GetTraceExporterPluginNameAtIndex(uint32_t index)
static bool CreateSettingForJITLoaderPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static lldb::OptionValuePropertiesSP GetSettingForObjectFilePlugin(Debugger &debugger, ConstString setting_name)
static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx)
static JITLoaderCreateInstance GetJITLoaderCreateCallbackAtIndex(uint32_t idx)
static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx)
static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions()
static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static void AutoCompletePlatformName(llvm::StringRef partial_name, CompletionRequest &request)
static TraceExporterCreateInstance GetTraceExporterCreateCallback(llvm::StringRef plugin_name)
static bool CreateSettingForObjectFilePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static lldb::ScriptInterpreterSP GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, Debugger &debugger)
static void AutoCompleteProcessName(llvm::StringRef partial_name, CompletionRequest &request)
static ThreadTraceExportCommandCreator GetThreadTraceExportCommandCreatorAtIndex(uint32_t index)
Return the callback used to create the CommandObject that will be listed under "thread trace export".
static LanguageSet GetREPLAllTypeSystemSupportedLanguages()
static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx)
static bool CreateSettingForTracePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static UnwindAssemblyCreateInstance GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx)
static SymbolFileCreateInstance GetSymbolFileCreateCallbackAtIndex(uint32_t idx)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static TypeSystemCreateInstance GetTypeSystemCreateCallbackAtIndex(uint32_t idx)
static InstrumentationRuntimeGetType GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx)
static llvm::StringRef GetTraceSchema(llvm::StringRef plugin_name)
Get the JSON schema for a trace bundle description file corresponding to the given plugin.
static TraceCreateInstanceForLiveProcess GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name)
static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin(Debugger &debugger, ConstString setting_name)
static LanguageRuntimeCreateInstance GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx)
static std::unique_ptr< Architecture > CreateArchitectureInstance(const ArchSpec &arch)
static SystemRuntimeCreateInstance GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx)
static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger, ConstString setting_name)
static bool CreateSettingForProcessPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, ConstString setting_name)
static SymbolVendorCreateInstance GetSymbolVendorCreateCallbackAtIndex(uint32_t idx)
static LanguageRuntimeGetCommandObject GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx)
static OperatingSystemCreateInstance GetOperatingSystemCreateCallbackAtIndex(uint32_t idx)
static LanguageRuntimeGetExceptionPrecondition GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx)
static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx)
static ObjectFileCreateMemoryInstance GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx)
static lldb::OptionValuePropertiesSP GetSettingForSymbolFilePlugin(Debugger &debugger, ConstString setting_name)
static DisassemblerCreateInstance GetDisassemblerCreateCallbackForPluginName(llvm::StringRef name)
static MemoryHistoryCreateInstance GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx)
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 DisassemblerCreateInstance GetDisassemblerCreateCallbackAtIndex(uint32_t idx)
static ObjectContainerCreateInstance GetObjectContainerCreateCallbackAtIndex(uint32_t idx)
static ObjectFileCreateInstance GetObjectFileCreateCallbackAtIndex(uint32_t idx)
static EmulateInstructionCreateInstance GetEmulateInstructionCreateCallbackForPluginName(llvm::StringRef name)
static bool CreateSettingForStructuredDataPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static DynamicLoaderCreateInstance GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx)
static lldb::OptionValuePropertiesSP GetSettingForDynamicLoaderPlugin(Debugger &debugger, ConstString setting_name)
static ObjectFileGetModuleSpecifications GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx)
static DynamicLoaderCreateInstance GetDynamicLoaderCreateCallbackForPluginName(llvm::StringRef name)
static PlatformCreateInstance GetPlatformCreateCallbackForPluginName(llvm::StringRef name)
static ScriptInterpreterCreateInstance GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx)
static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx)
static Status SaveCore(const lldb::ProcessSP &process_sp, const FileSpec &outfile, lldb::SaveCoreStyle &core_style, llvm::StringRef plugin_name)
static ProcessCreateInstance GetProcessCreateCallbackForPluginName(llvm::StringRef name)
static lldb::OptionValuePropertiesSP GetSettingForStructuredDataPlugin(Debugger &debugger, ConstString setting_name)
static llvm::StringRef GetProcessPluginDescriptionAtIndex(uint32_t idx)
static bool CreateSettingForDynamicLoaderPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static StructuredDataPluginCreateInstance GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx)
static ObjectFileGetModuleSpecifications GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx)
static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx)
static TraceCreateInstanceFromBundle GetTraceCreateCallback(llvm::StringRef plugin_name)
static void DebuggerInitialize(Debugger &debugger)
static llvm::StringRef GetProcessPluginNameAtIndex(uint32_t idx)
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes()
static bool UnregisterPlugin(ABICreateInstance create_callback)
static ObjectContainerCreateMemoryInstance GetObjectContainerCreateMemoryCallbackAtIndex(uint32_t idx)
static StructuredDataFilterLaunchInfo GetStructuredDataFilterCallbackAtIndex(uint32_t idx, bool &iteration_complete)
static InstrumentationRuntimeCreateInstance GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx)
static LanguageSet GetREPLSupportedLanguagesAtIndex(uint32_t idx)
static lldb::RegisterTypeBuilderSP GetRegisterTypeBuilder(Target &target)
static ObjectFileCreateMemoryInstance GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name)
static EmulateInstructionCreateInstance GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx)
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
An error handling class.
Definition: Status.h:44
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
ScriptLanguage
Script interpreter types.
@ eScriptLanguageNone
InstrumentationRuntimeInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, InstrumentationRuntimeGetType get_type_callback)
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
PluginTermCallback plugin_term_callback
PluginInfo()=default
llvm::sys::DynamicLibrary library
PluginInitCallback plugin_init_callback
llvm::StringRef name
llvm::StringRef description
Callback CallbackType
DebuggerInitializeCallback debugger_init_callback
Callback create_callback
PluginInstance()=default
PluginInstance(llvm::StringRef name, llvm::StringRef description, Callback create_callback, DebuggerInitializeCallback debugger_init_callback=nullptr)
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)
StructuredDataPluginInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, DebuggerInitializeCallback debugger_init_callback, StructuredDataFilterLaunchInfo filter_callback)
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
LanguageSet supported_languages_for_types
TypeSystemInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, LanguageSet supported_languages_for_types, LanguageSet supported_languages_for_expressions)
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:45
llvm::SmallBitVector bitvector
Definition: TypeSystem.h:46
#define PATH_MAX