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 SyntheticFrameProvider
1304
1313
1315 static SyntheticFrameProviderInstances g_instances;
1316 return g_instances;
1317}
1318
1320 static ScriptedFrameProviderInstances g_instances;
1321 return g_instances;
1322}
1323
1325 llvm::StringRef name, llvm::StringRef description,
1326 SyntheticFrameProviderCreateInstance create_native_callback,
1327 ScriptedFrameProviderCreateInstance create_scripted_callback) {
1328 if (create_native_callback)
1330 name, description, create_native_callback);
1331 else if (create_scripted_callback)
1333 name, description, create_scripted_callback);
1334 return false;
1335}
1336
1341
1346
1352
1357
1358#pragma mark StructuredDataPlugin
1359
1373
1376
1378 static StructuredDataPluginInstances g_instances;
1379 return g_instances;
1380}
1381
1383 llvm::StringRef name, llvm::StringRef description,
1384 StructuredDataPluginCreateInstance create_callback,
1385 DebuggerInitializeCallback debugger_init_callback,
1386 StructuredDataFilterLaunchInfo filter_callback) {
1388 name, description, create_callback, debugger_init_callback,
1389 filter_callback);
1390}
1391
1396
1401
1404 uint32_t idx, bool &iteration_complete) {
1405 if (auto instance =
1406 GetStructuredDataPluginInstances().GetInstanceAtIndex(idx)) {
1407 iteration_complete = false;
1408 return instance->filter_callback;
1409 }
1410 iteration_complete = true;
1411 return nullptr;
1412}
1413
1414#pragma mark SymbolFile
1415
1418
1420 static SymbolFileInstances g_instances;
1421 return g_instances;
1422}
1423
1425 llvm::StringRef name, llvm::StringRef description,
1426 SymbolFileCreateInstance create_callback,
1427 DebuggerInitializeCallback debugger_init_callback) {
1429 name, description, create_callback, debugger_init_callback);
1430}
1431
1433 return GetSymbolFileInstances().UnregisterPlugin(create_callback);
1434}
1435
1440
1441#pragma mark SymbolVendor
1442
1445
1447 static SymbolVendorInstances g_instances;
1448 return g_instances;
1449}
1450
1451bool PluginManager::RegisterPlugin(llvm::StringRef name,
1452 llvm::StringRef description,
1453 SymbolVendorCreateInstance create_callback) {
1454 return GetSymbolVendorInstances().RegisterPlugin(name, description,
1455 create_callback);
1456}
1457
1459 SymbolVendorCreateInstance create_callback) {
1460 return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
1461}
1462
1467
1468#pragma mark SymbolLocator
1469
1493
1495 static SymbolLocatorInstances g_instances;
1496 return g_instances;
1497}
1498
1500 llvm::StringRef name, llvm::StringRef description,
1501 SymbolLocatorCreateInstance create_callback,
1502 SymbolLocatorLocateExecutableObjectFile locate_executable_object_file,
1503 SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file,
1504 SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file,
1505 SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle,
1506 DebuggerInitializeCallback debugger_init_callback) {
1508 name, description, create_callback, locate_executable_object_file,
1509 locate_executable_symbol_file, download_object_symbol_file,
1510 find_symbol_file_in_bundle, debugger_init_callback);
1511}
1512
1514 SymbolLocatorCreateInstance create_callback) {
1515 return GetSymbolLocatorInstances().UnregisterPlugin(create_callback);
1516}
1517
1522
1525 StatisticsMap &map) {
1526 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1527 for (auto &instance : instances) {
1528 if (instance.locate_executable_object_file) {
1529 StatsDuration time;
1530 std::optional<ModuleSpec> result;
1531 {
1532 ElapsedTime elapsed(time);
1533 result = instance.locate_executable_object_file(module_spec);
1534 }
1535 map.add(instance.name, time.get().count());
1536 if (result)
1537 return *result;
1538 }
1539 }
1540 return {};
1541}
1542
1544 const ModuleSpec &module_spec, const FileSpecList &default_search_paths,
1545 StatisticsMap &map) {
1546 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1547 for (auto &instance : instances) {
1548 if (instance.locate_executable_symbol_file) {
1549 StatsDuration time;
1550 std::optional<FileSpec> result;
1551 {
1552 ElapsedTime elapsed(time);
1553 result = instance.locate_executable_symbol_file(module_spec,
1554 default_search_paths);
1555 }
1556 map.add(instance.name, time.get().count());
1557 if (result)
1558 return *result;
1559 }
1560 }
1561 return {};
1562}
1563
1565 Status &error,
1566 bool force_lookup,
1567 bool copy_executable) {
1568 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1569 for (auto &instance : instances) {
1570 if (instance.download_object_symbol_file) {
1571 if (instance.download_object_symbol_file(module_spec, error, force_lookup,
1572 copy_executable))
1573 return true;
1574 }
1575 }
1576 return false;
1577}
1578
1580 const UUID *uuid,
1581 const ArchSpec *arch) {
1582 auto instances = GetSymbolLocatorInstances().GetSnapshot();
1583 for (auto &instance : instances) {
1584 if (instance.find_symbol_file_in_bundle) {
1585 std::optional<FileSpec> result =
1586 instance.find_symbol_file_in_bundle(symfile_bundle, uuid, arch);
1587 if (result)
1588 return *result;
1589 }
1590 }
1591 return {};
1592}
1593
1594#pragma mark Trace
1595
1612
1614
1616 static TraceInstances g_instances;
1617 return g_instances;
1618}
1619
1621 llvm::StringRef name, llvm::StringRef description,
1622 TraceCreateInstanceFromBundle create_callback_from_bundle,
1623 TraceCreateInstanceForLiveProcess create_callback_for_live_process,
1624 llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) {
1626 name, description, create_callback_from_bundle,
1627 create_callback_for_live_process, schema, debugger_init_callback);
1628}
1629
1631 TraceCreateInstanceFromBundle create_callback_from_bundle) {
1633 create_callback_from_bundle);
1634}
1635
1637PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
1638 return GetTracePluginInstances().GetCallbackForName(plugin_name);
1639}
1640
1643 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1644 return instance->create_callback_for_live_process;
1645
1646 return nullptr;
1647}
1648
1649llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
1650 if (auto instance = GetTracePluginInstances().GetInstanceForName(plugin_name))
1651 return instance->schema;
1652 return llvm::StringRef();
1653}
1654
1655llvm::StringRef PluginManager::GetTraceSchema(size_t index) {
1656 if (const TraceInstance *instance =
1657 GetTracePluginInstances().GetInstanceAtIndex(index))
1658 return instance->schema;
1659 return llvm::StringRef();
1660}
1661
1662#pragma mark TraceExporter
1663
1677
1679
1681 static TraceExporterInstances g_instances;
1682 return g_instances;
1683}
1684
1686 llvm::StringRef name, llvm::StringRef description,
1687 TraceExporterCreateInstance create_callback,
1688 ThreadTraceExportCommandCreator create_thread_trace_export_command) {
1690 name, description, create_callback, create_thread_trace_export_command);
1691}
1692
1695 return GetTraceExporterInstances().GetCallbackForName(plugin_name);
1696}
1697
1699 TraceExporterCreateInstance create_callback) {
1700 return GetTraceExporterInstances().UnregisterPlugin(create_callback);
1701}
1702
1705 if (const TraceExporterInstance *instance =
1706 GetTraceExporterInstances().GetInstanceAtIndex(index))
1707 return instance->create_thread_trace_export_command;
1708 return nullptr;
1709}
1710
1711llvm::StringRef
1715
1716#pragma mark UnwindAssembly
1717
1720
1722 static UnwindAssemblyInstances g_instances;
1723 return g_instances;
1724}
1725
1727 llvm::StringRef name, llvm::StringRef description,
1728 UnwindAssemblyCreateInstance create_callback) {
1729 return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
1730 create_callback);
1731}
1732
1734 UnwindAssemblyCreateInstance create_callback) {
1735 return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
1736}
1737
1742
1743#pragma mark MemoryHistory
1744
1747
1749 static MemoryHistoryInstances g_instances;
1750 return g_instances;
1751}
1752
1754 llvm::StringRef name, llvm::StringRef description,
1755 MemoryHistoryCreateInstance create_callback) {
1756 return GetMemoryHistoryInstances().RegisterPlugin(name, description,
1757 create_callback);
1758}
1759
1761 MemoryHistoryCreateInstance create_callback) {
1762 return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
1763}
1764
1769
1770#pragma mark InstrumentationRuntime
1771
1784
1787
1789 static InstrumentationRuntimeInstances g_instances;
1790 return g_instances;
1791}
1792
1794 llvm::StringRef name, llvm::StringRef description,
1796 InstrumentationRuntimeGetType get_type_callback) {
1798 name, description, create_callback, get_type_callback);
1799}
1800
1805
1808 if (auto instance =
1809 GetInstrumentationRuntimeInstances().GetInstanceAtIndex(idx))
1810 return instance->get_type_callback;
1811 return nullptr;
1812}
1813
1818
1819#pragma mark TypeSystem
1820
1835
1837
1839 static TypeSystemInstances g_instances;
1840 return g_instances;
1841}
1842
1844 llvm::StringRef name, llvm::StringRef description,
1845 TypeSystemCreateInstance create_callback,
1846 LanguageSet supported_languages_for_types,
1847 LanguageSet supported_languages_for_expressions) {
1849 name, description, create_callback, supported_languages_for_types,
1850 supported_languages_for_expressions);
1851}
1852
1854 return GetTypeSystemInstances().UnregisterPlugin(create_callback);
1855}
1856
1861
1863 const auto instances = GetTypeSystemInstances().GetSnapshot();
1864 LanguageSet all;
1865 for (unsigned i = 0; i < instances.size(); ++i)
1866 all.bitvector |= instances[i].supported_languages_for_types.bitvector;
1867 return all;
1868}
1869
1871 const auto instances = GetTypeSystemInstances().GetSnapshot();
1872 LanguageSet all;
1873 for (unsigned i = 0; i < instances.size(); ++i)
1874 all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
1875 return all;
1876}
1877
1878#pragma mark ScriptedInterfaces
1879
1893
1895
1897 static ScriptedInterfaceInstances g_instances;
1898 return g_instances;
1899}
1900
1902 llvm::StringRef name, llvm::StringRef description,
1903 ScriptedInterfaceCreateInstance create_callback,
1906 name, description, create_callback, language, usages);
1907}
1908
1913
1917
1918llvm::StringRef PluginManager::GetScriptedInterfaceNameAtIndex(uint32_t index) {
1920}
1921
1922llvm::StringRef
1926
1929 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
1930 return instance->language;
1932}
1933
1936 if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx))
1937 return instance->usages;
1938 return {};
1939}
1940
1941#pragma mark REPL
1942
1951
1953
1955 static REPLInstances g_instances;
1956 return g_instances;
1957}
1958
1959bool PluginManager::RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
1960 REPLCreateInstance create_callback,
1961 LanguageSet supported_languages) {
1962 return GetREPLInstances().RegisterPlugin(name, description, create_callback,
1963 supported_languages);
1964}
1965
1967 return GetREPLInstances().UnregisterPlugin(create_callback);
1968}
1969
1973
1975 if (auto instance = GetREPLInstances().GetInstanceAtIndex(idx))
1976 return instance->supported_languages;
1977 return LanguageSet();
1978}
1979
1981 const auto instances = GetREPLInstances().GetSnapshot();
1982 LanguageSet all;
1983 for (unsigned i = 0; i < instances.size(); ++i)
1984 all.bitvector |= instances[i].supported_languages.bitvector;
1985 return all;
1986}
1987
1988#pragma mark PluginManager
1989
2004
2005// This is the preferred new way to register plugin specific settings. e.g.
2006// This will put a plugin's settings under e.g.
2007// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
2009GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_name,
2010 llvm::StringRef plugin_type_desc,
2011 bool can_create) {
2012 lldb::OptionValuePropertiesSP parent_properties_sp(
2013 debugger.GetValueProperties());
2014 if (parent_properties_sp) {
2015 static constexpr llvm::StringLiteral g_property_name("plugin");
2016
2017 OptionValuePropertiesSP plugin_properties_sp =
2018 parent_properties_sp->GetSubProperty(nullptr, g_property_name);
2019 if (!plugin_properties_sp && can_create) {
2020 plugin_properties_sp =
2021 std::make_shared<OptionValueProperties>(g_property_name);
2022 parent_properties_sp->AppendProperty(g_property_name,
2023 "Settings specify to plugins.", true,
2024 plugin_properties_sp);
2025 }
2026
2027 if (plugin_properties_sp) {
2028 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2029 plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2030 if (!plugin_type_properties_sp && can_create) {
2031 plugin_type_properties_sp =
2032 std::make_shared<OptionValueProperties>(plugin_type_name);
2033 plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2034 true, plugin_type_properties_sp);
2035 }
2036 return plugin_type_properties_sp;
2037 }
2038 }
2040}
2041
2042// This is deprecated way to register plugin specific settings. e.g.
2043// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
2044// generic settings would be under "platform.SETTINGNAME".
2046 Debugger &debugger, llvm::StringRef plugin_type_name,
2047 llvm::StringRef plugin_type_desc, bool can_create) {
2048 static constexpr llvm::StringLiteral g_property_name("plugin");
2049 lldb::OptionValuePropertiesSP parent_properties_sp(
2050 debugger.GetValueProperties());
2051 if (parent_properties_sp) {
2052 OptionValuePropertiesSP plugin_properties_sp =
2053 parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
2054 if (!plugin_properties_sp && can_create) {
2055 plugin_properties_sp =
2056 std::make_shared<OptionValueProperties>(plugin_type_name);
2057 parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
2058 true, plugin_properties_sp);
2059 }
2060
2061 if (plugin_properties_sp) {
2062 lldb::OptionValuePropertiesSP plugin_type_properties_sp =
2063 plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
2064 if (!plugin_type_properties_sp && can_create) {
2065 plugin_type_properties_sp =
2066 std::make_shared<OptionValueProperties>(g_property_name);
2067 plugin_properties_sp->AppendProperty(g_property_name,
2068 "Settings specific to plugins",
2069 true, plugin_type_properties_sp);
2070 }
2071 return plugin_type_properties_sp;
2072 }
2073 }
2075}
2076
2077namespace {
2078
2080GetDebuggerPropertyForPluginsPtr(Debugger &, llvm::StringRef, llvm::StringRef,
2081 bool can_create);
2082}
2083
2085GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name,
2086 llvm::StringRef plugin_type_name,
2087 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2089 lldb::OptionValuePropertiesSP properties_sp;
2090 lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property(
2091 debugger, plugin_type_name,
2092 "", // not creating to so we don't need the description
2093 false));
2094 if (plugin_type_properties_sp)
2095 properties_sp =
2096 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2097 return properties_sp;
2098}
2099
2100static bool
2101CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name,
2102 llvm::StringRef plugin_type_desc,
2103 const lldb::OptionValuePropertiesSP &properties_sp,
2104 llvm::StringRef description, bool is_global_property,
2105 GetDebuggerPropertyForPluginsPtr get_debugger_property =
2107 if (properties_sp) {
2108 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2109 get_debugger_property(debugger, plugin_type_name, plugin_type_desc,
2110 true));
2111 if (plugin_type_properties_sp) {
2112 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2113 description, is_global_property,
2114 properties_sp);
2115 return true;
2116 }
2117 }
2118 return false;
2119}
2120
2121static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader");
2122static constexpr llvm::StringLiteral kPlatformPluginName("platform");
2123static constexpr llvm::StringLiteral kProcessPluginName("process");
2124static constexpr llvm::StringLiteral kTracePluginName("trace");
2125static constexpr llvm::StringLiteral kObjectFilePluginName("object-file");
2126static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file");
2127static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator");
2128static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader");
2129static constexpr llvm::StringLiteral
2130 kStructuredDataPluginName("structured-data");
2131static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus");
2132
2135 llvm::StringRef setting_name) {
2136 return GetSettingForPlugin(debugger, setting_name, kDynamicLoaderPluginName);
2137}
2138
2140 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2141 llvm::StringRef description, bool is_global_property) {
2143 "Settings for dynamic loader plug-ins",
2144 properties_sp, description, is_global_property);
2145}
2146
2149 llvm::StringRef setting_name) {
2150 return GetSettingForPlugin(debugger, setting_name, kPlatformPluginName,
2152}
2153
2155 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2156 llvm::StringRef description, bool is_global_property) {
2158 "Settings for platform plug-ins", properties_sp,
2159 description, is_global_property,
2161}
2162
2165 llvm::StringRef setting_name) {
2166 return GetSettingForPlugin(debugger, setting_name, kProcessPluginName);
2167}
2168
2170 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2171 llvm::StringRef description, bool is_global_property) {
2173 "Settings for process plug-ins", properties_sp,
2174 description, is_global_property);
2175}
2176
2179 llvm::StringRef setting_name) {
2180 return GetSettingForPlugin(debugger, setting_name, kSymbolLocatorPluginName);
2181}
2182
2184 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2185 llvm::StringRef description, bool is_global_property) {
2187 "Settings for symbol locator plug-ins",
2188 properties_sp, description, is_global_property);
2189}
2190
2192 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2193 llvm::StringRef description, bool is_global_property) {
2195 "Settings for trace plug-ins", properties_sp,
2196 description, is_global_property);
2197}
2198
2201 llvm::StringRef setting_name) {
2202 return GetSettingForPlugin(debugger, setting_name, kObjectFilePluginName);
2203}
2204
2206 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2207 llvm::StringRef description, bool is_global_property) {
2209 "Settings for object file plug-ins",
2210 properties_sp, description, is_global_property);
2211}
2212
2215 llvm::StringRef setting_name) {
2216 return GetSettingForPlugin(debugger, setting_name, kSymbolFilePluginName);
2217}
2218
2220 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2221 llvm::StringRef description, bool is_global_property) {
2223 "Settings for symbol file plug-ins",
2224 properties_sp, description, is_global_property);
2225}
2226
2229 llvm::StringRef setting_name) {
2230 return GetSettingForPlugin(debugger, setting_name, kJITLoaderPluginName);
2231}
2232
2234 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2235 llvm::StringRef description, bool is_global_property) {
2237 "Settings for JIT loader plug-ins",
2238 properties_sp, description, is_global_property);
2239}
2240
2241static const char *kOperatingSystemPluginName("os");
2242
2245 llvm::StringRef setting_name) {
2246 lldb::OptionValuePropertiesSP properties_sp;
2247 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2250 "", // not creating to so we don't need the description
2251 false));
2252 if (plugin_type_properties_sp)
2253 properties_sp =
2254 plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
2255 return properties_sp;
2256}
2257
2259 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2260 llvm::StringRef description, bool is_global_property) {
2261 if (properties_sp) {
2262 lldb::OptionValuePropertiesSP plugin_type_properties_sp(
2264 "Settings for operating system plug-ins",
2265 true));
2266 if (plugin_type_properties_sp) {
2267 plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
2268 description, is_global_property,
2269 properties_sp);
2270 return true;
2271 }
2272 }
2273 return false;
2274}
2275
2278 llvm::StringRef setting_name) {
2279 return GetSettingForPlugin(debugger, setting_name, kStructuredDataPluginName);
2280}
2281
2283 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2284 llvm::StringRef description, bool is_global_property) {
2286 "Settings for structured data plug-ins",
2287 properties_sp, description, is_global_property);
2288}
2289
2292 Debugger &debugger, llvm::StringRef setting_name) {
2293 return GetSettingForPlugin(debugger, setting_name, kCPlusPlusLanguagePlugin);
2294}
2295
2297 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
2298 llvm::StringRef description, bool is_global_property) {
2300 "Settings for CPlusPlus language plug-ins",
2301 properties_sp, description, is_global_property);
2302}
2303
2304//
2305// Plugin Info+Enable Implementations
2306//
2307std::vector<RegisteredPluginInfo> PluginManager::GetABIPluginInfo() {
2309}
2310bool PluginManager::SetABIPluginEnabled(llvm::StringRef name, bool enable) {
2311 return GetABIInstances().SetInstanceEnabled(name, enable);
2312}
2313
2318 bool enable) {
2319 return GetArchitectureInstances().SetInstanceEnabled(name, enable);
2320}
2321
2326 bool enable) {
2327 return GetDisassemblerInstances().SetInstanceEnabled(name, enable);
2328}
2329
2334 bool enable) {
2335 return GetDynamicLoaderInstances().SetInstanceEnabled(name, enable);
2336}
2337
2338std::vector<RegisteredPluginInfo>
2343 bool enable) {
2345}
2346
2347std::vector<RegisteredPluginInfo>
2352 bool enable) {
2354}
2355
2356std::vector<RegisteredPluginInfo> PluginManager::GetJITLoaderPluginInfo() {
2358}
2360 bool enable) {
2361 return GetJITLoaderInstances().SetInstanceEnabled(name, enable);
2362}
2363
2364std::vector<RegisteredPluginInfo> PluginManager::GetLanguagePluginInfo() {
2366}
2368 bool enable) {
2369 return GetLanguageInstances().SetInstanceEnabled(name, enable);
2370}
2371
2372std::vector<RegisteredPluginInfo>
2377 bool enable) {
2378 return GetLanguageRuntimeInstances().SetInstanceEnabled(name, enable);
2379}
2380
2385 bool enable) {
2386 return GetMemoryHistoryInstances().SetInstanceEnabled(name, enable);
2387}
2388
2389std::vector<RegisteredPluginInfo>
2394 bool enable) {
2395 return GetObjectContainerInstances().SetInstanceEnabled(name, enable);
2396}
2397
2398std::vector<RegisteredPluginInfo> PluginManager::GetObjectFilePluginInfo() {
2400}
2402 bool enable) {
2403 return GetObjectFileInstances().SetInstanceEnabled(name, enable);
2404}
2405
2406std::vector<RegisteredPluginInfo>
2411 bool enable) {
2412 return GetOperatingSystemInstances().SetInstanceEnabled(name, enable);
2413}
2414
2415std::vector<RegisteredPluginInfo> PluginManager::GetPlatformPluginInfo() {
2417}
2419 bool enable) {
2420 return GetPlatformInstances().SetInstanceEnabled(name, enable);
2421}
2422
2423std::vector<RegisteredPluginInfo> PluginManager::GetProcessPluginInfo() {
2425}
2426bool PluginManager::SetProcessPluginEnabled(llvm::StringRef name, bool enable) {
2427 return GetProcessInstances().SetInstanceEnabled(name, enable);
2428}
2429
2430std::vector<RegisteredPluginInfo> PluginManager::GetREPLPluginInfo() {
2432}
2433bool PluginManager::SetREPLPluginEnabled(llvm::StringRef name, bool enable) {
2434 return GetREPLInstances().SetInstanceEnabled(name, enable);
2435}
2436
2437std::vector<RegisteredPluginInfo>
2442 bool enable) {
2444}
2445
2446std::vector<RegisteredPluginInfo>
2451 bool enable) {
2453}
2454
2455std::vector<RegisteredPluginInfo>
2460 bool enable) {
2462}
2463
2468 bool enable) {
2470}
2471
2472std::vector<RegisteredPluginInfo> PluginManager::GetSymbolFilePluginInfo() {
2474}
2476 bool enable) {
2477 return GetSymbolFileInstances().SetInstanceEnabled(name, enable);
2478}
2479
2484 bool enable) {
2485 return GetSymbolLocatorInstances().SetInstanceEnabled(name, enable);
2486}
2487
2492 bool enable) {
2493 return GetSymbolVendorInstances().SetInstanceEnabled(name, enable);
2494}
2495
2500 bool enable) {
2501 return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable);
2502}
2503
2504std::vector<RegisteredPluginInfo> PluginManager::GetTracePluginInfo() {
2506}
2507bool PluginManager::SetTracePluginEnabled(llvm::StringRef name, bool enable) {
2508 return GetTracePluginInstances().SetInstanceEnabled(name, enable);
2509}
2510
2515 bool enable) {
2516 return GetTraceExporterInstances().SetInstanceEnabled(name, enable);
2517}
2518
2519std::vector<RegisteredPluginInfo> PluginManager::GetTypeSystemPluginInfo() {
2521}
2523 bool enable) {
2524 return GetTypeSystemInstances().SetInstanceEnabled(name, enable);
2525}
2526
2531 bool enable) {
2532 return GetUnwindAssemblyInstances().SetInstanceEnabled(name, enable);
2533}
2534
2536 CompletionRequest &request) {
2537 // Split the name into the namespace and the plugin name.
2538 // If there is no dot then the ns_name will be equal to name and
2539 // plugin_prefix will be empty.
2540 llvm::StringRef ns_name, plugin_prefix;
2541 std::tie(ns_name, plugin_prefix) = name.split('.');
2542
2543 for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) {
2544 // If the plugin namespace matches exactly then
2545 // add all the plugins in this namespace as completions if the
2546 // plugin names starts with the plugin_prefix. If the plugin_prefix
2547 // is empty then it will match all the plugins (empty string is a
2548 // prefix of everything).
2549 if (plugin_ns.name == ns_name) {
2550 for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
2551 llvm::SmallString<128> buf;
2552 if (plugin.name.starts_with(plugin_prefix))
2553 request.AddCompletion(
2554 (plugin_ns.name + "." + plugin.name).toStringRef(buf));
2555 }
2556 } else if (plugin_ns.name.starts_with(name) &&
2557 !plugin_ns.get_info().empty()) {
2558 // Otherwise check if the namespace is a prefix of the full name.
2559 // Use a partial completion here so that we can either operate on the full
2560 // namespace or tab-complete to the next level.
2561 request.AddCompletion(plugin_ns.name, "", CompletionMode::Partial);
2562 }
2563 }
2564}
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:771
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")
static ScriptedFrameProviderInstances & GetScriptedFrameProviderInstances()
PluginInstances< OperatingSystemInstance > OperatingSystemInstances
static LanguageRuntimeInstances & GetLanguageRuntimeInstances()
PluginInstances< LanguageRuntimeInstance > LanguageRuntimeInstances
static InstrumentationRuntimeInstances & GetInstrumentationRuntimeInstances()
PluginInstances< ProcessInstance > ProcessInstances
PluginInstances< SyntheticFrameProviderInstance > SyntheticFrameProviderInstances
PluginInstances< REPLInstance > REPLInstances
static ArchitectureInstances & GetArchitectureInstances()
PluginInstances< ScriptedFrameProviderInstance > ScriptedFrameProviderInstances
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
PluginInstance< SyntheticFrameProviderCreateInstance > SyntheticFrameProviderInstance
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")
PluginInstance< ScriptedFrameProviderCreateInstance > ScriptedFrameProviderInstance
PluginInstances< ScriptInterpreterInstance > ScriptInterpreterInstances
static SyntheticFrameProviderInstances & GetSyntheticFrameProviderInstances()
bool(* PluginInitCallback)()
PluginInstance< DisassemblerCreateInstance > DisassemblerInstance
static SymbolVendorInstances & GetSymbolVendorInstances()
PluginInstances< ObjectContainerInstance > ObjectContainerInstances
static ProtocolServerInstances & GetProtocolServerInstances()
PluginInstances< RegisterTypeBuilderInstance > RegisterTypeBuilderInstances
static REPLInstances & GetREPLInstances()
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
bool UnregisterPlugin(typename Instance::CallbackType callback)
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 SyntheticFrameProviderCreateInstance GetSyntheticFrameProviderCreateCallbackForPluginName(llvm::StringRef name)
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 ScriptedFrameProviderCreateInstance GetScriptedFrameProviderCreateCallbackAtIndex(uint32_t idx)
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)
llvm::Expected< lldb::SyntheticFrameProviderSP >(* ScriptedFrameProviderCreateInstance)(lldb::StackFrameListSP input_frames, const lldb_private::SyntheticFrameProviderDescriptor &descriptor)
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)
llvm::Expected< lldb::SyntheticFrameProviderSP >(* SyntheticFrameProviderCreateInstance)(lldb::StackFrameListSP input_frames, const std::vector< lldb_private::ThreadSpec > &thread_specs)
OperatingSystem *(* OperatingSystemCreateInstance)(Process *process, bool force)
lldb::REPLSP(* REPLCreateInstance)(Status &error, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
SymbolFile *(* SymbolFileCreateInstance)(lldb::ObjectFileSP objfile_sp)
llvm::Expected< lldb::TraceExporterUP >(* TraceExporterCreateInstance)()
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