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"
16#include "lldb/Target/Process.h"
18#include "lldb/Utility/Status.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/Twine.h"
22#include "llvm/Support/DynamicLibrary.h"
23#include "llvm/Support/FileSystem.h"
24#include "llvm/Support/raw_ostream.h"
25#include <cassert>
26#include <map>
27#include <memory>
28#include <mutex>
29#include <string>
30#include <utility>
31#include <vector>
32#if defined(_WIN32)
34#endif
35
36using namespace lldb;
37using namespace lldb_private;
38
40typedef void (*PluginTermCallback)();
41
42struct PluginInfo {
43 PluginInfo() = default;
44
45 llvm::sys::DynamicLibrary library;
48};
49
50typedef std::map<FileSpec, PluginInfo> PluginTerminateMap;
51
52static std::recursive_mutex &GetPluginMapMutex() {
53 static std::recursive_mutex g_plugin_map_mutex;
54 return g_plugin_map_mutex;
55}
56
58 static PluginTerminateMap g_plugin_map;
59 return g_plugin_map;
60}
61
62static bool PluginIsLoaded(const FileSpec &plugin_file_spec) {
63 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
64 PluginTerminateMap &plugin_map = GetPluginMap();
65 return plugin_map.find(plugin_file_spec) != plugin_map.end();
66}
67
68static void SetPluginInfo(const FileSpec &plugin_file_spec,
69 const PluginInfo &plugin_info) {
70 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
71 PluginTerminateMap &plugin_map = GetPluginMap();
72 assert(plugin_map.find(plugin_file_spec) == plugin_map.end());
73 plugin_map[plugin_file_spec] = plugin_info;
74}
75
76template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
77 return reinterpret_cast<FPtrTy>(VPtr);
78}
79
81LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
82 llvm::StringRef path) {
84
85 namespace fs = llvm::sys::fs;
86 // If we have a regular file, a symbolic link or unknown file type, try and
87 // process the file. We must handle unknown as sometimes the directory
88 // enumeration might be enumerating a file system that doesn't have correct
89 // file type information.
90 if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
91 ft == fs::file_type::type_unknown) {
92 FileSpec plugin_file_spec(path);
93 FileSystem::Instance().Resolve(plugin_file_spec);
94
95 if (PluginIsLoaded(plugin_file_spec))
97 else {
98 PluginInfo plugin_info;
99
100 std::string pluginLoadError;
101 plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary(
102 plugin_file_spec.GetPath().c_str(), &pluginLoadError);
103 if (plugin_info.library.isValid()) {
104 bool success = false;
106 plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"));
107 if (plugin_info.plugin_init_callback) {
108 // Call the plug-in "bool LLDBPluginInitialize(void)" function
109 success = plugin_info.plugin_init_callback();
110 }
111
112 if (success) {
113 // It is ok for the "LLDBPluginTerminate" symbol to be nullptr
115 plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
116 } else {
117 // The initialize function returned FALSE which means the plug-in
118 // might not be compatible, or might be too new or too old, or might
119 // not want to run on this machine. Set it to a default-constructed
120 // instance to invalidate it.
121 plugin_info = PluginInfo();
122 }
123
124 // Regardless of success or failure, cache the plug-in load in our
125 // plug-in info so we don't try to load it again and again.
126 SetPluginInfo(plugin_file_spec, plugin_info);
127
129 }
130 }
131 }
132
133 if (ft == fs::file_type::directory_file ||
134 ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
135 // Try and recurse into anything that a directory or symbolic link. We must
136 // also do this for unknown as sometimes the directory enumeration might be
137 // enumerating a file system that doesn't have correct file type
138 // information.
140 }
141
143}
144
146 const bool find_directories = true;
147 const bool find_files = true;
148 const bool find_other = true;
149 char dir_path[PATH_MAX];
150 if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) {
151 if (FileSystem::Instance().Exists(dir_spec) &&
152 dir_spec.GetPath(dir_path, sizeof(dir_path))) {
153 FileSystem::Instance().EnumerateDirectory(dir_path, find_directories,
154 find_files, find_other,
155 LoadPluginCallback, nullptr);
156 }
157 }
158
159 if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) {
160 if (FileSystem::Instance().Exists(dir_spec) &&
161 dir_spec.GetPath(dir_path, sizeof(dir_path))) {
162 FileSystem::Instance().EnumerateDirectory(dir_path, find_directories,
163 find_files, find_other,
164 LoadPluginCallback, nullptr);
165 }
166 }
167}
168
170 std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
171 PluginTerminateMap &plugin_map = GetPluginMap();
172
173 PluginTerminateMap::const_iterator pos, end = plugin_map.end();
174 for (pos = plugin_map.begin(); pos != end; ++pos) {
175 // Call the plug-in "void LLDBPluginTerminate (void)" function if there is
176 // one (if the symbol was not nullptr).
177 if (pos->second.library.isValid()) {
178 if (pos->second.plugin_term_callback)
179 pos->second.plugin_term_callback();
180 }
181 }
182 plugin_map.clear();
183}
184
185llvm::ArrayRef<PluginNamespace> PluginManager::GetPluginNamespaces() {
186 static PluginNamespace PluginNamespaces[] = {
187
188 {
189 "abi",
192 },
193
194 {
195 "architecture",
198 },
199
200 {
201 "disassembler",
204 },
205
206 {
207 "dynamic-loader",
210 },
211
212 {
213 "emulate-instruction",
216 },
217
218 {
219 "instrumentation-runtime",
222 },
223
224 {
225 "jit-loader",
228 },
229
230 {
231 "language",
234 },
235
236 {
237 "language-runtime",
240 },
241
242 {
243 "memory-history",
246 },
247
248 {
249 "object-container",
252 },
253
254 {
255 "object-file",
258 },
259
260 {
261 "operating-system",
264 },
265
266 {
267 "platform",
270 },
271
272 {
273 "process",
276 },
277
278 {
279 "repl",
282 },
283
284 {
285 "register-type-builder",
288 },
289
290 {
291 "script-interpreter",
294 },
295
296 {
297 "scripted-interface",
300 },
301
302 {
303 "structured-data",
306 },
307
308 {
309 "symbol-file",
312 },
313
314 {
315 "symbol-locator",
318 },
319
320 {
321 "symbol-vendor",
324 },
325
326 {
327 "system-runtime",
330 },
331
332 {
333 "trace",
336 },
337
338 {
339 "trace-exporter",
342 },
343
344 {
345 "type-system",
348 },
349
350 {
351 "unwind-assembly",
354 },
355 };
356
357 return PluginNamespaces;
358}
359
360llvm::json::Object PluginManager::GetJSON(llvm::StringRef pattern) {
361 llvm::json::Object plugin_stats;
362
363 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
364 llvm::json::Array namespace_stats;
365
366 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
367 if (MatchPluginName(pattern, plugin_ns, plugin)) {
368 llvm::json::Object plugin_json;
369 plugin_json.try_emplace("name", plugin.name);
370 plugin_json.try_emplace("enabled", plugin.enabled);
371 namespace_stats.emplace_back(std::move(plugin_json));
372 }
373 }
374 if (!namespace_stats.empty())
375 plugin_stats.try_emplace(plugin_ns.name, std::move(namespace_stats));
376 }
377
378 return plugin_stats;
379}
380
381bool PluginManager::MatchPluginName(llvm::StringRef pattern,
382 const PluginNamespace &plugin_ns,
383 const RegisteredPluginInfo &plugin_info) {
384 // The empty pattern matches all plugins.
385 if (pattern.empty())
386 return true;
387
388 // Check if the pattern matches the namespace.
389 if (pattern == plugin_ns.name)
390 return true;
391
392 // Check if the pattern matches the qualified name.
393 std::string qualified_name = (plugin_ns.name + "." + plugin_info.name).str();
394 return pattern == qualified_name;
395}
396
397template <typename Callback> struct PluginInstance {
398 typedef Callback CallbackType;
399
400 PluginInstance() = default;
407
408 llvm::StringRef name;
409 llvm::StringRef description;
413};
414
415template <typename Instance> class PluginInstances {
416public:
417 template <typename... Args>
418 bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
419 typename Instance::CallbackType callback,
420 Args &&...args) {
421 if (!callback)
422 return false;
423 assert(!name.empty());
424 m_instances.emplace_back(name, description, callback,
425 std::forward<Args>(args)...);
426 return true;
427 }
428
429 bool UnregisterPlugin(typename Instance::CallbackType callback) {
430 if (!callback)
431 return false;
432 auto pos = m_instances.begin();
433 auto end = m_instances.end();
434 for (; pos != end; ++pos) {
435 if (pos->create_callback == callback) {
436 m_instances.erase(pos);
437 return true;
438 }
439 }
440 return false;
441 }
442
443 typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) {
444 if (const Instance *instance = GetInstanceAtIndex(idx))
445 return instance->create_callback;
446 return nullptr;
447 }
448
449 llvm::StringRef GetDescriptionAtIndex(uint32_t idx) {
450 if (const Instance *instance = GetInstanceAtIndex(idx))
451 return instance->description;
452 return "";
453 }
454
455 llvm::StringRef GetNameAtIndex(uint32_t idx) {
456 if (const Instance *instance = GetInstanceAtIndex(idx))
457 return instance->name;
458 return "";
459 }
460
461 typename Instance::CallbackType GetCallbackForName(llvm::StringRef name) {
462 if (const Instance *instance = GetInstanceForName(name))
463 return instance->create_callback;
464 return nullptr;
465 }
466
468 for (const auto &instance : m_instances) {
469 if (!instance.enabled)
470 continue;
471 if (instance.debugger_init_callback)
472 instance.debugger_init_callback(debugger);
473 }
474 }
475
476 // Return a copy of all the enabled instances.
477 // Note that this is a copy of the internal state so modifications
478 // to the returned instances will not be reflected back to instances
479 // stored by the PluginInstances object.
480 std::vector<Instance> GetSnapshot() {
481 std::vector<Instance> enabled_instances;
482 for (const auto &instance : m_instances) {
483 if (instance.enabled)
484 enabled_instances.push_back(instance);
485 }
486 return enabled_instances;
487 }
488
489 const Instance *GetInstanceAtIndex(uint32_t idx) {
490 uint32_t count = 0;
491
492 return FindEnabledInstance(
493 [&](const Instance &instance) { return count++ == idx; });
494 }
495
496 const Instance *GetInstanceForName(llvm::StringRef name) {
497 if (name.empty())
498 return nullptr;
499
500 return FindEnabledInstance(
501 [&](const Instance &instance) { return instance.name == name; });
502 }
503
504 const Instance *
505 FindEnabledInstance(std::function<bool(const Instance &)> predicate) const {
506 for (const auto &instance : m_instances) {
507 if (!instance.enabled)
508 continue;
509 if (predicate(instance))
510 return &instance;
511 }
512 return nullptr;
513 }
514
515 // Return a list of all the registered plugin instances. This includes both
516 // enabled and disabled instances. The instances are listed in the order they
517 // were registered which is the order they would be queried if they were all
518 // enabled.
519 std::vector<RegisteredPluginInfo> GetPluginInfoForAllInstances() {
520 // Lookup the plugin info for each instance in the sorted order.
521 std::vector<RegisteredPluginInfo> plugin_infos;
522 plugin_infos.reserve(m_instances.size());
523 for (const Instance &instance : m_instances)
524 plugin_infos.push_back(
525 {instance.name, instance.description, instance.enabled});
526
527 return plugin_infos;
528 }
529
530 bool SetInstanceEnabled(llvm::StringRef name, bool enable) {
531 auto it = llvm::find_if(m_instances, [&](const Instance &instance) {
532 return instance.name == name;
533 });
534
535 if (it == m_instances.end())
536 return false;
537
538 it->enabled = enable;
539 return true;
540 }
541
542private:
543 std::vector<Instance> m_instances;
544};
545
546#pragma mark ABI
547
550
552 static ABIInstances g_instances;
553 return g_instances;
554}
555
556bool PluginManager::RegisterPlugin(llvm::StringRef name,
557 llvm::StringRef description,
558 ABICreateInstance create_callback) {
559 return GetABIInstances().RegisterPlugin(name, description, create_callback);
560}
561
563 return GetABIInstances().UnregisterPlugin(create_callback);
564}
565
569
570#pragma mark Architecture
571
574
576 static ArchitectureInstances g_instances;
577 return g_instances;
578}
579
580void PluginManager::RegisterPlugin(llvm::StringRef name,
581 llvm::StringRef description,
582 ArchitectureCreateInstance create_callback) {
583 GetArchitectureInstances().RegisterPlugin(name, description, create_callback);
584}
585
587 ArchitectureCreateInstance create_callback) {
588 auto &instances = GetArchitectureInstances();
589 instances.UnregisterPlugin(create_callback);
590}
591
592std::unique_ptr<Architecture>
594 for (const auto &instances : GetArchitectureInstances().GetSnapshot()) {
595 if (auto plugin_up = instances.create_callback(arch))
596 return plugin_up;
597 }
598 return nullptr;
599}
600
601#pragma mark Disassembler
602
605
607 static DisassemblerInstances g_instances;
608 return g_instances;
609}
610
611bool PluginManager::RegisterPlugin(llvm::StringRef name,
612 llvm::StringRef description,
613 DisassemblerCreateInstance create_callback) {
614 return GetDisassemblerInstances().RegisterPlugin(name, description,
615 create_callback);
616}
617
619 DisassemblerCreateInstance create_callback) {
620 return GetDisassemblerInstances().UnregisterPlugin(create_callback);
621}
622
627
633
634#pragma mark DynamicLoader
635
638
640 static DynamicLoaderInstances g_instances;
641 return g_instances;
642}
643
645 llvm::StringRef name, llvm::StringRef description,
646 DynamicLoaderCreateInstance create_callback,
647 DebuggerInitializeCallback debugger_init_callback) {
649 name, description, create_callback, debugger_init_callback);
650}
651
653 DynamicLoaderCreateInstance create_callback) {
654 return GetDynamicLoaderInstances().UnregisterPlugin(create_callback);
655}
656
661
667
668#pragma mark JITLoader
669
672
674 static JITLoaderInstances g_instances;
675 return g_instances;
676}
677
679 llvm::StringRef name, llvm::StringRef description,
680 JITLoaderCreateInstance create_callback,
681 DebuggerInitializeCallback debugger_init_callback) {
683 name, description, create_callback, debugger_init_callback);
684}
685
687 return GetJITLoaderInstances().UnregisterPlugin(create_callback);
688}
689
694
695#pragma mark EmulateInstruction
696
700
702 static EmulateInstructionInstances g_instances;
703 return g_instances;
704}
705
707 llvm::StringRef name, llvm::StringRef description,
708 EmulateInstructionCreateInstance create_callback) {
709 return GetEmulateInstructionInstances().RegisterPlugin(name, description,
710 create_callback);
711}
712
717
722
728
729#pragma mark OperatingSystem
730
733
735 static OperatingSystemInstances g_instances;
736 return g_instances;
737}
738
740 llvm::StringRef name, llvm::StringRef description,
741 OperatingSystemCreateInstance create_callback,
742 DebuggerInitializeCallback debugger_init_callback) {
744 name, description, create_callback, debugger_init_callback);
745}
746
751
756
762
763#pragma mark Language
764
767
769 static LanguageInstances g_instances;
770 return g_instances;
771}
772
774 llvm::StringRef name, llvm::StringRef description,
775 LanguageCreateInstance create_callback,
776 DebuggerInitializeCallback debugger_init_callback) {
778 name, description, create_callback, debugger_init_callback);
779}
780
782 return GetLanguageInstances().UnregisterPlugin(create_callback);
783}
784
789
790#pragma mark LanguageRuntime
791
808
810
812 static LanguageRuntimeInstances g_instances;
813 return g_instances;
814}
815
817 llvm::StringRef name, llvm::StringRef description,
818 LanguageRuntimeCreateInstance create_callback,
819 LanguageRuntimeGetCommandObject command_callback,
820 LanguageRuntimeGetExceptionPrecondition precondition_callback) {
822 name, description, create_callback, nullptr, command_callback,
823 precondition_callback);
824}
825
830
835
838 if (auto instance = GetLanguageRuntimeInstances().GetInstanceAtIndex(idx))
839 return instance->command_callback;
840 return nullptr;
841}
842
845 if (auto instance = GetLanguageRuntimeInstances().GetInstanceAtIndex(idx))
846 return instance->precondition_callback;
847 return nullptr;
848}
849
850#pragma mark SystemRuntime
851
854
856 static SystemRuntimeInstances g_instances;
857 return g_instances;
858}
859
861 llvm::StringRef name, llvm::StringRef description,
862 SystemRuntimeCreateInstance create_callback) {
863 return GetSystemRuntimeInstances().RegisterPlugin(name, description,
864 create_callback);
865}
866
868 SystemRuntimeCreateInstance create_callback) {
869 return GetSystemRuntimeInstances().UnregisterPlugin(create_callback);
870}
871
876
877#pragma mark ObjectFile
878
898
900 static ObjectFileInstances g_instances;
901 return g_instances;
902}
903
905 if (name.empty())
906 return false;
907
908 return GetObjectFileInstances().GetInstanceForName(name) != nullptr;
909}
910
912 llvm::StringRef name, llvm::StringRef description,
913 ObjectFileCreateInstance create_callback,
914 ObjectFileCreateMemoryInstance create_memory_callback,
915 ObjectFileGetModuleSpecifications get_module_specifications,
916 ObjectFileSaveCore save_core,
917 DebuggerInitializeCallback debugger_init_callback) {
919 name, description, create_callback, create_memory_callback,
920 get_module_specifications, save_core, debugger_init_callback);
921}
922
926
931
934 if (auto instance = GetObjectFileInstances().GetInstanceAtIndex(idx))
935 return instance->create_memory_callback;
936 return nullptr;
937}
938
941 uint32_t idx) {
942 if (auto instance = GetObjectFileInstances().GetInstanceAtIndex(idx))
943 return instance->get_module_specifications;
944 return nullptr;
945}
946
949 llvm::StringRef name) {
950 if (auto instance = GetObjectFileInstances().GetInstanceForName(name))
951 return instance->create_memory_callback;
952 return nullptr;
953}
954
957 if (!options.GetOutputFile()) {
958 error = Status::FromErrorString("No output file specified");
959 return error;
960 }
961
962 if (!options.GetProcess()) {
963 error = Status::FromErrorString("Invalid process");
964 return error;
965 }
966
968 if (error.Fail())
969 return error;
970
971 if (!options.GetPluginName().has_value()) {
972 // Try saving core directly from the process plugin first.
973 llvm::Expected<bool> ret =
974 options.GetProcess()->SaveCore(options.GetOutputFile()->GetPath());
975 if (!ret)
976 return Status::FromError(ret.takeError());
977 if (ret.get())
978 return Status();
979 }
980
981 // Fall back to object plugins.
982 const auto &plugin_name = options.GetPluginName().value_or("");
983 auto instances = GetObjectFileInstances().GetSnapshot();
984 for (auto &instance : instances) {
985 if (plugin_name.empty() || instance.name == plugin_name) {
986 // TODO: Refactor the instance.save_core() to not require a process and
987 // get it from options instead.
988 if (instance.save_core &&
989 instance.save_core(options.GetProcess(), options, error))
990 return error;
991 }
992 }
993
994 // Check to see if any of the object file plugins tried and failed to save.
995 // if any failure, return the error message.
996 if (error.Fail())
997 return error;
998
999 // Report only for the plugin that was specified.
1000 if (!plugin_name.empty())
1002 "The \"{}\" plugin is not able to save a core for this process.",
1003 plugin_name);
1004
1006 "no ObjectFile plugins were able to save a core for this process");
1007}
1008
1009std::vector<llvm::StringRef> PluginManager::GetSaveCorePluginNames() {
1010 std::vector<llvm::StringRef> plugin_names;
1011 auto instances = GetObjectFileInstances().GetSnapshot();
1012 for (auto &instance : instances) {
1013 if (instance.save_core)
1014 plugin_names.emplace_back(instance.name);
1015 }
1016 return plugin_names;
1017}
1018
1019#pragma mark ObjectContainer
1020
1037
1039 static ObjectContainerInstances g_instances;
1040 return g_instances;
1041}
1042
1044 llvm::StringRef name, llvm::StringRef description,
1045 ObjectContainerCreateInstance create_callback,
1046 ObjectFileGetModuleSpecifications get_module_specifications,
1047 ObjectContainerCreateMemoryInstance create_memory_callback) {
1049 name, description, create_callback, create_memory_callback,
1050 get_module_specifications);
1051}
1052
1054 ObjectContainerCreateInstance create_callback) {
1055 return GetObjectContainerInstances().UnregisterPlugin(create_callback);
1056}
1057
1062
1065 if (auto instance = GetObjectContainerInstances().GetInstanceAtIndex(idx))
1066 return instance->create_memory_callback;
1067 return nullptr;
1068}
1069
1072 uint32_t idx) {
1073 if (auto instance = GetObjectContainerInstances().GetInstanceAtIndex(idx))
1074 return instance->get_module_specifications;
1075 return nullptr;
1076}
1077
1078#pragma mark Platform
1079
1082
1084 static PlatformInstances g_platform_instances;
1085 return g_platform_instances;
1086}
1087
1089 llvm::StringRef name, llvm::StringRef description,
1090 PlatformCreateInstance create_callback,
1091 DebuggerInitializeCallback debugger_init_callback) {
1093 name, description, create_callback, debugger_init_callback);
1094}
1095
1097 return GetPlatformInstances().UnregisterPlugin(create_callback);
1098}
1099
1100llvm::StringRef PluginManager::GetPlatformPluginNameAtIndex(uint32_t idx) {
1102}
1103
1104llvm::StringRef
1108
1113
1118
1120 CompletionRequest &request) {
1121 for (const auto &instance : GetPlatformInstances().GetSnapshot()) {
1122 if (instance.name.starts_with(name))
1123 request.AddCompletion(instance.name);
1124 }
1125}
1126
1127#pragma mark Process
1128
1131
1133 static ProcessInstances g_instances;
1134 return g_instances;
1135}
1136
1138 llvm::StringRef name, llvm::StringRef description,
1139 ProcessCreateInstance create_callback,
1140 DebuggerInitializeCallback debugger_init_callback) {
1142 name, description, create_callback, debugger_init_callback);
1143}
1144
1146 return GetProcessInstances().UnregisterPlugin(create_callback);
1147}
1148
1149llvm::StringRef PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) {
1150 return GetProcessInstances().GetNameAtIndex(idx);
1151}
1152
1156
1161
1166
1168 CompletionRequest &request) {
1169 for (const auto &instance : GetProcessInstances().GetSnapshot()) {
1170 if (instance.name.starts_with(name))
1171 request.AddCompletion(instance.name, instance.description);
1172 }
1173}
1174
1175#pragma mark ProtocolServer
1176
1179
1181 static ProtocolServerInstances g_instances;
1182 return g_instances;
1183}
1184
1186 llvm::StringRef name, llvm::StringRef description,
1187 ProtocolServerCreateInstance create_callback) {
1188 return GetProtocolServerInstances().RegisterPlugin(name, description,
1189 create_callback);
1190}
1191
1193 ProtocolServerCreateInstance create_callback) {
1194 return GetProtocolServerInstances().UnregisterPlugin(create_callback);
1195}
1196
1197llvm::StringRef
1201
1206
1207#pragma mark RegisterTypeBuilder
1208
1210 : public PluginInstance<RegisterTypeBuilderCreateInstance> {
1215};
1216
1217typedef PluginInstances<RegisterTypeBuilderInstance>
1219
1221 static RegisterTypeBuilderInstances g_instances;
1222 return g_instances;
1223}
1224
1226 llvm::StringRef name, llvm::StringRef description,
1227 RegisterTypeBuilderCreateInstance create_callback) {
1228 return GetRegisterTypeBuilderInstances().RegisterPlugin(name, description,
1229 create_callback);
1230}
1231
1236
1239 // We assume that RegisterTypeBuilderClang is the only instance of this plugin
1240 // type and is always present.
1242 assert(instance);
1243 return instance->create_callback(target);
1244}
1245
1246#pragma mark ScriptInterpreter
1247
1259
1261
1263 static ScriptInterpreterInstances g_instances;
1264 return g_instances;
1265}
1266
1268 llvm::StringRef name, llvm::StringRef description,
1269 lldb::ScriptLanguage script_language,
1270 ScriptInterpreterCreateInstance create_callback) {
1272 name, description, create_callback, script_language);
1273}
1274
1279
1284
1287 Debugger &debugger) {
1288 const auto instances = GetScriptInterpreterInstances().GetSnapshot();
1289 ScriptInterpreterCreateInstance none_instance = nullptr;
1290 for (const auto &instance : instances) {
1291 if (instance.language == lldb::eScriptLanguageNone)
1292 none_instance = instance.create_callback;
1293
1294 if (script_lang == instance.language)
1295 return instance.create_callback(debugger);
1296 }
1297
1298 // If we didn't find one, return the ScriptInterpreter for the null language.
1299 assert(none_instance != nullptr);
1300 return none_instance(debugger);
1301}
1302
1303#pragma mark StructuredDataPlugin
1304
1318
1321
1323 static StructuredDataPluginInstances g_instances;
1324 return g_instances;
1325}
1326
1328 llvm::StringRef name, llvm::StringRef description,
1329 StructuredDataPluginCreateInstance create_callback,
1330 DebuggerInitializeCallback debugger_init_callback,
1331 StructuredDataFilterLaunchInfo filter_callback) {
1333 name, description, create_callback, debugger_init_callback,
1334 filter_callback);
1335}
1336
1341
1346
1349 uint32_t idx, bool &iteration_complete) {
1350 if (auto instance =
1351 GetStructuredDataPluginInstances().GetInstanceAtIndex(idx)) {
1352 iteration_complete = false;
1353 return instance->filter_callback;
1354 }
1355 iteration_complete = true;
1356 return nullptr;
1357}
1358
1359#pragma mark SymbolFile
1360
1363
1365 static SymbolFileInstances g_instances;
1366 return g_instances;
1367}
1368
1370 llvm::StringRef name, llvm::StringRef description,
1371 SymbolFileCreateInstance create_callback,
1372 DebuggerInitializeCallback debugger_init_callback) {
1374 name, description, create_callback, debugger_init_callback);
1375}
1376
1378 return GetSymbolFileInstances().UnregisterPlugin(create_callback);
1379}
1380
1385
1386#pragma mark SymbolVendor
1387
1390
1392 static SymbolVendorInstances g_instances;
1393 return g_instances;
1394}
1395
1396bool PluginManager::RegisterPlugin(llvm::StringRef name,
1397 llvm::StringRef description,
1398 SymbolVendorCreateInstance create_callback) {
1399 return GetSymbolVendorInstances().RegisterPlugin(name, description,
1400 create_callback);
1401}
1402
1404 SymbolVendorCreateInstance create_callback) {
1405 return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
1406}
1407
1412
1413#pragma mark SymbolLocator
1414
1438
1440 static SymbolLocatorInstances g_instances;
1441 return g_instances;
1442}
1443
1445 llvm::StringRef name, llvm::StringRef description,
1446 SymbolLocatorCreateInstance create_callback,
1447 SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
1448 SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
1449 SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file,
1450 SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle,
1451 DebuggerInitializeCallback debugger_init_callback) {
1453 name, description, create_callback, locate_executable_object_file,
1454 locate_executable_symbol_file, download_object_symbol_file,
1455 find_symbol_file_in_bundle, debugger_init_callback);
1456}
1457
1459 SymbolLocatorCreateInstance create_callback) {
1460 return GetSymbolLocatorInstances().UnregisterPlugin(create_callback);
1461}
1462
1467
1470 StatisticsMap &map) {
1471 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1472 for (auto &instance : instances) {
1473 if (instance.locate_executable_object_file) {
1474 StatsDuration time;
1475 std::optional<ModuleSpec> result;
1476 {
1477 ElapsedTime elapsed(time);
1478 result = instance.locate_executable_object_file(module_spec);
1479 }
1480 map.add(instance.name, time.get().count());
1481 if (result)
1482 return *result;
1483 }
1484 }
1485 return {};
1486}
1487
1489 const ModuleSpec &module_spec, const FileSpecList &default_search_paths,
1490 StatisticsMap &map) {
1491 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1492 for (auto &instance : instances) {
1493 if (instance.locate_executable_symbol_file) {
1494 StatsDuration time;
1495 std::optional<FileSpec> result;
1496 {
1497 ElapsedTime elapsed(time);
1498 result = instance.locate_executable_symbol_file(module_spec,
1499 default_search_paths);
1500 }
1501 map.add(instance.name, time.get().count());
1502 if (result)
1503 return *result;
1504 }
1505 }
1506 return {};
1507}
1508
1510 Status &error,
1511 bool force_lookup,
1512 bool copy_executable) {
1513 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1514 for (auto &instance : instances) {
1515 if (instance.download_object_symbol_file) {
1516 if (instance.download_object_symbol_file(module_spec, error, force_lookup,
1517 copy_executable))
1518 return true;
1519 }
1520 }
1521 return false;
1522}
1523
1525 const UUID *uuid,
1526 const ArchSpec *arch) {
1527 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1528 for (auto &instance : instances) {
1529 if (instance.find_symbol_file_in_bundle) {
1530 std::optional<FileSpec> result =
1531 instance.find_symbol_file_in_bundle(symfile_bundle, uuid, arch);
1532 if (result)
1533 return *result;
1534 }
1535 }
1536 return {};
1537}
1538
1539#pragma mark Trace
1540
1557
1559
1561 static TraceInstances g_instances;
1562 return g_instances;
1563}
1564
1566 llvm::StringRef name, llvm::StringRef description,
1567 TraceCreateInstanceFromBundle create_callback_from_bundle,
1568 TraceCreateInstanceForLiveProcess create_callback_for_live_process,
1569 llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) {
1571 name, description, create_callback_from_bundle,
1572 create_callback_for_live_process, schema, debugger_init_callback);
1573}
1574
1576 TraceCreateInstanceFromBundle create_callback_from_bundle) {
1578 create_callback_from_bundle);
1579}
1580
1582PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
1583 return GetTracePluginInstances().GetCallbackForName(plugin_name);
1584}
1585
1588 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1589 return instance->create_callback_for_live_process;
1590
1591 return nullptr;
1592}
1593
1594llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
1595 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1596 return instance->schema;
1597 return llvm::StringRef();
1598}
1599
1600llvm::StringRef PluginManager::GetTraceSchema(size_t index) {
1601 if (const TraceInstance *instance =
1602 GetTracePluginInstances().GetInstanceAtIndex(index))
1603 return instance->schema;
1604 return llvm::StringRef();
1605}
1606
1607#pragma mark TraceExporter
1608
1622
1624
1626 static TraceExporterInstances g_instances;
1627 return g_instances;
1628}
1629
1631 llvm::StringRef name, llvm::StringRef description,
1632 TraceExporterCreateInstance create_callback,
1633 ThreadTraceExportCommandCreator create_thread_trace_export_command) {
1635 name, description, create_callback, create_thread_trace_export_command);
1636}
1637
1640 return GetTraceExporterInstances().GetCallbackForName(plugin_name);
1641}
1642
1644 TraceExporterCreateInstance create_callback) {
1645 return GetTraceExporterInstances().UnregisterPlugin(create_callback);
1646}
1647
1650 if (const TraceExporterInstance *instance =
1651 GetTraceExporterInstances().GetInstanceAtIndex(index))
1652 return instance->create_thread_trace_export_command;
1653 return nullptr;
1654}
1655
1656llvm::StringRef
1660
1661#pragma mark UnwindAssembly
1662
1665
1667 static UnwindAssemblyInstances g_instances;
1668 return g_instances;
1669}
1670
1672 llvm::StringRef name, llvm::StringRef description,
1673 UnwindAssemblyCreateInstance create_callback) {
1674 return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
1675 create_callback);
1676}
1677
1679 UnwindAssemblyCreateInstance create_callback) {
1680 return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
1681}
1682
1687
1688#pragma mark MemoryHistory
1689
1692
1694 static MemoryHistoryInstances g_instances;
1695 return g_instances;
1696}
1697
1699 llvm::StringRef name, llvm::StringRef description,
1700 MemoryHistoryCreateInstance create_callback) {
1701 return GetMemoryHistoryInstances().RegisterPlugin(name, description,
1702 create_callback);
1703}
1704
1706 MemoryHistoryCreateInstance create_callback) {
1707 return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
1708}
1709
1714
1715#pragma mark InstrumentationRuntime
1716
1729
1732
1734 static InstrumentationRuntimeInstances g_instances;
1735 return g_instances;
1736}
1737
1739 llvm::StringRef name, llvm::StringRef description,
1741 InstrumentationRuntimeGetType get_type_callback) {
1743 name, description, create_callback, get_type_callback);
1744}
1745
1750
1753 if (auto instance =
1754 GetInstrumentationRuntimeInstances().GetInstanceAtIndex(idx))
1755 return instance->get_type_callback;
1756 return nullptr;
1757}
1758
1763
1764#pragma mark TypeSystem
1765
1780
1782
1784 static TypeSystemInstances g_instances;
1785 return g_instances;
1786}
1787
1789 llvm::StringRef name, llvm::StringRef description,
1790 TypeSystemCreateInstance create_callback,
1791 LanguageSet supported_languages_for_types,
1792 LanguageSet supported_languages_for_expressions) {
1794 name, description, create_callback, supported_languages_for_types,
1795 supported_languages_for_expressions);
1796}
1797
1799 return GetTypeSystemInstances().UnregisterPlugin(create_callback);
1800}
1801
1806
1808 const auto instances = GetTypeSystemInstances().GetSnapshot();
1809 LanguageSet all;
1810 for (unsigned i = 0; i < instances.size(); ++i)
1811 all.bitvector |= instances[i].supported_languages_for_types.bitvector;
1812 return all;
1813}
1814
1816 const auto instances = GetTypeSystemInstances().GetSnapshot();
1817 LanguageSet all;
1818 for (unsigned i = 0; i < instances.size(); ++i)
1819 all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
1820 return all;
1821}
1822
1823#pragma mark ScriptedInterfaces
1824
1838
1840
1842 static ScriptedInterfaceInstances g_instances;
1843 return g_instances;
1844}
1845
1847 llvm::StringRef name, llvm::StringRef description,
1848 ScriptedInterfaceCreateInstance create_callback,
1851 name, description, create_callback, language, usages);
1852}
1853
1858
1862
1863llvm::StringRef PluginManager::GetScriptedInterfaceNameAtIndex(uint32_t index) {
1865}
1866
1867llvm::StringRef
1871
1874 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
1875 return instance->language;
1877}
1878
1881 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
1882 return instance->usages;
1883 return {};
1884}
1885
1886#pragma mark REPL
1887
1896
1898
1900 static REPLInstances g_instances;
1901 return g_instances;
1902}
1903
1904bool PluginManager::RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
1905 REPLCreateInstance create_callback,
1906 LanguageSet supported_languages) {
1907 return GetREPLInstances().RegisterPlugin(name, description, create_callback,
1908 supported_languages);
1909}
1910
1912 return GetREPLInstances().UnregisterPlugin(create_callback);
1913}
1914
1918
1920 if (auto instance = GetREPLInstances().GetInstanceAtIndex(idx))
1921 return instance->supported_languages;
1922 return LanguageSet();
1923}
1924
1926 const auto instances = GetREPLInstances().GetSnapshot();
1927 LanguageSet all;
1928 for (unsigned i = 0; i < instances.size(); ++i)
1929 all.bitvector |= instances[i].supported_languages.bitvector;
1930 return all;
1931}
1932
1933#pragma mark PluginManager
1934
1949
1950// This is the preferred new way to register plugin specific settings. e.g.
1951// This will put a plugin's settings under e.g.
1952// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
1954GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_name,
1955 llvm::StringRef plugin_type_desc,
1956 bool can_create) {
1957 lldb::OptionValuePropertiesSP parent_properties_sp(
1958 debugger.GetValueProperties());
1959 if (parent_properties_sp) {
1960 static constexpr llvm::StringLiteral g_property_name("plugin");
1961
1962 OptionValuePropertiesSP plugin_properties_sp =
1963 parent_properties_sp->GetSubProperty(nullptr, g_property_name);
1964 if (!plugin_properties_sp && can_create) {
1965 plugin_properties_sp =
1966 std::make_shared<OptionValueProperties>(g_property_name);
1967 parent_properties_sp->AppendProperty(g_property_name,
1968 "Settings specify to plugins.", true,
1969 plugin_properties_sp);
1970 }
1971
1972 if (plugin_properties_sp) {
1973 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
1974 plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
1975 if (!plugin_type_properties_sp && can_create) {
1976 plugin_type_properties_sp =
1977 std::make_shared<OptionValueProperties>(plugin_type_name);
1978 plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
1979 true, plugin_type_properties_sp);
1980 }
1981 return plugin_type_properties_sp;
1982 }
1983 }
1985}
1986
1987// This is deprecated way to register plugin specific settings. e.g.
1988// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
1989// generic settings would be under "platform.SETTINGNAME".
1991 Debugger &debugger, llvm::StringRef plugin_type_name,
1992 llvm::StringRef plugin_type_desc, bool can_create) {
1993 static constexpr llvm::StringLiteral g_property_name("plugin");
1994 lldb::OptionValuePropertiesSP parent_properties_sp(
1995 debugger.GetValueProperties());
1996 if (parent_properties_sp) {
1997 OptionValuePropertiesSP plugin_properties_sp =
1998 parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
1999 if (!plugin_properties_sp && can_create) {
2000 plugin_properties_sp =
2001 std::make_shared<OptionValueProperties>(plugin_type_name);
2002 parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2003 true, plugin_properties_sp);
2004 }
2005
2006 if (plugin_properties_sp) {
2007 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2008 plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
2009 if (!plugin_type_properties_sp && can_create) {
2010 plugin_type_properties_sp =
2011 std::make_shared<OptionValueProperties>(g_property_name);
2012 plugin_properties_sp->AppendProperty(g_property_name,
2013 "Settings specific to plugins",
2014 true, plugin_type_properties_sp);
2015 }
2016 return plugin_type_properties_sp;
2017 }
2018 }
2020}
2021
2022namespace {
2023
2025GetDebuggerPropertyForPluginsPtr(Debugger &, llvm::StringRef, llvm::StringRef,
2026 bool can_create);
2027}
2028
2030GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name,
2031 llvm::StringRef plugin_type_name,
2032 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2034 lldb::OptionValuePropertiesSP properties_sp;
2035 lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property(
2036 debugger, plugin_type_name,
2037 "", // not creating to so we don't need the description
2038 false));
2039 if (plugin_type_properties_sp)
2040 properties_sp =
2041 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2042 return properties_sp;
2043}
2044
2045static bool
2046CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name,
2047 llvm::StringRef plugin_type_desc,
2048 const lldb::OptionValuePropertiesSP &properties_sp,
2049 llvm::StringRef description, bool is_global_property,
2050 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2052 if (properties_sp) {
2053 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2054 get_debugger_property(debugger, plugin_type_name, plugin_type_desc,
2055 true));
2056 if (plugin_type_properties_sp) {
2057 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2058 description, is_global_property,
2059 properties_sp);
2060 return true;
2061 }
2062 }
2063 return false;
2064}
2065
2066static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader");
2067static constexpr llvm::StringLiteral kPlatformPluginName("platform");
2068static constexpr llvm::StringLiteral kProcessPluginName("process");
2069static constexpr llvm::StringLiteral kTracePluginName("trace");
2070static constexpr llvm::StringLiteral kObjectFilePluginName("object-file");
2071static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file");
2072static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator");
2073static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader");
2074static constexpr llvm::StringLiteral
2075 kStructuredDataPluginName("structured-data");
2076static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus");
2077
2080 llvm::StringRef setting_name) {
2081 return GetSettingForPlugin(debugger, setting_name, kDynamicLoaderPluginName);
2082}
2083
2085 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2086 llvm::StringRef description, bool is_global_property) {
2088 "Settings for dynamic loader plug-ins",
2089 properties_sp, description, is_global_property);
2090}
2091
2094 llvm::StringRef setting_name) {
2095 return GetSettingForPlugin(debugger, setting_name, kPlatformPluginName,
2097}
2098
2100 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2101 llvm::StringRef description, bool is_global_property) {
2103 "Settings for platform plug-ins", properties_sp,
2104 description, is_global_property,
2106}
2107
2110 llvm::StringRef setting_name) {
2111 return GetSettingForPlugin(debugger, setting_name, kProcessPluginName);
2112}
2113
2115 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2116 llvm::StringRef description, bool is_global_property) {
2118 "Settings for process plug-ins", properties_sp,
2119 description, is_global_property);
2120}
2121
2124 llvm::StringRef setting_name) {
2125 return GetSettingForPlugin(debugger, setting_name, kSymbolLocatorPluginName);
2126}
2127
2129 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2130 llvm::StringRef description, bool is_global_property) {
2132 "Settings for symbol locator plug-ins",
2133 properties_sp, description, is_global_property);
2134}
2135
2137 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2138 llvm::StringRef description, bool is_global_property) {
2140 "Settings for trace plug-ins", properties_sp,
2141 description, is_global_property);
2142}
2143
2146 llvm::StringRef setting_name) {
2147 return GetSettingForPlugin(debugger, setting_name, kObjectFilePluginName);
2148}
2149
2151 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2152 llvm::StringRef description, bool is_global_property) {
2154 "Settings for object file plug-ins",
2155 properties_sp, description, is_global_property);
2156}
2157
2160 llvm::StringRef setting_name) {
2161 return GetSettingForPlugin(debugger, setting_name, kSymbolFilePluginName);
2162}
2163
2165 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2166 llvm::StringRef description, bool is_global_property) {
2168 "Settings for symbol file plug-ins",
2169 properties_sp, description, is_global_property);
2170}
2171
2174 llvm::StringRef setting_name) {
2175 return GetSettingForPlugin(debugger, setting_name, kJITLoaderPluginName);
2176}
2177
2179 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2180 llvm::StringRef description, bool is_global_property) {
2182 "Settings for JIT loader plug-ins",
2183 properties_sp, description, is_global_property);
2184}
2185
2186static const char *kOperatingSystemPluginName("os");
2187
2190 llvm::StringRef setting_name) {
2191 lldb::OptionValuePropertiesSP properties_sp;
2192 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2195 "", // not creating to so we don't need the description
2196 false));
2197 if (plugin_type_properties_sp)
2198 properties_sp =
2199 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2200 return properties_sp;
2201}
2202
2204 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2205 llvm::StringRef description, bool is_global_property) {
2206 if (properties_sp) {
2207 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2209 "Settings for operating system plug-ins",
2210 true));
2211 if (plugin_type_properties_sp) {
2212 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2213 description, is_global_property,
2214 properties_sp);
2215 return true;
2216 }
2217 }
2218 return false;
2219}
2220
2223 llvm::StringRef setting_name) {
2224 return GetSettingForPlugin(debugger, setting_name, kStructuredDataPluginName);
2225}
2226
2228 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2229 llvm::StringRef description, bool is_global_property) {
2231 "Settings for structured data plug-ins",
2232 properties_sp, description, is_global_property);
2233}
2234
2237 Debugger &debugger, llvm::StringRef setting_name) {
2238 return GetSettingForPlugin(debugger, setting_name, kCPlusPlusLanguagePlugin);
2239}
2240
2242 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2243 llvm::StringRef description, bool is_global_property) {
2245 "Settings for CPlusPlus language plug-ins",
2246 properties_sp, description, is_global_property);
2247}
2248
2249//
2250// Plugin Info+Enable Implementations
2251//
2252std::vector<RegisteredPluginInfo> PluginManager::GetABIPluginInfo() {
2254}
2255bool PluginManager::SetABIPluginEnabled(llvm::StringRef name, bool enable) {
2256 return GetABIInstances().SetInstanceEnabled(name, enable);
2257}
2258
2263 bool enable) {
2264 return GetArchitectureInstances().SetInstanceEnabled(name, enable);
2265}
2266
2271 bool enable) {
2272 return GetDisassemblerInstances().SetInstanceEnabled(name, enable);
2273}
2274
2279 bool enable) {
2280 return GetDynamicLoaderInstances().SetInstanceEnabled(name, enable);
2281}
2282
2283std::vector<RegisteredPluginInfo>
2288 bool enable) {
2290}
2291
2292std::vector<RegisteredPluginInfo>
2297 bool enable) {
2299}
2300
2301std::vector<RegisteredPluginInfo> PluginManager::GetJITLoaderPluginInfo() {
2303}
2305 bool enable) {
2306 return GetJITLoaderInstances().SetInstanceEnabled(name, enable);
2307}
2308
2309std::vector<RegisteredPluginInfo> PluginManager::GetLanguagePluginInfo() {
2311}
2313 bool enable) {
2314 return GetLanguageInstances().SetInstanceEnabled(name, enable);
2315}
2316
2317std::vector<RegisteredPluginInfo>
2322 bool enable) {
2323 return GetLanguageRuntimeInstances().SetInstanceEnabled(name, enable);
2324}
2325
2330 bool enable) {
2331 return GetMemoryHistoryInstances().SetInstanceEnabled(name, enable);
2332}
2333
2334std::vector<RegisteredPluginInfo>
2339 bool enable) {
2340 return GetObjectContainerInstances().SetInstanceEnabled(name, enable);
2341}
2342
2343std::vector<RegisteredPluginInfo> PluginManager::GetObjectFilePluginInfo() {
2345}
2347 bool enable) {
2348 return GetObjectFileInstances().SetInstanceEnabled(name, enable);
2349}
2350
2351std::vector<RegisteredPluginInfo>
2356 bool enable) {
2357 return GetOperatingSystemInstances().SetInstanceEnabled(name, enable);
2358}
2359
2360std::vector<RegisteredPluginInfo> PluginManager::GetPlatformPluginInfo() {
2362}
2364 bool enable) {
2365 return GetPlatformInstances().SetInstanceEnabled(name, enable);
2366}
2367
2368std::vector<RegisteredPluginInfo> PluginManager::GetProcessPluginInfo() {
2370}
2371bool PluginManager::SetProcessPluginEnabled(llvm::StringRef name, bool enable) {
2372 return GetProcessInstances().SetInstanceEnabled(name, enable);
2373}
2374
2375std::vector<RegisteredPluginInfo> PluginManager::GetREPLPluginInfo() {
2377}
2378bool PluginManager::SetREPLPluginEnabled(llvm::StringRef name, bool enable) {
2379 return GetREPLInstances().SetInstanceEnabled(name, enable);
2380}
2381
2382std::vector<RegisteredPluginInfo>
2387 bool enable) {
2389}
2390
2391std::vector<RegisteredPluginInfo>
2396 bool enable) {
2398}
2399
2400std::vector<RegisteredPluginInfo>
2405 bool enable) {
2407}
2408
2413 bool enable) {
2415}
2416
2417std::vector<RegisteredPluginInfo> PluginManager::GetSymbolFilePluginInfo() {
2419}
2421 bool enable) {
2422 return GetSymbolFileInstances().SetInstanceEnabled(name, enable);
2423}
2424
2429 bool enable) {
2430 return GetSymbolLocatorInstances().SetInstanceEnabled(name, enable);
2431}
2432
2437 bool enable) {
2438 return GetSymbolVendorInstances().SetInstanceEnabled(name, enable);
2439}
2440
2445 bool enable) {
2446 return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable);
2447}
2448
2449std::vector<RegisteredPluginInfo> PluginManager::GetTracePluginInfo() {
2451}
2452bool PluginManager::SetTracePluginEnabled(llvm::StringRef name, bool enable) {
2453 return GetTracePluginInstances().SetInstanceEnabled(name, enable);
2454}
2455
2460 bool enable) {
2461 return GetTraceExporterInstances().SetInstanceEnabled(name, enable);
2462}
2463
2464std::vector<RegisteredPluginInfo> PluginManager::GetTypeSystemPluginInfo() {
2466}
2468 bool enable) {
2469 return GetTypeSystemInstances().SetInstanceEnabled(name, enable);
2470}
2471
2476 bool enable) {
2477 return GetUnwindAssemblyInstances().SetInstanceEnabled(name, enable);
2478}
2479
2481 CompletionRequest &request) {
2482 // Split the name into the namespace and the plugin name.
2483 // If there is no dot then the ns_name will be equal to name and
2484 // plugin_prefix will be empty.
2485 llvm::StringRef ns_name, plugin_prefix;
2486 std::tie(ns_name, plugin_prefix) = name.split('.');
2487
2488 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
2489 // If the plugin namespace matches exactly then
2490 // add all the plugins in this namespace as completions if the
2491 // plugin names starts with the plugin_prefix. If the plugin_prefix
2492 // is empty then it will match all the plugins (empty string is a
2493 // prefix of everything).
2494 if (plugin_ns.name == ns_name) {
2495 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
2496 llvm::SmallString<128> buf;
2497 if (plugin.name.starts_with(plugin_prefix))
2498 request.AddCompletion(
2499 (plugin_ns.name + "." + plugin.name).toStringRef(buf));
2500 }
2501 } else if (plugin_ns.name.starts_with(name) &&
2502 !plugin_ns.get_info().empty()) {
2503 // Otherwise check if the namespace is a prefix of the full name.
2504 // Use a partial completion here so that we can either operate on the full
2505 // namespace or tab-complete to the next level.
2506 request.AddCompletion(plugin_ns.name, "", CompletionMode::Partial);
2507 }
2508 }
2509}
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:769
static DisassemblerInstances & GetDisassemblerInstances()
PluginInstances< ProtocolServerInstance > ProtocolServerInstances
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
static constexpr llvm::StringLiteral kPlatformPluginName("platform")
PluginInstance< EmulateInstructionCreateInstance > EmulateInstructionInstance
static ABIInstances & GetABIInstances()
static constexpr llvm::StringLiteral kProcessPluginName("process")
PluginInstances< SymbolVendorInstance > SymbolVendorInstances
static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader")
static lldb::OptionValuePropertiesSP GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name, llvm::StringRef plugin_type_name, GetDebuggerPropertyForPluginsPtr get_debugger_property=GetDebuggerPropertyForPlugins)
static ScriptInterpreterInstances & GetScriptInterpreterInstances()
PluginInstance< DynamicLoaderCreateInstance > DynamicLoaderInstance
PluginInstances< PlatformInstance > PlatformInstances
PluginInstance< JITLoaderCreateInstance > JITLoaderInstance
PluginInstance< ArchitectureCreateInstance > ArchitectureInstance
static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus")
PluginInstances< SystemRuntimeInstance > SystemRuntimeInstances
static TraceExporterInstances & GetTraceExporterInstances()
static void SetPluginInfo(const FileSpec &plugin_file_spec, const PluginInfo &plugin_info)
static PluginTerminateMap & GetPluginMap()
PluginInstance< LanguageCreateInstance > LanguageInstance
PluginInstance< SymbolFileCreateInstance > SymbolFileInstance
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_name, llvm::StringRef plugin_type_desc, bool can_create)
static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator")
PluginInstances< ObjectFileInstance > ObjectFileInstances
void(* PluginTermCallback)()
static StructuredDataPluginInstances & GetStructuredDataPluginInstances()
static constexpr llvm::StringLiteral kObjectFilePluginName("object-file")
PluginInstances< MemoryHistoryInstance > MemoryHistoryInstances
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(Debugger &debugger, llvm::StringRef plugin_type_name, llvm::StringRef plugin_type_desc, bool can_create)
PluginInstances< DynamicLoaderInstance > DynamicLoaderInstances
PluginInstances< LanguageInstance > LanguageInstances
PluginInstances< TraceInstance > TraceInstances
PluginInstances< ArchitectureInstance > ArchitectureInstances
PluginInstances< StructuredDataPluginInstance > StructuredDataPluginInstances
static constexpr llvm::StringLiteral kStructuredDataPluginName("structured-data")
PluginInstance< MemoryHistoryCreateInstance > MemoryHistoryInstance
static const char * kOperatingSystemPluginName("os")
static SymbolLocatorInstances & GetSymbolLocatorInstances()
PluginInstance< ProtocolServerCreateInstance > ProtocolServerInstance
PluginInstance< OperatingSystemCreateInstance > OperatingSystemInstance
static ObjectFileInstances & GetObjectFileInstances()
static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file")
PluginInstances< SymbolLocatorInstance > SymbolLocatorInstances
PluginInstance< SystemRuntimeCreateInstance > SystemRuntimeInstance
PluginInstance< SymbolVendorCreateInstance > SymbolVendorInstance
static EmulateInstructionInstances & GetEmulateInstructionInstances()
PluginInstance< UnwindAssemblyCreateInstance > UnwindAssemblyInstance
static LanguageInstances & GetLanguageInstances()
static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader")
PluginInstances< OperatingSystemInstance > OperatingSystemInstances
static LanguageRuntimeInstances & GetLanguageRuntimeInstances()
PluginInstances< LanguageRuntimeInstance > LanguageRuntimeInstances
static InstrumentationRuntimeInstances & GetInstrumentationRuntimeInstances()
PluginInstances< ProcessInstance > ProcessInstances
PluginInstances< REPLInstance > REPLInstances
static ArchitectureInstances & GetArchitectureInstances()
static RegisterTypeBuilderInstances & GetRegisterTypeBuilderInstances()
static std::recursive_mutex & GetPluginMapMutex()
static TypeSystemInstances & GetTypeSystemInstances()
static PlatformInstances & GetPlatformInstances()
static ScriptedInterfaceInstances & GetScriptedInterfaceInstances()
static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path)
PluginInstances< EmulateInstructionInstance > EmulateInstructionInstances
static JITLoaderInstances & GetJITLoaderInstances()
PluginInstances< DisassemblerInstance > DisassemblerInstances
PluginInstance< ProcessCreateInstance > ProcessInstance
static UnwindAssemblyInstances & GetUnwindAssemblyInstances()
PluginInstances< ScriptedInterfaceInstance > ScriptedInterfaceInstances
PluginInstances< UnwindAssemblyInstance > UnwindAssemblyInstances
static SymbolFileInstances & GetSymbolFileInstances()
static bool CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name, llvm::StringRef plugin_type_desc, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property, GetDebuggerPropertyForPluginsPtr get_debugger_property=GetDebuggerPropertyForPlugins)
PluginInstances< ABIInstance > ABIInstances
static FPtrTy CastToFPtr(void *VPtr)
static ProcessInstances & GetProcessInstances()
static bool PluginIsLoaded(const FileSpec &plugin_file_spec)
static OperatingSystemInstances & GetOperatingSystemInstances()
static constexpr llvm::StringLiteral kTracePluginName("trace")
PluginInstances< ScriptInterpreterInstance > ScriptInterpreterInstances
bool(* PluginInitCallback)()
PluginInstance< DisassemblerCreateInstance > DisassemblerInstance
static SymbolVendorInstances & GetSymbolVendorInstances()
PluginInstances< ObjectContainerInstance > ObjectContainerInstances
static ProtocolServerInstances & GetProtocolServerInstances()
PluginInstances< RegisterTypeBuilderInstance > RegisterTypeBuilderInstances
static REPLInstances & GetREPLInstances()
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
bool UnregisterPlugin(typename Instance::CallbackType callback)
llvm::StringRef GetNameAtIndex(uint32_t idx)
Instance::CallbackType GetCallbackAtIndex(uint32_t idx)
const ABIInstance * GetInstanceAtIndex(uint32_t idx)
llvm::StringRef GetDescriptionAtIndex(uint32_t idx)
Instance::CallbackType GetCallbackForName(llvm::StringRef name)
const ABIInstance * FindEnabledInstance(std::function< bool(const ABIInstance &)> predicate) const
bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, typename Instance::CallbackType callback, Args &&...args)
std::vector< ABIInstance > m_instances
std::vector< Instance > GetSnapshot()
const ABIInstance * GetInstanceForName(llvm::StringRef name)
std::vector< RegisteredPluginInfo > GetPluginInfoForAllInstances()
void PerformDebuggerCallback(Debugger &debugger)
bool SetInstanceEnabled(llvm::StringRef name, bool enable)
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 class to manage flag bits.
Definition Debugger.h:80
A class that measures elapsed time in an exception safe way.
Definition Statistics.h:76
A file collection class.
A file utility class.
Definition FileSpec.h:57
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
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:181
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
Definition FileSystem.h:178
static FileSystem & Instance()
static bool SetArchitecturePluginEnabled(llvm::StringRef name, bool enable)
static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx)
static bool SetPlatformPluginEnabled(llvm::StringRef name, bool enable)
static bool SetScriptInterpreterPluginEnabled(llvm::StringRef name, bool enable)
static bool MatchPluginName(llvm::StringRef pattern, const PluginNamespace &plugin_ns, const RegisteredPluginInfo &plugin)
static lldb::OptionValuePropertiesSP GetSettingForStructuredDataPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool SetMemoryHistoryPluginEnabled(llvm::StringRef name, bool enable)
static std::vector< RegisteredPluginInfo > GetSystemRuntimePluginInfo()
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 ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx)
static bool SetRegisterTypeBuilderPluginEnabled(llvm::StringRef name, bool enable)
static bool SetTraceExporterPluginEnabled(llvm::StringRef name, bool enable)
static JITLoaderCreateInstance GetJITLoaderCreateCallbackAtIndex(uint32_t idx)
static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx)
static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions()
static bool SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, bool enable)
static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static lldb::OptionValuePropertiesSP GetSettingForObjectFilePlugin(Debugger &debugger, llvm::StringRef setting_name)
static void AutoCompletePlatformName(llvm::StringRef partial_name, CompletionRequest &request)
static TraceExporterCreateInstance GetTraceExporterCreateCallback(llvm::StringRef plugin_name)
static bool SetDynamicLoaderPluginEnabled(llvm::StringRef name, bool enable)
static llvm::json::Object GetJSON(llvm::StringRef pattern="")
static bool CreateSettingForObjectFilePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool SetScriptedInterfacePluginEnabled(llvm::StringRef name, bool enable)
static bool SetOperatingSystemPluginEnabled(llvm::StringRef name, bool enable)
static lldb::ScriptInterpreterSP GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, Debugger &debugger)
static 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 std::vector< RegisteredPluginInfo > GetMemoryHistoryPluginInfo()
static std::vector< RegisteredPluginInfo > GetLanguagePluginInfo()
static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx)
static bool CreateSettingForTracePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static std::vector< RegisteredPluginInfo > GetTraceExporterPluginInfo()
static UnwindAssemblyCreateInstance GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx)
static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
static std::vector< RegisteredPluginInfo > GetLanguageRuntimePluginInfo()
static SymbolFileCreateInstance GetSymbolFileCreateCallbackAtIndex(uint32_t idx)
static bool SetLanguageRuntimePluginEnabled(llvm::StringRef name, bool enable)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t idx)
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 std::vector< RegisteredPluginInfo > GetSymbolLocatorPluginInfo()
static std::vector< RegisteredPluginInfo > GetSymbolVendorPluginInfo()
static SymbolLocatorCreateInstance GetSymbolLocatorCreateCallbackAtIndex(uint32_t idx)
static bool SetUnwindAssemblyPluginEnabled(llvm::StringRef name, bool enable)
static lldb::OptionValuePropertiesSP GetSettingForCPlusPlusLanguagePlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool SetDisassemblerPluginEnabled(llvm::StringRef name, bool enable)
static bool SetSystemRuntimePluginEnabled(llvm::StringRef name, bool enable)
static TraceCreateInstanceForLiveProcess GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name)
static LanguageRuntimeCreateInstance GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx)
static std::vector< RegisteredPluginInfo > GetObjectFilePluginInfo()
static std::unique_ptr< Architecture > CreateArchitectureInstance(const ArchSpec &arch)
static SystemRuntimeCreateInstance GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx)
static std::vector< RegisteredPluginInfo > GetArchitecturePluginInfo()
static lldb::OptionValuePropertiesSP GetSettingForSymbolLocatorPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool SetStructuredDataPluginEnabled(llvm::StringRef name, bool enable)
static uint32_t GetNumScriptedInterfaces()
static bool SetObjectContainerPluginEnabled(llvm::StringRef name, bool enable)
static bool CreateSettingForProcessPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static SymbolVendorCreateInstance GetSymbolVendorCreateCallbackAtIndex(uint32_t idx)
static LanguageRuntimeGetCommandObject GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx)
static OperatingSystemCreateInstance GetOperatingSystemCreateCallbackAtIndex(uint32_t idx)
static std::vector< RegisteredPluginInfo > GetJITLoaderPluginInfo()
static std::vector< RegisteredPluginInfo > GetREPLPluginInfo()
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, llvm::StringRef setting_name)
static LanguageRuntimeGetExceptionPrecondition GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx)
static std::vector< RegisteredPluginInfo > GetOperatingSystemPluginInfo()
static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx)
static ObjectFileCreateMemoryInstance GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx)
static llvm::ArrayRef< PluginNamespace > GetPluginNamespaces()
static bool SetTypeSystemPluginEnabled(llvm::StringRef name, bool enable)
static bool SetTracePluginEnabled(llvm::StringRef name, bool enable)
static Status SaveCore(lldb_private::SaveCoreOptions &core_options)
static std::vector< RegisteredPluginInfo > GetStructuredDataPluginInfo()
static std::vector< RegisteredPluginInfo > GetPlatformPluginInfo()
static std::vector< RegisteredPluginInfo > GetTypeSystemPluginInfo()
static std::vector< RegisteredPluginInfo > GetObjectContainerPluginInfo()
static std::vector< RegisteredPluginInfo > GetTracePluginInfo()
static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec, const FileSpecList &default_search_paths, StatisticsMap &map)
static bool SetEmulateInstructionPluginEnabled(llvm::StringRef name, bool enable)
static lldb::OptionValuePropertiesSP GetSettingForJITLoaderPlugin(Debugger &debugger, llvm::StringRef setting_name)
static DisassemblerCreateInstance GetDisassemblerCreateCallbackForPluginName(llvm::StringRef name)
static bool SetJITLoaderPluginEnabled(llvm::StringRef name, bool enable)
static 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 std::vector< RegisteredPluginInfo > GetScriptInterpreterPluginInfo()
static bool SetSymbolFilePluginEnabled(llvm::StringRef name, bool enable)
static EmulateInstructionCreateInstance GetEmulateInstructionCreateCallbackForPluginName(llvm::StringRef name)
static lldb::OptionValuePropertiesSP GetSettingForSymbolFilePlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForStructuredDataPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static std::vector< RegisteredPluginInfo > GetProcessPluginInfo()
static bool CreateSettingForCPlusPlusLanguagePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static DynamicLoaderCreateInstance GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx)
static std::vector< llvm::StringRef > GetSaveCorePluginNames()
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 bool SetProcessPluginEnabled(llvm::StringRef name, bool enable)
static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx)
static bool SetABIPluginEnabled(llvm::StringRef name, bool enable)
static std::vector< RegisteredPluginInfo > GetRegisterTypeBuilderPluginInfo()
static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin(Debugger &debugger, llvm::StringRef setting_name)
static std::vector< RegisteredPluginInfo > GetScriptedInterfacePluginInfo()
static std::vector< RegisteredPluginInfo > GetUnwindAssemblyPluginInfo()
static ProcessCreateInstance GetProcessCreateCallbackForPluginName(llvm::StringRef name)
static void AutoCompletePluginName(llvm::StringRef partial_name, CompletionRequest &request)
static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx)
static llvm::StringRef GetProcessPluginDescriptionAtIndex(uint32_t idx)
static llvm::StringRef GetProtocolServerPluginNameAtIndex(uint32_t idx)
static bool IsRegisteredObjectFilePluginName(llvm::StringRef name)
static lldb::OptionValuePropertiesSP GetSettingForDynamicLoaderPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForDynamicLoaderPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool SetLanguagePluginEnabled(llvm::StringRef name, bool enable)
static bool SetREPLPluginEnabled(llvm::StringRef name, bool enable)
static StructuredDataPluginCreateInstance GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx)
static ObjectFileGetModuleSpecifications GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx)
static std::vector< RegisteredPluginInfo > GetABIPluginInfo()
static std::vector< RegisteredPluginInfo > GetSymbolFilePluginInfo()
static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx)
static bool SetSymbolVendorPluginEnabled(llvm::StringRef name, bool enable)
static TraceCreateInstanceFromBundle GetTraceCreateCallback(llvm::StringRef plugin_name)
static std::vector< RegisteredPluginInfo > GetDynamicLoaderPluginInfo()
static void DebuggerInitialize(Debugger &debugger)
static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx)
static llvm::StringRef GetProcessPluginNameAtIndex(uint32_t idx)
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec, StatisticsMap &map)
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes()
static bool UnregisterPlugin(ABICreateInstance create_callback)
static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
static bool SetSymbolLocatorPluginEnabled(llvm::StringRef name, bool enable)
static ProtocolServerCreateInstance GetProtocolCreateCallbackForPluginName(llvm::StringRef name)
static std::vector< RegisteredPluginInfo > GetDisassemblerPluginInfo()
static std::vector< RegisteredPluginInfo > GetInstrumentationRuntimePluginInfo()
static ObjectContainerCreateMemoryInstance GetObjectContainerCreateMemoryCallbackAtIndex(uint32_t idx)
static StructuredDataFilterLaunchInfo GetStructuredDataFilterCallbackAtIndex(uint32_t idx, bool &iteration_complete)
static InstrumentationRuntimeCreateInstance GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx)
static std::vector< RegisteredPluginInfo > GetEmulateInstructionPluginInfo()
static LanguageSet GetREPLSupportedLanguagesAtIndex(uint32_t idx)
static lldb::RegisterTypeBuilderSP GetRegisterTypeBuilder(Target &target)
static ScriptedInterfaceUsages GetScriptedInterfaceUsagesAtIndex(uint32_t idx)
static ObjectFileCreateMemoryInstance GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name)
static bool CreateSettingForSymbolLocatorPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static EmulateInstructionCreateInstance GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx)
static bool SetObjectFilePluginEnabled(llvm::StringRef name, bool enable)
lldb::OptionValuePropertiesSP GetValueProperties() const
const std::optional< lldb_private::FileSpec > GetOutputFile() const
std::optional< std::string > GetPluginName() const
A class to count time for plugins.
Definition Statistics.h:94
void add(llvm::StringRef key, double value)
Definition Statistics.h:96
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:137
Represents UUID's of various sizes.
Definition UUID.h:27
A class that represents a running process on the host machine.
SymbolVendor *(* SymbolVendorCreateInstance)(const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm)
bool(* ObjectFileSaveCore)(const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &options, Status &error)
llvm::Expected< lldb::TraceSP >(* TraceCreateInstanceForLiveProcess)(Process &process)
lldb::RegisterTypeBuilderSP(* RegisterTypeBuilderCreateInstance)(Target &target)
lldb::ProtocolServerUP(* ProtocolServerCreateInstance)()
LanguageRuntime *(* LanguageRuntimeCreateInstance)(Process *process, lldb::LanguageType language)
lldb::InstrumentationRuntimeType(* InstrumentationRuntimeGetType)()
llvm::Expected< lldb::TraceSP >(* TraceCreateInstanceFromBundle)(const llvm::json::Value &trace_bundle_description, llvm::StringRef session_file_dir, lldb_private::Debugger &debugger)
Trace.
lldb::DisassemblerSP(* DisassemblerCreateInstance)(const ArchSpec &arch, const char *flavor, const char *cpu, const char *features)
std::optional< FileSpec >(* SymbolLocatorLocateExecutableSymbolFile)(const ModuleSpec &module_spec, const FileSpecList &default_search_paths)
EmulateInstruction *(* EmulateInstructionCreateInstance)(const ArchSpec &arch, InstructionType inst_type)
ObjectContainer *(* ObjectContainerCreateMemoryInstance)(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset)
size_t(* ObjectFileGetModuleSpecifications)(const FileSpec &file, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, ModuleSpecList &module_specs)
void(* DebuggerInitializeCallback)(Debugger &debugger)
std::unique_ptr< Architecture >(* ArchitectureCreateInstance)(const ArchSpec &arch)
lldb::ScriptInterpreterSP(* ScriptInterpreterCreateInstance)(Debugger &debugger)
lldb::PlatformSP(* PlatformCreateInstance)(bool force, const ArchSpec *arch)
bool(* ScriptedInterfaceCreateInstance)(lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
SystemRuntime *(* SystemRuntimeCreateInstance)(Process *process)
lldb::ProcessSP(* ProcessCreateInstance)(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
UnwindAssembly *(* UnwindAssemblyCreateInstance)(const ArchSpec &arch)
lldb::TypeSystemSP(* TypeSystemCreateInstance)(lldb::LanguageType language, Module *module, Target *target)
lldb::BreakpointPreconditionSP(* LanguageRuntimeGetExceptionPrecondition)(lldb::LanguageType language, bool throw_bp)
ObjectContainer *(* ObjectContainerCreateInstance)(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
lldb::MemoryHistorySP(* MemoryHistoryCreateInstance)(const lldb::ProcessSP &process_sp)
ObjectFile *(* ObjectFileCreateMemoryInstance)(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset)
SymbolLocator *(* SymbolLocatorCreateInstance)()
std::optional< ModuleSpec >(* SymbolLocatorLocateExecutableObjectFile)(const ModuleSpec &module_spec)
@ Partial
The current token has been partially completed.
lldb::CommandObjectSP(* LanguageRuntimeGetCommandObject)(CommandInterpreter &interpreter)
ObjectFile *(* ObjectFileCreateInstance)(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
DynamicLoader *(* DynamicLoaderCreateInstance)(Process *process, bool force)
lldb::StructuredDataPluginSP(* StructuredDataPluginCreateInstance)(Process &process)
lldb::JITLoaderSP(* JITLoaderCreateInstance)(Process *process, bool force)
OperatingSystem *(* OperatingSystemCreateInstance)(Process *process, bool force)
lldb::REPLSP(* REPLCreateInstance)(Status &error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
SymbolFile *(* SymbolFileCreateInstance)(lldb::ObjectFileSP objfile_sp)
llvm::Expected< lldb::TraceExporterUP >(* TraceExporterCreateInstance)()
std::optional< FileSpec >(* SymbolLocatorFindSymbolFileInBundle)(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
bool(* SymbolLocatorDownloadObjectAndSymbolFile)(ModuleSpec &module_spec, Status &error, bool force_lookup, bool copy_executable)
Language *(* LanguageCreateInstance)(lldb::LanguageType language)
Status(* StructuredDataFilterLaunchInfo)(ProcessLaunchInfo &launch_info, Target *target)
lldb::ABISP(* ABICreateInstance)(lldb::ProcessSP process_sp, const ArchSpec &arch)
lldb::CommandObjectSP(* ThreadTraceExportCommandCreator)(CommandInterpreter &interpreter)
lldb::InstrumentationRuntimeSP(* InstrumentationRuntimeCreateInstance)(const lldb::ProcessSP &process_sp)
ScriptLanguage
Script interpreter types.
@ eScriptLanguageNone
std::shared_ptr< lldb_private::OptionValueProperties > OptionValuePropertiesSP
std::shared_ptr< lldb_private::ScriptInterpreter > ScriptInterpreterSP
std::shared_ptr< lldb_private::RegisterTypeBuilder > RegisterTypeBuilderSP
InstrumentationRuntimeGetType get_type_callback
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
DebuggerInitializeCallback debugger_init_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)
lldb::ScriptLanguage language
ScriptInterpreterInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, lldb::ScriptLanguage language)
ScriptedInterfaceUsages usages
lldb::ScriptLanguage language
ScriptedInterfaceInstance(llvm::StringRef name, llvm::StringRef description, ScriptedInterfaceCreateInstance create_callback, lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
StructuredDataPluginInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, DebuggerInitializeCallback debugger_init_callback, StructuredDataFilterLaunchInfo filter_callback)
StructuredDataFilterLaunchInfo filter_callback
SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle
SymbolLocatorInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback, SymbolLocatorLocateExecutableObjectFile locate_executable_object_file, SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file, SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file, SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle, DebuggerInitializeCallback debugger_init_callback)
SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file
SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file
SymbolLocatorLocateExecutableObjectFile locate_executable_object_file
ThreadTraceExportCommandCreator create_thread_trace_export_command
TraceExporterInstance(llvm::StringRef name, llvm::StringRef description, TraceExporterCreateInstance create_instance, ThreadTraceExportCommandCreator create_thread_trace_export_command)
llvm::StringRef schema
TraceInstance(llvm::StringRef name, llvm::StringRef description, CallbackType create_callback_from_bundle, TraceCreateInstanceForLiveProcess create_callback_for_live_process, llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback)
TraceCreateInstanceForLiveProcess create_callback_for_live_process
LanguageSet supported_languages_for_expressions
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 Type.h:38
llvm::SmallBitVector bitvector
Definition Type.h:39
#define PATH_MAX