1 //===-- PluginManager.cpp ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/PluginManager.h"
19 // Other libraries and framework includes
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/DynamicLibrary.h"
24 #include "lldb/Core/Debugger.h"
25 #include "lldb/Core/Error.h"
26 #include "lldb/Host/FileSpec.h"
27 #include "lldb/Host/Host.h"
28 #include "lldb/Host/HostInfo.h"
29 #include "lldb/Interpreter/OptionValueProperties.h"
32 using namespace lldb_private;
36 ePluginRegisterInstance,
37 ePluginUnregisterInstance,
38 ePluginGetInstanceAtIndex
41 typedef bool (*PluginInitCallback)();
42 typedef void (*PluginTermCallback)();
47 : plugin_init_callback(nullptr), plugin_term_callback(nullptr)
51 llvm::sys::DynamicLibrary library;
52 PluginInitCallback plugin_init_callback;
53 PluginTermCallback plugin_term_callback;
56 typedef std::map<FileSpec, PluginInfo> PluginTerminateMap;
58 static std::recursive_mutex &
61 static std::recursive_mutex g_plugin_map_mutex;
62 return g_plugin_map_mutex;
65 static PluginTerminateMap &
68 static PluginTerminateMap g_plugin_map;
73 PluginIsLoaded (const FileSpec &plugin_file_spec)
75 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
76 PluginTerminateMap &plugin_map = GetPluginMap ();
77 return plugin_map.find (plugin_file_spec) != plugin_map.end();
81 SetPluginInfo (const FileSpec &plugin_file_spec, const PluginInfo &plugin_info)
83 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
84 PluginTerminateMap &plugin_map = GetPluginMap ();
85 assert (plugin_map.find (plugin_file_spec) == plugin_map.end());
86 plugin_map[plugin_file_spec] = plugin_info;
89 template <typename FPtrTy>
91 CastToFPtr (void *VPtr)
93 return reinterpret_cast<FPtrTy>(reinterpret_cast<intptr_t>(VPtr));
96 static FileSpec::EnumerateDirectoryResult
97 LoadPluginCallback(void *baton,
98 FileSpec::FileType file_type,
99 const FileSpec &file_spec)
101 // PluginManager *plugin_manager = (PluginManager *)baton;
104 // If we have a regular file, a symbolic link or unknown file type, try
105 // and process the file. We must handle unknown as sometimes the directory
106 // enumeration might be enumerating a file system that doesn't have correct
107 // file type information.
108 if (file_type == FileSpec::eFileTypeRegular ||
109 file_type == FileSpec::eFileTypeSymbolicLink ||
110 file_type == FileSpec::eFileTypeUnknown )
112 FileSpec plugin_file_spec (file_spec);
113 plugin_file_spec.ResolvePath();
115 if (PluginIsLoaded (plugin_file_spec))
116 return FileSpec::eEnumerateDirectoryResultNext;
119 PluginInfo plugin_info;
121 std::string pluginLoadError;
122 plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary (plugin_file_spec.GetPath().c_str(), &pluginLoadError);
123 if (plugin_info.library.isValid())
125 bool success = false;
126 plugin_info.plugin_init_callback =
127 CastToFPtr<PluginInitCallback>(plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"));
128 if (plugin_info.plugin_init_callback)
130 // Call the plug-in "bool LLDBPluginInitialize(void)" function
131 success = plugin_info.plugin_init_callback();
136 // It is ok for the "LLDBPluginTerminate" symbol to be nullptr
137 plugin_info.plugin_term_callback =
138 CastToFPtr<PluginTermCallback>(plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
142 // The initialize function returned FALSE which means the plug-in might not be
143 // compatible, or might be too new or too old, or might not want to run on this
144 // machine. Set it to a default-constructed instance to invalidate it.
145 plugin_info = PluginInfo();
148 // Regardless of success or failure, cache the plug-in load
149 // in our plug-in info so we don't try to load it again and
151 SetPluginInfo (plugin_file_spec, plugin_info);
153 return FileSpec::eEnumerateDirectoryResultNext;
158 if (file_type == FileSpec::eFileTypeUnknown ||
159 file_type == FileSpec::eFileTypeDirectory ||
160 file_type == FileSpec::eFileTypeSymbolicLink )
162 // Try and recurse into anything that a directory or symbolic link.
163 // We must also do this for unknown as sometimes the directory enumeration
164 // might be enumerating a file system that doesn't have correct file type
166 return FileSpec::eEnumerateDirectoryResultEnter;
169 return FileSpec::eEnumerateDirectoryResultNext;
173 PluginManager::Initialize ()
177 const bool find_directories = true;
178 const bool find_files = true;
179 const bool find_other = true;
180 char dir_path[PATH_MAX];
181 if (HostInfo::GetLLDBPath(ePathTypeLLDBSystemPlugins, dir_spec))
183 if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path)))
185 FileSpec::EnumerateDirectory(dir_path,
194 if (HostInfo::GetLLDBPath(ePathTypeLLDBUserPlugins, dir_spec))
196 if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path)))
198 FileSpec::EnumerateDirectory(dir_path,
210 PluginManager::Terminate ()
212 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
213 PluginTerminateMap &plugin_map = GetPluginMap ();
215 PluginTerminateMap::const_iterator pos, end = plugin_map.end();
216 for (pos = plugin_map.begin(); pos != end; ++pos)
218 // Call the plug-in "void LLDBPluginTerminate (void)" function if there
219 // is one (if the symbol was not nullptr).
220 if (pos->second.library.isValid())
222 if (pos->second.plugin_term_callback)
223 pos->second.plugin_term_callback();
236 create_callback(nullptr)
241 std::string description;
242 ABICreateInstance create_callback;
245 typedef std::vector<ABIInstance> ABIInstances;
247 static std::recursive_mutex &
248 GetABIInstancesMutex()
250 static std::recursive_mutex g_instances_mutex;
251 return g_instances_mutex;
254 static ABIInstances &
257 static ABIInstances g_instances;
262 PluginManager::RegisterPlugin(const ConstString &name,
263 const char *description,
264 ABICreateInstance create_callback)
268 ABIInstance instance;
270 instance.name = name;
271 if (description && description[0])
272 instance.description = description;
273 instance.create_callback = create_callback;
274 std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
275 GetABIInstances ().push_back (instance);
282 PluginManager::UnregisterPlugin (ABICreateInstance create_callback)
286 std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
287 ABIInstances &instances = GetABIInstances ();
289 ABIInstances::iterator pos, end = instances.end();
290 for (pos = instances.begin(); pos != end; ++ pos)
292 if (pos->create_callback == create_callback)
294 instances.erase(pos);
303 PluginManager::GetABICreateCallbackAtIndex (uint32_t idx)
305 std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
306 ABIInstances &instances = GetABIInstances ();
307 if (idx < instances.size())
308 return instances[idx].create_callback;
313 PluginManager::GetABICreateCallbackForPluginName (const ConstString &name)
317 std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
318 ABIInstances &instances = GetABIInstances ();
320 ABIInstances::iterator pos, end = instances.end();
321 for (pos = instances.begin(); pos != end; ++ pos)
323 if (name == pos->name)
324 return pos->create_callback;
330 #pragma mark Disassembler
332 struct DisassemblerInstance
334 DisassemblerInstance() :
337 create_callback(nullptr)
342 std::string description;
343 DisassemblerCreateInstance create_callback;
346 typedef std::vector<DisassemblerInstance> DisassemblerInstances;
348 static std::recursive_mutex &
349 GetDisassemblerMutex()
351 static std::recursive_mutex g_instances_mutex;
352 return g_instances_mutex;
355 static DisassemblerInstances &
356 GetDisassemblerInstances ()
358 static DisassemblerInstances g_instances;
363 PluginManager::RegisterPlugin(const ConstString &name,
364 const char *description,
365 DisassemblerCreateInstance create_callback)
369 DisassemblerInstance instance;
371 instance.name = name;
372 if (description && description[0])
373 instance.description = description;
374 instance.create_callback = create_callback;
375 std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
376 GetDisassemblerInstances ().push_back (instance);
383 PluginManager::UnregisterPlugin (DisassemblerCreateInstance create_callback)
387 std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
388 DisassemblerInstances &instances = GetDisassemblerInstances ();
390 DisassemblerInstances::iterator pos, end = instances.end();
391 for (pos = instances.begin(); pos != end; ++ pos)
393 if (pos->create_callback == create_callback)
395 instances.erase(pos);
403 DisassemblerCreateInstance
404 PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx)
406 std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
407 DisassemblerInstances &instances = GetDisassemblerInstances ();
408 if (idx < instances.size())
409 return instances[idx].create_callback;
413 DisassemblerCreateInstance
414 PluginManager::GetDisassemblerCreateCallbackForPluginName (const ConstString &name)
418 std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
419 DisassemblerInstances &instances = GetDisassemblerInstances ();
421 DisassemblerInstances::iterator pos, end = instances.end();
422 for (pos = instances.begin(); pos != end; ++ pos)
424 if (name == pos->name)
425 return pos->create_callback;
431 #pragma mark DynamicLoader
433 struct DynamicLoaderInstance
435 DynamicLoaderInstance() :
438 create_callback(nullptr),
439 debugger_init_callback(nullptr)
444 std::string description;
445 DynamicLoaderCreateInstance create_callback;
446 DebuggerInitializeCallback debugger_init_callback;
449 typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances;
451 static std::recursive_mutex &
452 GetDynamicLoaderMutex()
454 static std::recursive_mutex g_instances_mutex;
455 return g_instances_mutex;
458 static DynamicLoaderInstances &
459 GetDynamicLoaderInstances ()
461 static DynamicLoaderInstances g_instances;
466 PluginManager::RegisterPlugin(const ConstString &name,
467 const char *description,
468 DynamicLoaderCreateInstance create_callback,
469 DebuggerInitializeCallback debugger_init_callback)
473 DynamicLoaderInstance instance;
475 instance.name = name;
476 if (description && description[0])
477 instance.description = description;
478 instance.create_callback = create_callback;
479 instance.debugger_init_callback = debugger_init_callback;
480 std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
481 GetDynamicLoaderInstances ().push_back (instance);
487 PluginManager::UnregisterPlugin (DynamicLoaderCreateInstance create_callback)
491 std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
492 DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
494 DynamicLoaderInstances::iterator pos, end = instances.end();
495 for (pos = instances.begin(); pos != end; ++ pos)
497 if (pos->create_callback == create_callback)
499 instances.erase(pos);
507 DynamicLoaderCreateInstance
508 PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx)
510 std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
511 DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
512 if (idx < instances.size())
513 return instances[idx].create_callback;
517 DynamicLoaderCreateInstance
518 PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name)
522 std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
523 DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
525 DynamicLoaderInstances::iterator pos, end = instances.end();
526 for (pos = instances.begin(); pos != end; ++ pos)
528 if (name == pos->name)
529 return pos->create_callback;
535 #pragma mark JITLoader
537 struct JITLoaderInstance
539 JITLoaderInstance() :
542 create_callback(nullptr),
543 debugger_init_callback(nullptr)
548 std::string description;
549 JITLoaderCreateInstance create_callback;
550 DebuggerInitializeCallback debugger_init_callback;
553 typedef std::vector<JITLoaderInstance> JITLoaderInstances;
555 static std::recursive_mutex &
558 static std::recursive_mutex g_instances_mutex;
559 return g_instances_mutex;
562 static JITLoaderInstances &
563 GetJITLoaderInstances ()
565 static JITLoaderInstances g_instances;
570 PluginManager::RegisterPlugin(const ConstString &name,
571 const char *description,
572 JITLoaderCreateInstance create_callback,
573 DebuggerInitializeCallback debugger_init_callback)
577 JITLoaderInstance instance;
579 instance.name = name;
580 if (description && description[0])
581 instance.description = description;
582 instance.create_callback = create_callback;
583 instance.debugger_init_callback = debugger_init_callback;
584 std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
585 GetJITLoaderInstances ().push_back (instance);
591 PluginManager::UnregisterPlugin (JITLoaderCreateInstance create_callback)
595 std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
596 JITLoaderInstances &instances = GetJITLoaderInstances ();
598 JITLoaderInstances::iterator pos, end = instances.end();
599 for (pos = instances.begin(); pos != end; ++ pos)
601 if (pos->create_callback == create_callback)
603 instances.erase(pos);
611 JITLoaderCreateInstance
612 PluginManager::GetJITLoaderCreateCallbackAtIndex (uint32_t idx)
614 std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
615 JITLoaderInstances &instances = GetJITLoaderInstances ();
616 if (idx < instances.size())
617 return instances[idx].create_callback;
621 JITLoaderCreateInstance
622 PluginManager::GetJITLoaderCreateCallbackForPluginName (const ConstString &name)
626 std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
627 JITLoaderInstances &instances = GetJITLoaderInstances ();
629 JITLoaderInstances::iterator pos, end = instances.end();
630 for (pos = instances.begin(); pos != end; ++ pos)
632 if (name == pos->name)
633 return pos->create_callback;
639 #pragma mark EmulateInstruction
641 struct EmulateInstructionInstance
643 EmulateInstructionInstance() :
646 create_callback(nullptr)
651 std::string description;
652 EmulateInstructionCreateInstance create_callback;
655 typedef std::vector<EmulateInstructionInstance> EmulateInstructionInstances;
657 static std::recursive_mutex &
658 GetEmulateInstructionMutex()
660 static std::recursive_mutex g_instances_mutex;
661 return g_instances_mutex;
664 static EmulateInstructionInstances &
665 GetEmulateInstructionInstances ()
667 static EmulateInstructionInstances g_instances;
672 PluginManager::RegisterPlugin(const ConstString &name,
673 const char *description,
674 EmulateInstructionCreateInstance create_callback)
678 EmulateInstructionInstance instance;
680 instance.name = name;
681 if (description && description[0])
682 instance.description = description;
683 instance.create_callback = create_callback;
684 std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
685 GetEmulateInstructionInstances ().push_back (instance);
691 PluginManager::UnregisterPlugin (EmulateInstructionCreateInstance create_callback)
695 std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
696 EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
698 EmulateInstructionInstances::iterator pos, end = instances.end();
699 for (pos = instances.begin(); pos != end; ++ pos)
701 if (pos->create_callback == create_callback)
703 instances.erase(pos);
711 EmulateInstructionCreateInstance
712 PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx)
714 std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
715 EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
716 if (idx < instances.size())
717 return instances[idx].create_callback;
721 EmulateInstructionCreateInstance
722 PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name)
726 std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
727 EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
729 EmulateInstructionInstances::iterator pos, end = instances.end();
730 for (pos = instances.begin(); pos != end; ++ pos)
732 if (name == pos->name)
733 return pos->create_callback;
739 #pragma mark OperatingSystem
741 struct OperatingSystemInstance
743 OperatingSystemInstance () :
746 create_callback (nullptr),
747 debugger_init_callback (nullptr)
752 std::string description;
753 OperatingSystemCreateInstance create_callback;
754 DebuggerInitializeCallback debugger_init_callback;
757 typedef std::vector<OperatingSystemInstance> OperatingSystemInstances;
759 static std::recursive_mutex &
760 GetOperatingSystemMutex()
762 static std::recursive_mutex g_instances_mutex;
763 return g_instances_mutex;
766 static OperatingSystemInstances &
767 GetOperatingSystemInstances ()
769 static OperatingSystemInstances g_instances;
774 PluginManager::RegisterPlugin(const ConstString &name, const char *description,
775 OperatingSystemCreateInstance create_callback,
776 DebuggerInitializeCallback debugger_init_callback)
780 OperatingSystemInstance instance;
782 instance.name = name;
783 if (description && description[0])
784 instance.description = description;
785 instance.create_callback = create_callback;
786 instance.debugger_init_callback = debugger_init_callback;
787 std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
788 GetOperatingSystemInstances ().push_back (instance);
794 PluginManager::UnregisterPlugin (OperatingSystemCreateInstance create_callback)
798 std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
799 OperatingSystemInstances &instances = GetOperatingSystemInstances ();
801 OperatingSystemInstances::iterator pos, end = instances.end();
802 for (pos = instances.begin(); pos != end; ++ pos)
804 if (pos->create_callback == create_callback)
806 instances.erase(pos);
814 OperatingSystemCreateInstance
815 PluginManager::GetOperatingSystemCreateCallbackAtIndex (uint32_t idx)
817 std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
818 OperatingSystemInstances &instances = GetOperatingSystemInstances ();
819 if (idx < instances.size())
820 return instances[idx].create_callback;
824 OperatingSystemCreateInstance
825 PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString &name)
829 std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
830 OperatingSystemInstances &instances = GetOperatingSystemInstances ();
832 OperatingSystemInstances::iterator pos, end = instances.end();
833 for (pos = instances.begin(); pos != end; ++ pos)
835 if (name == pos->name)
836 return pos->create_callback;
842 #pragma mark Language
844 struct LanguageInstance
849 create_callback(nullptr)
854 std::string description;
855 LanguageCreateInstance create_callback;
858 typedef std::vector<LanguageInstance> LanguageInstances;
860 static std::recursive_mutex &
863 static std::recursive_mutex g_instances_mutex;
864 return g_instances_mutex;
867 static LanguageInstances &
868 GetLanguageInstances ()
870 static LanguageInstances g_instances;
875 PluginManager::RegisterPlugin(const ConstString &name,
876 const char *description,
877 LanguageCreateInstance create_callback)
881 LanguageInstance instance;
883 instance.name = name;
884 if (description && description[0])
885 instance.description = description;
886 instance.create_callback = create_callback;
887 std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
888 GetLanguageInstances ().push_back (instance);
894 PluginManager::UnregisterPlugin (LanguageCreateInstance create_callback)
898 std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
899 LanguageInstances &instances = GetLanguageInstances ();
901 LanguageInstances::iterator pos, end = instances.end();
902 for (pos = instances.begin(); pos != end; ++ pos)
904 if (pos->create_callback == create_callback)
906 instances.erase(pos);
914 LanguageCreateInstance
915 PluginManager::GetLanguageCreateCallbackAtIndex (uint32_t idx)
917 std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
918 LanguageInstances &instances = GetLanguageInstances ();
919 if (idx < instances.size())
920 return instances[idx].create_callback;
924 LanguageCreateInstance
925 PluginManager::GetLanguageCreateCallbackForPluginName (const ConstString &name)
929 std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
930 LanguageInstances &instances = GetLanguageInstances ();
932 LanguageInstances::iterator pos, end = instances.end();
933 for (pos = instances.begin(); pos != end; ++ pos)
935 if (name == pos->name)
936 return pos->create_callback;
942 #pragma mark LanguageRuntime
944 struct LanguageRuntimeInstance
946 LanguageRuntimeInstance() :
949 create_callback(nullptr)
954 std::string description;
955 LanguageRuntimeCreateInstance create_callback;
956 LanguageRuntimeGetCommandObject command_callback;
959 typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
961 static std::recursive_mutex &
962 GetLanguageRuntimeMutex()
964 static std::recursive_mutex g_instances_mutex;
965 return g_instances_mutex;
968 static LanguageRuntimeInstances &
969 GetLanguageRuntimeInstances ()
971 static LanguageRuntimeInstances g_instances;
976 PluginManager::RegisterPlugin(const ConstString &name,
977 const char *description,
978 LanguageRuntimeCreateInstance create_callback,
979 LanguageRuntimeGetCommandObject command_callback)
983 LanguageRuntimeInstance instance;
985 instance.name = name;
986 if (description && description[0])
987 instance.description = description;
988 instance.create_callback = create_callback;
989 instance.command_callback = command_callback;
990 std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
991 GetLanguageRuntimeInstances ().push_back (instance);
997 PluginManager::UnregisterPlugin (LanguageRuntimeCreateInstance create_callback)
1001 std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
1002 LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
1004 LanguageRuntimeInstances::iterator pos, end = instances.end();
1005 for (pos = instances.begin(); pos != end; ++ pos)
1007 if (pos->create_callback == create_callback)
1009 instances.erase(pos);
1017 LanguageRuntimeCreateInstance
1018 PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx)
1020 std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
1021 LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
1022 if (idx < instances.size())
1023 return instances[idx].create_callback;
1027 LanguageRuntimeGetCommandObject
1028 PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex (uint32_t idx)
1030 std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
1031 LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
1032 if (idx < instances.size())
1033 return instances[idx].command_callback;
1037 LanguageRuntimeCreateInstance
1038 PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
1042 std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
1043 LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
1045 LanguageRuntimeInstances::iterator pos, end = instances.end();
1046 for (pos = instances.begin(); pos != end; ++ pos)
1048 if (name == pos->name)
1049 return pos->create_callback;
1055 #pragma mark SystemRuntime
1057 struct SystemRuntimeInstance
1059 SystemRuntimeInstance() :
1062 create_callback(nullptr)
1067 std::string description;
1068 SystemRuntimeCreateInstance create_callback;
1071 typedef std::vector<SystemRuntimeInstance> SystemRuntimeInstances;
1073 static std::recursive_mutex &
1074 GetSystemRuntimeMutex()
1076 static std::recursive_mutex g_instances_mutex;
1077 return g_instances_mutex;
1080 static SystemRuntimeInstances &
1081 GetSystemRuntimeInstances ()
1083 static SystemRuntimeInstances g_instances;
1088 PluginManager::RegisterPlugin(const ConstString &name,
1089 const char *description,
1090 SystemRuntimeCreateInstance create_callback)
1092 if (create_callback)
1094 SystemRuntimeInstance instance;
1095 assert ((bool)name);
1096 instance.name = name;
1097 if (description && description[0])
1098 instance.description = description;
1099 instance.create_callback = create_callback;
1100 std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
1101 GetSystemRuntimeInstances ().push_back (instance);
1107 PluginManager::UnregisterPlugin (SystemRuntimeCreateInstance create_callback)
1109 if (create_callback)
1111 std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
1112 SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
1114 SystemRuntimeInstances::iterator pos, end = instances.end();
1115 for (pos = instances.begin(); pos != end; ++ pos)
1117 if (pos->create_callback == create_callback)
1119 instances.erase(pos);
1127 SystemRuntimeCreateInstance
1128 PluginManager::GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx)
1130 std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
1131 SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
1132 if (idx < instances.size())
1133 return instances[idx].create_callback;
1137 SystemRuntimeCreateInstance
1138 PluginManager::GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name)
1142 std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
1143 SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
1145 SystemRuntimeInstances::iterator pos, end = instances.end();
1146 for (pos = instances.begin(); pos != end; ++ pos)
1148 if (name == pos->name)
1149 return pos->create_callback;
1155 #pragma mark ObjectFile
1157 struct ObjectFileInstance
1159 ObjectFileInstance() :
1162 create_callback(nullptr),
1163 create_memory_callback(nullptr),
1164 get_module_specifications(nullptr),
1170 std::string description;
1171 ObjectFileCreateInstance create_callback;
1172 ObjectFileCreateMemoryInstance create_memory_callback;
1173 ObjectFileGetModuleSpecifications get_module_specifications;
1174 ObjectFileSaveCore save_core;
1177 typedef std::vector<ObjectFileInstance> ObjectFileInstances;
1179 static std::recursive_mutex &
1180 GetObjectFileMutex()
1182 static std::recursive_mutex g_instances_mutex;
1183 return g_instances_mutex;
1186 static ObjectFileInstances &
1187 GetObjectFileInstances ()
1189 static ObjectFileInstances g_instances;
1194 PluginManager::RegisterPlugin (const ConstString &name,
1195 const char *description,
1196 ObjectFileCreateInstance create_callback,
1197 ObjectFileCreateMemoryInstance create_memory_callback,
1198 ObjectFileGetModuleSpecifications get_module_specifications,
1199 ObjectFileSaveCore save_core)
1201 if (create_callback)
1203 ObjectFileInstance instance;
1204 assert ((bool)name);
1205 instance.name = name;
1206 if (description && description[0])
1207 instance.description = description;
1208 instance.create_callback = create_callback;
1209 instance.create_memory_callback = create_memory_callback;
1210 instance.save_core = save_core;
1211 instance.get_module_specifications = get_module_specifications;
1212 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1213 GetObjectFileInstances ().push_back (instance);
1219 PluginManager::UnregisterPlugin (ObjectFileCreateInstance create_callback)
1221 if (create_callback)
1223 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1224 ObjectFileInstances &instances = GetObjectFileInstances ();
1226 ObjectFileInstances::iterator pos, end = instances.end();
1227 for (pos = instances.begin(); pos != end; ++ pos)
1229 if (pos->create_callback == create_callback)
1231 instances.erase(pos);
1239 ObjectFileCreateInstance
1240 PluginManager::GetObjectFileCreateCallbackAtIndex (uint32_t idx)
1242 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1243 ObjectFileInstances &instances = GetObjectFileInstances ();
1244 if (idx < instances.size())
1245 return instances[idx].create_callback;
1249 ObjectFileCreateMemoryInstance
1250 PluginManager::GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx)
1252 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1253 ObjectFileInstances &instances = GetObjectFileInstances ();
1254 if (idx < instances.size())
1255 return instances[idx].create_memory_callback;
1259 ObjectFileGetModuleSpecifications
1260 PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
1262 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1263 ObjectFileInstances &instances = GetObjectFileInstances ();
1264 if (idx < instances.size())
1265 return instances[idx].get_module_specifications;
1269 ObjectFileCreateInstance
1270 PluginManager::GetObjectFileCreateCallbackForPluginName (const ConstString &name)
1274 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1275 ObjectFileInstances &instances = GetObjectFileInstances ();
1277 ObjectFileInstances::iterator pos, end = instances.end();
1278 for (pos = instances.begin(); pos != end; ++ pos)
1280 if (name == pos->name)
1281 return pos->create_callback;
1287 ObjectFileCreateMemoryInstance
1288 PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name)
1292 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1293 ObjectFileInstances &instances = GetObjectFileInstances ();
1295 ObjectFileInstances::iterator pos, end = instances.end();
1296 for (pos = instances.begin(); pos != end; ++ pos)
1298 if (name == pos->name)
1299 return pos->create_memory_callback;
1306 PluginManager::SaveCore (const lldb::ProcessSP &process_sp, const FileSpec &outfile)
1309 std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
1310 ObjectFileInstances &instances = GetObjectFileInstances ();
1312 ObjectFileInstances::iterator pos, end = instances.end();
1313 for (pos = instances.begin(); pos != end; ++ pos)
1315 if (pos->save_core && pos->save_core (process_sp, outfile, error))
1318 error.SetErrorString("no ObjectFile plugins were able to save a core for this process");
1322 #pragma mark ObjectContainer
1324 struct ObjectContainerInstance
1326 ObjectContainerInstance() :
1329 create_callback(nullptr),
1330 get_module_specifications(nullptr)
1335 std::string description;
1336 ObjectContainerCreateInstance create_callback;
1337 ObjectFileGetModuleSpecifications get_module_specifications;
1340 typedef std::vector<ObjectContainerInstance> ObjectContainerInstances;
1342 static std::recursive_mutex &
1343 GetObjectContainerMutex()
1345 static std::recursive_mutex g_instances_mutex;
1346 return g_instances_mutex;
1349 static ObjectContainerInstances &
1350 GetObjectContainerInstances ()
1352 static ObjectContainerInstances g_instances;
1357 PluginManager::RegisterPlugin (const ConstString &name,
1358 const char *description,
1359 ObjectContainerCreateInstance create_callback,
1360 ObjectFileGetModuleSpecifications get_module_specifications)
1362 if (create_callback)
1364 ObjectContainerInstance instance;
1365 assert ((bool)name);
1366 instance.name = name;
1367 if (description && description[0])
1368 instance.description = description;
1369 instance.create_callback = create_callback;
1370 instance.get_module_specifications = get_module_specifications;
1371 std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
1372 GetObjectContainerInstances ().push_back (instance);
1378 PluginManager::UnregisterPlugin (ObjectContainerCreateInstance create_callback)
1380 if (create_callback)
1382 std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
1383 ObjectContainerInstances &instances = GetObjectContainerInstances ();
1385 ObjectContainerInstances::iterator pos, end = instances.end();
1386 for (pos = instances.begin(); pos != end; ++ pos)
1388 if (pos->create_callback == create_callback)
1390 instances.erase(pos);
1398 ObjectContainerCreateInstance
1399 PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx)
1401 std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
1402 ObjectContainerInstances &instances = GetObjectContainerInstances ();
1403 if (idx < instances.size())
1404 return instances[idx].create_callback;
1408 ObjectContainerCreateInstance
1409 PluginManager::GetObjectContainerCreateCallbackForPluginName (const ConstString &name)
1413 std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
1414 ObjectContainerInstances &instances = GetObjectContainerInstances ();
1416 ObjectContainerInstances::iterator pos, end = instances.end();
1417 for (pos = instances.begin(); pos != end; ++ pos)
1419 if (name == pos->name)
1420 return pos->create_callback;
1426 ObjectFileGetModuleSpecifications
1427 PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
1429 std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
1430 ObjectContainerInstances &instances = GetObjectContainerInstances ();
1431 if (idx < instances.size())
1432 return instances[idx].get_module_specifications;
1436 #pragma mark LogChannel
1443 create_callback(nullptr)
1448 std::string description;
1449 LogChannelCreateInstance create_callback;
1452 typedef std::vector<LogInstance> LogInstances;
1454 static std::recursive_mutex &
1457 static std::recursive_mutex g_instances_mutex;
1458 return g_instances_mutex;
1461 static LogInstances &
1464 static LogInstances g_instances;
1469 PluginManager::RegisterPlugin(const ConstString &name,
1470 const char *description,
1471 LogChannelCreateInstance create_callback)
1473 if (create_callback)
1475 LogInstance instance;
1476 assert ((bool)name);
1477 instance.name = name;
1478 if (description && description[0])
1479 instance.description = description;
1480 instance.create_callback = create_callback;
1481 std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
1482 GetLogInstances ().push_back (instance);
1488 PluginManager::UnregisterPlugin (LogChannelCreateInstance create_callback)
1490 if (create_callback)
1492 std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
1493 LogInstances &instances = GetLogInstances ();
1495 LogInstances::iterator pos, end = instances.end();
1496 for (pos = instances.begin(); pos != end; ++ pos)
1498 if (pos->create_callback == create_callback)
1500 instances.erase(pos);
1509 PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx)
1511 std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
1512 LogInstances &instances = GetLogInstances ();
1513 if (idx < instances.size())
1514 return instances[idx].name.GetCString();
1518 LogChannelCreateInstance
1519 PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx)
1521 std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
1522 LogInstances &instances = GetLogInstances ();
1523 if (idx < instances.size())
1524 return instances[idx].create_callback;
1528 LogChannelCreateInstance
1529 PluginManager::GetLogChannelCreateCallbackForPluginName (const ConstString &name)
1533 std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
1534 LogInstances &instances = GetLogInstances ();
1536 LogInstances::iterator pos, end = instances.end();
1537 for (pos = instances.begin(); pos != end; ++ pos)
1539 if (name == pos->name)
1540 return pos->create_callback;
1546 #pragma mark Platform
1548 struct PlatformInstance
1550 PlatformInstance() :
1553 create_callback(nullptr),
1554 debugger_init_callback(nullptr)
1559 std::string description;
1560 PlatformCreateInstance create_callback;
1561 DebuggerInitializeCallback debugger_init_callback;
1564 typedef std::vector<PlatformInstance> PlatformInstances;
1566 static std::recursive_mutex &
1567 GetPlatformInstancesMutex()
1569 static std::recursive_mutex g_platform_instances_mutex;
1570 return g_platform_instances_mutex;
1573 static PlatformInstances &
1574 GetPlatformInstances ()
1576 static PlatformInstances g_platform_instances;
1577 return g_platform_instances;
1581 PluginManager::RegisterPlugin (const ConstString &name,
1582 const char *description,
1583 PlatformCreateInstance create_callback,
1584 DebuggerInitializeCallback debugger_init_callback)
1586 if (create_callback)
1588 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1590 PlatformInstance instance;
1591 assert ((bool)name);
1592 instance.name = name;
1593 if (description && description[0])
1594 instance.description = description;
1595 instance.create_callback = create_callback;
1596 instance.debugger_init_callback = debugger_init_callback;
1597 GetPlatformInstances ().push_back (instance);
1604 PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
1606 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1607 PlatformInstances &instances = GetPlatformInstances ();
1608 if (idx < instances.size())
1609 return instances[idx].name.GetCString();
1614 PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx)
1616 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1617 PlatformInstances &instances = GetPlatformInstances ();
1618 if (idx < instances.size())
1619 return instances[idx].description.c_str();
1624 PluginManager::UnregisterPlugin (PlatformCreateInstance create_callback)
1626 if (create_callback)
1628 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1629 PlatformInstances &instances = GetPlatformInstances ();
1631 PlatformInstances::iterator pos, end = instances.end();
1632 for (pos = instances.begin(); pos != end; ++ pos)
1634 if (pos->create_callback == create_callback)
1636 instances.erase(pos);
1644 PlatformCreateInstance
1645 PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx)
1647 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1648 PlatformInstances &instances = GetPlatformInstances ();
1649 if (idx < instances.size())
1650 return instances[idx].create_callback;
1654 PlatformCreateInstance
1655 PluginManager::GetPlatformCreateCallbackForPluginName (const ConstString &name)
1659 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1660 PlatformInstances &instances = GetPlatformInstances ();
1662 PlatformInstances::iterator pos, end = instances.end();
1663 for (pos = instances.begin(); pos != end; ++ pos)
1665 if (name == pos->name)
1666 return pos->create_callback;
1673 PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
1677 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
1678 PlatformInstances &instances = GetPlatformInstances ();
1679 llvm::StringRef name_sref(name);
1681 PlatformInstances::iterator pos, end = instances.end();
1682 for (pos = instances.begin(); pos != end; ++ pos)
1684 llvm::StringRef plugin_name (pos->name.GetCString());
1685 if (plugin_name.startswith(name_sref))
1686 matches.AppendString (plugin_name.data());
1689 return matches.GetSize();
1692 #pragma mark Process
1694 struct ProcessInstance
1699 create_callback(nullptr),
1700 debugger_init_callback(nullptr)
1705 std::string description;
1706 ProcessCreateInstance create_callback;
1707 DebuggerInitializeCallback debugger_init_callback;
1710 typedef std::vector<ProcessInstance> ProcessInstances;
1712 static std::recursive_mutex &
1715 static std::recursive_mutex g_instances_mutex;
1716 return g_instances_mutex;
1719 static ProcessInstances &
1720 GetProcessInstances ()
1722 static ProcessInstances g_instances;
1727 PluginManager::RegisterPlugin (const ConstString &name,
1728 const char *description,
1729 ProcessCreateInstance create_callback,
1730 DebuggerInitializeCallback debugger_init_callback)
1732 if (create_callback)
1734 ProcessInstance instance;
1735 assert ((bool)name);
1736 instance.name = name;
1737 if (description && description[0])
1738 instance.description = description;
1739 instance.create_callback = create_callback;
1740 instance.debugger_init_callback = debugger_init_callback;
1741 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
1742 GetProcessInstances ().push_back (instance);
1748 PluginManager::GetProcessPluginNameAtIndex (uint32_t idx)
1750 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
1751 ProcessInstances &instances = GetProcessInstances ();
1752 if (idx < instances.size())
1753 return instances[idx].name.GetCString();
1758 PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx)
1760 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
1761 ProcessInstances &instances = GetProcessInstances ();
1762 if (idx < instances.size())
1763 return instances[idx].description.c_str();
1768 PluginManager::UnregisterPlugin (ProcessCreateInstance create_callback)
1770 if (create_callback)
1772 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
1773 ProcessInstances &instances = GetProcessInstances ();
1775 ProcessInstances::iterator pos, end = instances.end();
1776 for (pos = instances.begin(); pos != end; ++ pos)
1778 if (pos->create_callback == create_callback)
1780 instances.erase(pos);
1788 ProcessCreateInstance
1789 PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx)
1791 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
1792 ProcessInstances &instances = GetProcessInstances ();
1793 if (idx < instances.size())
1794 return instances[idx].create_callback;
1798 ProcessCreateInstance
1799 PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name)
1803 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
1804 ProcessInstances &instances = GetProcessInstances ();
1806 ProcessInstances::iterator pos, end = instances.end();
1807 for (pos = instances.begin(); pos != end; ++ pos)
1809 if (name == pos->name)
1810 return pos->create_callback;
1816 #pragma mark ScriptInterpreter
1818 struct ScriptInterpreterInstance
1820 ScriptInterpreterInstance()
1822 , language(lldb::eScriptLanguageNone)
1824 , create_callback(nullptr)
1829 lldb::ScriptLanguage language;
1830 std::string description;
1831 ScriptInterpreterCreateInstance create_callback;
1834 typedef std::vector<ScriptInterpreterInstance> ScriptInterpreterInstances;
1836 static std::recursive_mutex &
1837 GetScriptInterpreterMutex()
1839 static std::recursive_mutex g_instances_mutex;
1840 return g_instances_mutex;
1843 static ScriptInterpreterInstances &
1844 GetScriptInterpreterInstances()
1846 static ScriptInterpreterInstances g_instances;
1851 PluginManager::RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_language,
1852 ScriptInterpreterCreateInstance create_callback)
1854 if (!create_callback)
1856 ScriptInterpreterInstance instance;
1858 instance.name = name;
1859 if (description && description[0])
1860 instance.description = description;
1861 instance.create_callback = create_callback;
1862 instance.language = script_language;
1863 std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
1864 GetScriptInterpreterInstances().push_back(instance);
1869 PluginManager::UnregisterPlugin(ScriptInterpreterCreateInstance create_callback)
1871 if (!create_callback)
1873 std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
1874 ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
1876 ScriptInterpreterInstances::iterator pos, end = instances.end();
1877 for (pos = instances.begin(); pos != end; ++pos)
1879 if (pos->create_callback != create_callback)
1882 instances.erase(pos);
1888 ScriptInterpreterCreateInstance
1889 PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx)
1891 std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
1892 ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
1893 if (idx < instances.size())
1894 return instances[idx].create_callback;
1898 lldb::ScriptInterpreterSP
1899 PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, CommandInterpreter &interpreter)
1901 std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
1902 ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
1904 ScriptInterpreterInstances::iterator pos, end = instances.end();
1905 ScriptInterpreterCreateInstance none_instance = nullptr;
1906 for (pos = instances.begin(); pos != end; ++pos)
1908 if (pos->language == lldb::eScriptLanguageNone)
1909 none_instance = pos->create_callback;
1911 if (script_lang == pos->language)
1912 return pos->create_callback(interpreter);
1915 // If we didn't find one, return the ScriptInterpreter for the null language.
1916 assert(none_instance != nullptr);
1917 return none_instance(interpreter);
1920 #pragma mark SymbolFile
1922 struct SymbolFileInstance
1924 SymbolFileInstance() :
1927 create_callback(nullptr),
1928 debugger_init_callback(nullptr)
1933 std::string description;
1934 SymbolFileCreateInstance create_callback;
1935 DebuggerInitializeCallback debugger_init_callback;
1938 typedef std::vector<SymbolFileInstance> SymbolFileInstances;
1940 static std::recursive_mutex &
1941 GetSymbolFileMutex()
1943 static std::recursive_mutex g_instances_mutex;
1944 return g_instances_mutex;
1947 static SymbolFileInstances &
1948 GetSymbolFileInstances ()
1950 static SymbolFileInstances g_instances;
1955 PluginManager::RegisterPlugin(const ConstString &name,
1956 const char *description,
1957 SymbolFileCreateInstance create_callback,
1958 DebuggerInitializeCallback debugger_init_callback)
1960 if (create_callback)
1962 SymbolFileInstance instance;
1963 assert ((bool)name);
1964 instance.name = name;
1965 if (description && description[0])
1966 instance.description = description;
1967 instance.create_callback = create_callback;
1968 instance.debugger_init_callback = debugger_init_callback;
1969 std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
1970 GetSymbolFileInstances ().push_back (instance);
1976 PluginManager::UnregisterPlugin (SymbolFileCreateInstance create_callback)
1978 if (create_callback)
1980 std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
1981 SymbolFileInstances &instances = GetSymbolFileInstances ();
1983 SymbolFileInstances::iterator pos, end = instances.end();
1984 for (pos = instances.begin(); pos != end; ++ pos)
1986 if (pos->create_callback == create_callback)
1988 instances.erase(pos);
1996 SymbolFileCreateInstance
1997 PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx)
1999 std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
2000 SymbolFileInstances &instances = GetSymbolFileInstances ();
2001 if (idx < instances.size())
2002 return instances[idx].create_callback;
2006 SymbolFileCreateInstance
2007 PluginManager::GetSymbolFileCreateCallbackForPluginName (const ConstString &name)
2011 std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
2012 SymbolFileInstances &instances = GetSymbolFileInstances ();
2014 SymbolFileInstances::iterator pos, end = instances.end();
2015 for (pos = instances.begin(); pos != end; ++ pos)
2017 if (name == pos->name)
2018 return pos->create_callback;
2024 #pragma mark SymbolVendor
2026 struct SymbolVendorInstance
2028 SymbolVendorInstance() :
2031 create_callback(nullptr)
2036 std::string description;
2037 SymbolVendorCreateInstance create_callback;
2040 typedef std::vector<SymbolVendorInstance> SymbolVendorInstances;
2042 static std::recursive_mutex &
2043 GetSymbolVendorMutex()
2045 static std::recursive_mutex g_instances_mutex;
2046 return g_instances_mutex;
2049 static SymbolVendorInstances &
2050 GetSymbolVendorInstances ()
2052 static SymbolVendorInstances g_instances;
2057 PluginManager::RegisterPlugin(const ConstString &name,
2058 const char *description,
2059 SymbolVendorCreateInstance create_callback)
2061 if (create_callback)
2063 SymbolVendorInstance instance;
2064 assert ((bool)name);
2065 instance.name = name;
2066 if (description && description[0])
2067 instance.description = description;
2068 instance.create_callback = create_callback;
2069 std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
2070 GetSymbolVendorInstances ().push_back (instance);
2076 PluginManager::UnregisterPlugin (SymbolVendorCreateInstance create_callback)
2078 if (create_callback)
2080 std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
2081 SymbolVendorInstances &instances = GetSymbolVendorInstances ();
2083 SymbolVendorInstances::iterator pos, end = instances.end();
2084 for (pos = instances.begin(); pos != end; ++ pos)
2086 if (pos->create_callback == create_callback)
2088 instances.erase(pos);
2096 SymbolVendorCreateInstance
2097 PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx)
2099 std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
2100 SymbolVendorInstances &instances = GetSymbolVendorInstances ();
2101 if (idx < instances.size())
2102 return instances[idx].create_callback;
2106 SymbolVendorCreateInstance
2107 PluginManager::GetSymbolVendorCreateCallbackForPluginName (const ConstString &name)
2111 std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
2112 SymbolVendorInstances &instances = GetSymbolVendorInstances ();
2114 SymbolVendorInstances::iterator pos, end = instances.end();
2115 for (pos = instances.begin(); pos != end; ++ pos)
2117 if (name == pos->name)
2118 return pos->create_callback;
2124 #pragma mark UnwindAssembly
2126 struct UnwindAssemblyInstance
2128 UnwindAssemblyInstance() :
2131 create_callback(nullptr)
2136 std::string description;
2137 UnwindAssemblyCreateInstance create_callback;
2140 typedef std::vector<UnwindAssemblyInstance> UnwindAssemblyInstances;
2142 static std::recursive_mutex &
2143 GetUnwindAssemblyMutex()
2145 static std::recursive_mutex g_instances_mutex;
2146 return g_instances_mutex;
2149 static UnwindAssemblyInstances &
2150 GetUnwindAssemblyInstances ()
2152 static UnwindAssemblyInstances g_instances;
2157 PluginManager::RegisterPlugin(const ConstString &name,
2158 const char *description,
2159 UnwindAssemblyCreateInstance create_callback)
2161 if (create_callback)
2163 UnwindAssemblyInstance instance;
2164 assert ((bool)name);
2165 instance.name = name;
2166 if (description && description[0])
2167 instance.description = description;
2168 instance.create_callback = create_callback;
2169 std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
2170 GetUnwindAssemblyInstances ().push_back (instance);
2176 PluginManager::UnregisterPlugin (UnwindAssemblyCreateInstance create_callback)
2178 if (create_callback)
2180 std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
2181 UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
2183 UnwindAssemblyInstances::iterator pos, end = instances.end();
2184 for (pos = instances.begin(); pos != end; ++ pos)
2186 if (pos->create_callback == create_callback)
2188 instances.erase(pos);
2196 UnwindAssemblyCreateInstance
2197 PluginManager::GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx)
2199 std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
2200 UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
2201 if (idx < instances.size())
2202 return instances[idx].create_callback;
2206 UnwindAssemblyCreateInstance
2207 PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name)
2211 std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
2212 UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
2214 UnwindAssemblyInstances::iterator pos, end = instances.end();
2215 for (pos = instances.begin(); pos != end; ++ pos)
2217 if (name == pos->name)
2218 return pos->create_callback;
2224 #pragma mark MemoryHistory
2226 struct MemoryHistoryInstance
2228 MemoryHistoryInstance() :
2231 create_callback(nullptr)
2236 std::string description;
2237 MemoryHistoryCreateInstance create_callback;
2240 typedef std::vector<MemoryHistoryInstance> MemoryHistoryInstances;
2242 static std::recursive_mutex &
2243 GetMemoryHistoryMutex()
2245 static std::recursive_mutex g_instances_mutex;
2246 return g_instances_mutex;
2249 static MemoryHistoryInstances &
2250 GetMemoryHistoryInstances ()
2252 static MemoryHistoryInstances g_instances;
2257 PluginManager::RegisterPlugin(const ConstString &name,
2258 const char *description,
2259 MemoryHistoryCreateInstance create_callback)
2261 if (create_callback)
2263 MemoryHistoryInstance instance;
2264 assert ((bool)name);
2265 instance.name = name;
2266 if (description && description[0])
2267 instance.description = description;
2268 instance.create_callback = create_callback;
2269 std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
2270 GetMemoryHistoryInstances ().push_back (instance);
2276 PluginManager::UnregisterPlugin (MemoryHistoryCreateInstance create_callback)
2278 if (create_callback)
2280 std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
2281 MemoryHistoryInstances &instances = GetMemoryHistoryInstances ();
2283 MemoryHistoryInstances::iterator pos, end = instances.end();
2284 for (pos = instances.begin(); pos != end; ++ pos)
2286 if (pos->create_callback == create_callback)
2288 instances.erase(pos);
2296 MemoryHistoryCreateInstance
2297 PluginManager::GetMemoryHistoryCreateCallbackAtIndex (uint32_t idx)
2299 std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
2300 MemoryHistoryInstances &instances = GetMemoryHistoryInstances ();
2301 if (idx < instances.size())
2302 return instances[idx].create_callback;
2306 MemoryHistoryCreateInstance
2307 PluginManager::GetMemoryHistoryCreateCallbackForPluginName (const ConstString &name)
2311 std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
2312 MemoryHistoryInstances &instances = GetMemoryHistoryInstances ();
2314 MemoryHistoryInstances::iterator pos, end = instances.end();
2315 for (pos = instances.begin(); pos != end; ++ pos)
2317 if (name == pos->name)
2318 return pos->create_callback;
2324 #pragma mark InstrumentationRuntime
2326 struct InstrumentationRuntimeInstance
2328 InstrumentationRuntimeInstance() :
2331 create_callback(nullptr)
2336 std::string description;
2337 InstrumentationRuntimeCreateInstance create_callback;
2338 InstrumentationRuntimeGetType get_type_callback;
2341 typedef std::vector<InstrumentationRuntimeInstance> InstrumentationRuntimeInstances;
2343 static std::recursive_mutex &
2344 GetInstrumentationRuntimeMutex()
2346 static std::recursive_mutex g_instances_mutex;
2347 return g_instances_mutex;
2350 static InstrumentationRuntimeInstances &
2351 GetInstrumentationRuntimeInstances ()
2353 static InstrumentationRuntimeInstances g_instances;
2358 PluginManager::RegisterPlugin(const ConstString &name,
2359 const char *description,
2360 InstrumentationRuntimeCreateInstance create_callback,
2361 InstrumentationRuntimeGetType get_type_callback)
2363 if (create_callback)
2365 InstrumentationRuntimeInstance instance;
2366 assert ((bool)name);
2367 instance.name = name;
2368 if (description && description[0])
2369 instance.description = description;
2370 instance.create_callback = create_callback;
2371 instance.get_type_callback = get_type_callback;
2372 std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
2373 GetInstrumentationRuntimeInstances ().push_back (instance);
2379 PluginManager::UnregisterPlugin (InstrumentationRuntimeCreateInstance create_callback)
2381 if (create_callback)
2383 std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
2384 InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances ();
2386 InstrumentationRuntimeInstances::iterator pos, end = instances.end();
2387 for (pos = instances.begin(); pos != end; ++ pos)
2389 if (pos->create_callback == create_callback)
2391 instances.erase(pos);
2399 InstrumentationRuntimeGetType
2400 PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex (uint32_t idx)
2402 std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
2403 InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances ();
2404 if (idx < instances.size())
2405 return instances[idx].get_type_callback;
2409 InstrumentationRuntimeCreateInstance
2410 PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex (uint32_t idx)
2412 std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
2413 InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances ();
2414 if (idx < instances.size())
2415 return instances[idx].create_callback;
2419 InstrumentationRuntimeCreateInstance
2420 PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name)
2424 std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
2425 InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances ();
2427 InstrumentationRuntimeInstances::iterator pos, end = instances.end();
2428 for (pos = instances.begin(); pos != end; ++ pos)
2430 if (name == pos->name)
2431 return pos->create_callback;
2437 #pragma mark TypeSystem
2439 struct TypeSystemInstance
2441 TypeSystemInstance() :
2444 create_callback(nullptr)
2449 std::string description;
2450 TypeSystemCreateInstance create_callback;
2451 TypeSystemEnumerateSupportedLanguages enumerate_callback;
2454 typedef std::vector<TypeSystemInstance> TypeSystemInstances;
2456 static std::recursive_mutex &
2457 GetTypeSystemMutex()
2459 static std::recursive_mutex g_instances_mutex;
2460 return g_instances_mutex;
2463 static TypeSystemInstances &
2464 GetTypeSystemInstances ()
2466 static TypeSystemInstances g_instances;
2471 PluginManager::RegisterPlugin (const ConstString &name,
2472 const char *description,
2473 TypeSystemCreateInstance create_callback,
2474 TypeSystemEnumerateSupportedLanguages enumerate_supported_languages_callback)
2476 if (create_callback)
2478 TypeSystemInstance instance;
2479 assert ((bool)name);
2480 instance.name = name;
2481 if (description && description[0])
2482 instance.description = description;
2483 instance.create_callback = create_callback;
2484 instance.enumerate_callback = enumerate_supported_languages_callback;
2485 std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
2486 GetTypeSystemInstances ().push_back (instance);
2492 PluginManager::UnregisterPlugin (TypeSystemCreateInstance create_callback)
2494 if (create_callback)
2496 std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
2497 TypeSystemInstances &instances = GetTypeSystemInstances ();
2499 TypeSystemInstances::iterator pos, end = instances.end();
2500 for (pos = instances.begin(); pos != end; ++ pos)
2502 if (pos->create_callback == create_callback)
2504 instances.erase(pos);
2512 TypeSystemCreateInstance
2513 PluginManager::GetTypeSystemCreateCallbackAtIndex (uint32_t idx)
2515 std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
2516 TypeSystemInstances &instances = GetTypeSystemInstances ();
2517 if (idx < instances.size())
2518 return instances[idx].create_callback;
2522 TypeSystemCreateInstance
2523 PluginManager::GetTypeSystemCreateCallbackForPluginName (const ConstString &name)
2527 std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
2528 TypeSystemInstances &instances = GetTypeSystemInstances ();
2530 TypeSystemInstances::iterator pos, end = instances.end();
2531 for (pos = instances.begin(); pos != end; ++ pos)
2533 if (name == pos->name)
2534 return pos->create_callback;
2540 TypeSystemEnumerateSupportedLanguages
2541 PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
2543 std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
2544 TypeSystemInstances &instances = GetTypeSystemInstances ();
2545 if (idx < instances.size())
2546 return instances[idx].enumerate_callback;
2550 TypeSystemEnumerateSupportedLanguages
2551 PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name)
2555 std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
2556 TypeSystemInstances &instances = GetTypeSystemInstances ();
2558 TypeSystemInstances::iterator pos, end = instances.end();
2559 for (pos = instances.begin(); pos != end; ++ pos)
2561 if (name == pos->name)
2562 return pos->enumerate_callback;
2575 create_callback(nullptr)
2580 std::string description;
2581 REPLCreateInstance create_callback;
2582 REPLEnumerateSupportedLanguages enumerate_languages_callback;
2585 typedef std::vector<REPLInstance> REPLInstances;
2587 static std::recursive_mutex &
2590 static std::recursive_mutex g_instances_mutex;
2591 return g_instances_mutex;
2594 static REPLInstances &
2597 static REPLInstances g_instances;
2602 PluginManager::RegisterPlugin (const ConstString &name,
2603 const char *description,
2604 REPLCreateInstance create_callback,
2605 REPLEnumerateSupportedLanguages enumerate_languages_callback)
2607 if (create_callback)
2609 REPLInstance instance;
2610 assert ((bool)name);
2611 instance.name = name;
2612 if (description && description[0])
2613 instance.description = description;
2614 instance.create_callback = create_callback;
2615 instance.enumerate_languages_callback = enumerate_languages_callback;
2616 std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
2617 GetREPLInstances ().push_back (instance);
2623 PluginManager::UnregisterPlugin (REPLCreateInstance create_callback)
2625 if (create_callback)
2627 std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
2628 REPLInstances &instances = GetREPLInstances ();
2630 REPLInstances::iterator pos, end = instances.end();
2631 for (pos = instances.begin(); pos != end; ++ pos)
2633 if (pos->create_callback == create_callback)
2635 instances.erase(pos);
2644 PluginManager::GetREPLCreateCallbackAtIndex (uint32_t idx)
2646 std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
2647 REPLInstances &instances = GetREPLInstances ();
2648 if (idx < instances.size())
2649 return instances[idx].create_callback;
2654 PluginManager::GetREPLCreateCallbackForPluginName (const ConstString &name)
2658 std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
2659 REPLInstances &instances = GetREPLInstances ();
2661 REPLInstances::iterator pos, end = instances.end();
2662 for (pos = instances.begin(); pos != end; ++ pos)
2664 if (name == pos->name)
2665 return pos->create_callback;
2671 REPLEnumerateSupportedLanguages
2672 PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
2674 std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
2675 REPLInstances &instances = GetREPLInstances ();
2676 if (idx < instances.size())
2677 return instances[idx].enumerate_languages_callback;
2681 REPLEnumerateSupportedLanguages
2682 PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name)
2686 std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
2687 REPLInstances &instances = GetREPLInstances ();
2689 REPLInstances::iterator pos, end = instances.end();
2690 for (pos = instances.begin(); pos != end; ++ pos)
2692 if (name == pos->name)
2693 return pos->enumerate_languages_callback;
2699 #pragma mark PluginManager
2702 PluginManager::DebuggerInitialize (Debugger &debugger)
2704 // Initialize the DynamicLoader plugins
2706 std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
2707 DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
2709 DynamicLoaderInstances::iterator pos, end = instances.end();
2710 for (pos = instances.begin(); pos != end; ++ pos)
2712 if (pos->debugger_init_callback)
2713 pos->debugger_init_callback (debugger);
2717 // Initialize the JITLoader plugins
2719 std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
2720 JITLoaderInstances &instances = GetJITLoaderInstances ();
2722 JITLoaderInstances::iterator pos, end = instances.end();
2723 for (pos = instances.begin(); pos != end; ++ pos)
2725 if (pos->debugger_init_callback)
2726 pos->debugger_init_callback (debugger);
2730 // Initialize the Platform plugins
2732 std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
2733 PlatformInstances &instances = GetPlatformInstances ();
2735 PlatformInstances::iterator pos, end = instances.end();
2736 for (pos = instances.begin(); pos != end; ++ pos)
2738 if (pos->debugger_init_callback)
2739 pos->debugger_init_callback (debugger);
2743 // Initialize the Process plugins
2745 std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
2746 ProcessInstances &instances = GetProcessInstances();
2748 ProcessInstances::iterator pos, end = instances.end();
2749 for (pos = instances.begin(); pos != end; ++ pos)
2751 if (pos->debugger_init_callback)
2752 pos->debugger_init_callback (debugger);
2756 // Initialize the SymbolFile plugins
2758 std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
2759 for (auto& sym_file: GetSymbolFileInstances())
2761 if (sym_file.debugger_init_callback)
2762 sym_file.debugger_init_callback (debugger);
2766 // Initialize the OperatingSystem plugins
2768 std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
2769 for (auto &os : GetOperatingSystemInstances())
2771 if (os.debugger_init_callback)
2772 os.debugger_init_callback(debugger);
2777 // This is the preferred new way to register plugin specific settings. e.g.
2778 // This will put a plugin's settings under e.g. "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
2779 static lldb::OptionValuePropertiesSP
2780 GetDebuggerPropertyForPlugins (Debugger &debugger,
2781 const ConstString &plugin_type_name,
2782 const ConstString &plugin_type_desc,
2785 lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
2786 if (parent_properties_sp)
2788 static ConstString g_property_name("plugin");
2790 OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty(nullptr, g_property_name);
2791 if (!plugin_properties_sp && can_create)
2793 plugin_properties_sp.reset (new OptionValueProperties (g_property_name));
2794 parent_properties_sp->AppendProperty (g_property_name,
2795 ConstString("Settings specify to plugins."),
2797 plugin_properties_sp);
2800 if (plugin_properties_sp)
2802 lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2803 if (!plugin_type_properties_sp && can_create)
2805 plugin_type_properties_sp.reset (new OptionValueProperties (plugin_type_name));
2806 plugin_properties_sp->AppendProperty (plugin_type_name,
2809 plugin_type_properties_sp);
2811 return plugin_type_properties_sp;
2814 return lldb::OptionValuePropertiesSP();
2817 // This is deprecated way to register plugin specific settings. e.g.
2818 // "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME"
2819 // and Platform generic settings would be under "platform.SETTINGNAME".
2820 static lldb::OptionValuePropertiesSP
2821 GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
2822 const ConstString &plugin_type_name,
2823 const ConstString &plugin_type_desc,
2826 static ConstString g_property_name("plugin");
2827 lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
2828 if (parent_properties_sp)
2830 OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2831 if (!plugin_properties_sp && can_create)
2833 plugin_properties_sp.reset (new OptionValueProperties (plugin_type_name));
2834 parent_properties_sp->AppendProperty (plugin_type_name,
2837 plugin_properties_sp);
2840 if (plugin_properties_sp)
2842 lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
2843 if (!plugin_type_properties_sp && can_create)
2845 plugin_type_properties_sp.reset (new OptionValueProperties (g_property_name));
2846 plugin_properties_sp->AppendProperty (g_property_name,
2847 ConstString("Settings specific to plugins"),
2849 plugin_type_properties_sp);
2851 return plugin_type_properties_sp;
2854 return lldb::OptionValuePropertiesSP();
2859 typedef lldb::OptionValuePropertiesSP
2860 GetDebuggerPropertyForPluginsPtr (Debugger&, const ConstString&, const ConstString&, bool can_create);
2862 lldb::OptionValuePropertiesSP
2863 GetSettingForPlugin (Debugger &debugger,
2864 const ConstString &setting_name,
2865 const ConstString &plugin_type_name,
2866 GetDebuggerPropertyForPluginsPtr get_debugger_property= GetDebuggerPropertyForPlugins)
2868 lldb::OptionValuePropertiesSP properties_sp;
2869 lldb::OptionValuePropertiesSP plugin_type_properties_sp (get_debugger_property (debugger,
2871 ConstString(), // not creating to so we don't need the description
2873 if (plugin_type_properties_sp)
2874 properties_sp = plugin_type_properties_sp->GetSubProperty (nullptr, setting_name);
2875 return properties_sp;
2879 CreateSettingForPlugin (Debugger &debugger,
2880 const ConstString &plugin_type_name,
2881 const ConstString &plugin_type_desc,
2882 const lldb::OptionValuePropertiesSP &properties_sp,
2883 const ConstString &description,
2884 bool is_global_property,
2885 GetDebuggerPropertyForPluginsPtr get_debugger_property = GetDebuggerPropertyForPlugins)
2889 lldb::OptionValuePropertiesSP plugin_type_properties_sp (get_debugger_property (
2890 debugger, plugin_type_name, plugin_type_desc, true));
2891 if (plugin_type_properties_sp)
2893 plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
2903 const char* kDynamicLoaderPluginName("dynamic-loader");
2904 const char* kPlatformPluginName("platform");
2905 const char* kProcessPluginName("process");
2906 const char* kSymbolFilePluginName("symbol-file");
2907 const char* kJITLoaderPluginName("jit-loader");
2909 } // anonymous namespace
2911 lldb::OptionValuePropertiesSP
2912 PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger,
2913 const ConstString &setting_name)
2915 return GetSettingForPlugin(debugger, setting_name, ConstString(kDynamicLoaderPluginName));
2919 PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
2920 const lldb::OptionValuePropertiesSP &properties_sp,
2921 const ConstString &description,
2922 bool is_global_property)
2924 return CreateSettingForPlugin(debugger,
2925 ConstString(kDynamicLoaderPluginName),
2926 ConstString("Settings for dynamic loader plug-ins"),
2929 is_global_property);
2932 lldb::OptionValuePropertiesSP
2933 PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
2935 return GetSettingForPlugin(debugger,
2937 ConstString(kPlatformPluginName),
2938 GetDebuggerPropertyForPluginsOldStyle);
2942 PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
2943 const lldb::OptionValuePropertiesSP &properties_sp,
2944 const ConstString &description,
2945 bool is_global_property)
2947 return CreateSettingForPlugin(debugger,
2948 ConstString(kPlatformPluginName),
2949 ConstString("Settings for platform plug-ins"),
2953 GetDebuggerPropertyForPluginsOldStyle);
2956 lldb::OptionValuePropertiesSP
2957 PluginManager::GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name)
2959 return GetSettingForPlugin(debugger, setting_name, ConstString(kProcessPluginName));
2963 PluginManager::CreateSettingForProcessPlugin (Debugger &debugger,
2964 const lldb::OptionValuePropertiesSP &properties_sp,
2965 const ConstString &description,
2966 bool is_global_property)
2968 return CreateSettingForPlugin(debugger,
2969 ConstString(kProcessPluginName),
2970 ConstString("Settings for process plug-ins"),
2973 is_global_property);
2976 lldb::OptionValuePropertiesSP
2977 PluginManager::GetSettingForSymbolFilePlugin (Debugger &debugger,
2978 const ConstString &setting_name)
2980 return GetSettingForPlugin(debugger, setting_name, ConstString(kSymbolFilePluginName));
2984 PluginManager::CreateSettingForSymbolFilePlugin (Debugger &debugger,
2985 const lldb::OptionValuePropertiesSP &properties_sp,
2986 const ConstString &description,
2987 bool is_global_property)
2989 return CreateSettingForPlugin(debugger,
2990 ConstString(kSymbolFilePluginName),
2991 ConstString("Settings for symbol file plug-ins"),
2994 is_global_property);
2997 lldb::OptionValuePropertiesSP
2998 PluginManager::GetSettingForJITLoaderPlugin (Debugger &debugger,
2999 const ConstString &setting_name)
3001 return GetSettingForPlugin(debugger, setting_name, ConstString(kJITLoaderPluginName));
3005 PluginManager::CreateSettingForJITLoaderPlugin (Debugger &debugger,
3006 const lldb::OptionValuePropertiesSP &properties_sp,
3007 const ConstString &description,
3008 bool is_global_property)
3010 return CreateSettingForPlugin(debugger,
3011 ConstString(kJITLoaderPluginName),
3012 ConstString("Settings for JIT loader plug-ins"),
3015 is_global_property);
3018 static const char *kOperatingSystemPluginName("os");
3020 lldb::OptionValuePropertiesSP
3021 PluginManager::GetSettingForOperatingSystemPlugin(Debugger &debugger, const ConstString &setting_name)
3023 lldb::OptionValuePropertiesSP properties_sp;
3024 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
3025 GetDebuggerPropertyForPlugins(debugger, ConstString(kOperatingSystemPluginName),
3026 ConstString(), // not creating to so we don't need the description
3028 if (plugin_type_properties_sp)
3029 properties_sp = plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
3030 return properties_sp;
3034 PluginManager::CreateSettingForOperatingSystemPlugin(Debugger &debugger,
3035 const lldb::OptionValuePropertiesSP &properties_sp,
3036 const ConstString &description, bool is_global_property)
3040 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
3041 GetDebuggerPropertyForPlugins(debugger, ConstString(kOperatingSystemPluginName),
3042 ConstString("Settings for operating system plug-ins"), true));
3043 if (plugin_type_properties_sp)
3045 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(), description, is_global_property,