1 //===-- PluginManager.h -----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_PluginManager_h_
10 #define liblldb_PluginManager_h_
12 #include "lldb/Core/Architecture.h"
13 #include "lldb/Symbol/TypeSystem.h"
14 #include "lldb/Utility/CompletionRequest.h"
15 #include "lldb/Utility/FileSpec.h"
16 #include "lldb/Utility/Status.h"
17 #include "lldb/lldb-enumerations.h"
18 #include "lldb/lldb-forward.h"
19 #include "lldb/lldb-private-interfaces.h"
20 #include "llvm/ADT/StringRef.h"
25 namespace lldb_private {
26 class CommandInterpreter;
33 static void Initialize();
35 static void Terminate();
38 static bool RegisterPlugin(ConstString name, const char *description,
39 ABICreateInstance create_callback);
41 static bool UnregisterPlugin(ABICreateInstance create_callback);
43 static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
45 static ABICreateInstance
46 GetABICreateCallbackForPluginName(ConstString name);
49 using ArchitectureCreateInstance =
50 std::unique_ptr<Architecture> (*)(const ArchSpec &);
52 static void RegisterPlugin(ConstString name,
53 llvm::StringRef description,
54 ArchitectureCreateInstance create_callback);
56 static void UnregisterPlugin(ArchitectureCreateInstance create_callback);
58 static std::unique_ptr<Architecture>
59 CreateArchitectureInstance(const ArchSpec &arch);
62 static bool RegisterPlugin(ConstString name, const char *description,
63 DisassemblerCreateInstance create_callback);
65 static bool UnregisterPlugin(DisassemblerCreateInstance create_callback);
67 static DisassemblerCreateInstance
68 GetDisassemblerCreateCallbackAtIndex(uint32_t idx);
70 static DisassemblerCreateInstance
71 GetDisassemblerCreateCallbackForPluginName(ConstString name);
75 RegisterPlugin(ConstString name, const char *description,
76 DynamicLoaderCreateInstance create_callback,
77 DebuggerInitializeCallback debugger_init_callback = nullptr);
79 static bool UnregisterPlugin(DynamicLoaderCreateInstance create_callback);
81 static DynamicLoaderCreateInstance
82 GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
84 static DynamicLoaderCreateInstance
85 GetDynamicLoaderCreateCallbackForPluginName(ConstString name);
89 RegisterPlugin(ConstString name, const char *description,
90 JITLoaderCreateInstance create_callback,
91 DebuggerInitializeCallback debugger_init_callback = nullptr);
93 static bool UnregisterPlugin(JITLoaderCreateInstance create_callback);
95 static JITLoaderCreateInstance
96 GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
98 static JITLoaderCreateInstance
99 GetJITLoaderCreateCallbackForPluginName(ConstString name);
101 // EmulateInstruction
102 static bool RegisterPlugin(ConstString name, const char *description,
103 EmulateInstructionCreateInstance create_callback);
106 UnregisterPlugin(EmulateInstructionCreateInstance create_callback);
108 static EmulateInstructionCreateInstance
109 GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
111 static EmulateInstructionCreateInstance
112 GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
115 static bool RegisterPlugin(ConstString name, const char *description,
116 OperatingSystemCreateInstance create_callback,
117 DebuggerInitializeCallback debugger_init_callback);
119 static bool UnregisterPlugin(OperatingSystemCreateInstance create_callback);
121 static OperatingSystemCreateInstance
122 GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
124 static OperatingSystemCreateInstance
125 GetOperatingSystemCreateCallbackForPluginName(ConstString name);
128 static bool RegisterPlugin(ConstString name, const char *description,
129 LanguageCreateInstance create_callback);
131 static bool UnregisterPlugin(LanguageCreateInstance create_callback);
133 static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
135 static LanguageCreateInstance
136 GetLanguageCreateCallbackForPluginName(ConstString name);
139 static bool RegisterPlugin(
140 ConstString name, const char *description,
141 LanguageRuntimeCreateInstance create_callback,
142 LanguageRuntimeGetCommandObject command_callback = nullptr,
143 LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr);
145 static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback);
147 static LanguageRuntimeCreateInstance
148 GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx);
150 static LanguageRuntimeGetCommandObject
151 GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx);
153 static LanguageRuntimeGetExceptionPrecondition
154 GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
156 static LanguageRuntimeCreateInstance
157 GetLanguageRuntimeCreateCallbackForPluginName(ConstString name);
160 static bool RegisterPlugin(ConstString name, const char *description,
161 SystemRuntimeCreateInstance create_callback);
163 static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
165 static SystemRuntimeCreateInstance
166 GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
168 static SystemRuntimeCreateInstance
169 GetSystemRuntimeCreateCallbackForPluginName(ConstString name);
173 RegisterPlugin(ConstString name, const char *description,
174 ObjectFileCreateInstance create_callback,
175 ObjectFileCreateMemoryInstance create_memory_callback,
176 ObjectFileGetModuleSpecifications get_module_specifications,
177 ObjectFileSaveCore save_core = nullptr);
179 static bool UnregisterPlugin(ObjectFileCreateInstance create_callback);
181 static ObjectFileCreateInstance
182 GetObjectFileCreateCallbackAtIndex(uint32_t idx);
184 static ObjectFileCreateMemoryInstance
185 GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx);
187 static ObjectFileGetModuleSpecifications
188 GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
190 static ObjectFileCreateInstance
191 GetObjectFileCreateCallbackForPluginName(ConstString name);
193 static ObjectFileCreateMemoryInstance
194 GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
196 static Status SaveCore(const lldb::ProcessSP &process_sp,
197 const FileSpec &outfile);
201 RegisterPlugin(ConstString name, const char *description,
202 ObjectContainerCreateInstance create_callback,
203 ObjectFileGetModuleSpecifications get_module_specifications);
205 static bool UnregisterPlugin(ObjectContainerCreateInstance create_callback);
207 static ObjectContainerCreateInstance
208 GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
210 static ObjectContainerCreateInstance
211 GetObjectContainerCreateCallbackForPluginName(ConstString name);
213 static ObjectFileGetModuleSpecifications
214 GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
218 RegisterPlugin(ConstString name, const char *description,
219 PlatformCreateInstance create_callback,
220 DebuggerInitializeCallback debugger_init_callback = nullptr);
222 static bool UnregisterPlugin(PlatformCreateInstance create_callback);
224 static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
226 static PlatformCreateInstance
227 GetPlatformCreateCallbackForPluginName(ConstString name);
229 static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
231 static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx);
233 static void AutoCompletePlatformName(llvm::StringRef partial_name,
234 CompletionRequest &request);
237 RegisterPlugin(ConstString name, const char *description,
238 ProcessCreateInstance create_callback,
239 DebuggerInitializeCallback debugger_init_callback = nullptr);
241 static bool UnregisterPlugin(ProcessCreateInstance create_callback);
243 static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx);
245 static ProcessCreateInstance
246 GetProcessCreateCallbackForPluginName(ConstString name);
248 static const char *GetProcessPluginNameAtIndex(uint32_t idx);
250 static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx);
253 static bool RegisterPlugin(ConstString name, const char *description,
254 lldb::ScriptLanguage script_lang,
255 ScriptInterpreterCreateInstance create_callback);
257 static bool UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
259 static ScriptInterpreterCreateInstance
260 GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
262 static lldb::ScriptInterpreterSP
263 GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
266 // StructuredDataPlugin
268 /// Register a StructuredDataPlugin class along with optional
269 /// callbacks for debugger initialization and Process launch info
270 /// filtering and manipulation.
273 /// The name of the plugin.
275 /// \param[in] description
276 /// A description string for the plugin.
278 /// \param[in] create_callback
279 /// The callback that will be invoked to create an instance of
280 /// the callback. This may not be nullptr.
282 /// \param[in] debugger_init_callback
283 /// An optional callback that will be made when a Debugger
284 /// instance is initialized.
286 /// \param[in] filter_callback
287 /// An optional callback that will be invoked before LLDB
288 /// launches a process for debugging. The callback must
289 /// do the following:
290 /// 1. Only do something if the plugin's behavior is enabled.
291 /// 2. Only make changes for processes that are relevant to the
292 /// plugin. The callback gets a pointer to the Target, which
293 /// can be inspected as needed. The ProcessLaunchInfo is
294 /// provided in read-write mode, and may be modified by the
295 /// plugin if, for instance, additional environment variables
296 /// are needed to support the feature when enabled.
299 /// Returns true upon success; otherwise, false.
301 RegisterPlugin(ConstString name, const char *description,
302 StructuredDataPluginCreateInstance create_callback,
303 DebuggerInitializeCallback debugger_init_callback = nullptr,
304 StructuredDataFilterLaunchInfo filter_callback = nullptr);
307 UnregisterPlugin(StructuredDataPluginCreateInstance create_callback);
309 static StructuredDataPluginCreateInstance
310 GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
312 static StructuredDataPluginCreateInstance
313 GetStructuredDataPluginCreateCallbackForPluginName(ConstString name);
315 static StructuredDataFilterLaunchInfo
316 GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
317 bool &iteration_complete);
321 RegisterPlugin(ConstString name, const char *description,
322 SymbolFileCreateInstance create_callback,
323 DebuggerInitializeCallback debugger_init_callback = nullptr);
325 static bool UnregisterPlugin(SymbolFileCreateInstance create_callback);
327 static SymbolFileCreateInstance
328 GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
330 static SymbolFileCreateInstance
331 GetSymbolFileCreateCallbackForPluginName(ConstString name);
334 static bool RegisterPlugin(ConstString name, const char *description,
335 SymbolVendorCreateInstance create_callback);
337 static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
339 static SymbolVendorCreateInstance
340 GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
342 static SymbolVendorCreateInstance
343 GetSymbolVendorCreateCallbackForPluginName(ConstString name);
346 static bool RegisterPlugin(ConstString name, const char *description,
347 UnwindAssemblyCreateInstance create_callback);
349 static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback);
351 static UnwindAssemblyCreateInstance
352 GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
354 static UnwindAssemblyCreateInstance
355 GetUnwindAssemblyCreateCallbackForPluginName(ConstString name);
358 static bool RegisterPlugin(ConstString name, const char *description,
359 MemoryHistoryCreateInstance create_callback);
361 static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
363 static MemoryHistoryCreateInstance
364 GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
366 static MemoryHistoryCreateInstance
367 GetMemoryHistoryCreateCallbackForPluginName(ConstString name);
369 // InstrumentationRuntime
371 RegisterPlugin(ConstString name, const char *description,
372 InstrumentationRuntimeCreateInstance create_callback,
373 InstrumentationRuntimeGetType get_type_callback);
376 UnregisterPlugin(InstrumentationRuntimeCreateInstance create_callback);
378 static InstrumentationRuntimeGetType
379 GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx);
381 static InstrumentationRuntimeCreateInstance
382 GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
384 static InstrumentationRuntimeCreateInstance
385 GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
388 static bool RegisterPlugin(ConstString name, const char *description,
389 TypeSystemCreateInstance create_callback,
390 LanguageSet supported_languages_for_types,
391 LanguageSet supported_languages_for_expressions);
393 static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
395 static TypeSystemCreateInstance
396 GetTypeSystemCreateCallbackAtIndex(uint32_t idx);
398 static TypeSystemCreateInstance
399 GetTypeSystemCreateCallbackForPluginName(ConstString name);
401 static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes();
403 static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();
406 static bool RegisterPlugin(ConstString name, const char *description,
407 REPLCreateInstance create_callback,
408 LanguageSet supported_languages);
410 static bool UnregisterPlugin(REPLCreateInstance create_callback);
412 static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx);
414 static REPLCreateInstance
415 GetREPLCreateCallbackForPluginName(ConstString name);
417 static LanguageSet GetREPLAllTypeSystemSupportedLanguages();
419 // Some plug-ins might register a DebuggerInitializeCallback callback when
420 // registering the plug-in. After a new Debugger instance is created, this
421 // DebuggerInitialize function will get called. This allows plug-ins to
422 // install Properties and do any other initialization that requires a
423 // debugger instance.
424 static void DebuggerInitialize(Debugger &debugger);
426 static lldb::OptionValuePropertiesSP
427 GetSettingForDynamicLoaderPlugin(Debugger &debugger,
428 ConstString setting_name);
430 static bool CreateSettingForDynamicLoaderPlugin(
431 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
432 ConstString description, bool is_global_property);
434 static lldb::OptionValuePropertiesSP
435 GetSettingForPlatformPlugin(Debugger &debugger, ConstString setting_name);
437 static bool CreateSettingForPlatformPlugin(
438 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
439 ConstString description, bool is_global_property);
441 static lldb::OptionValuePropertiesSP
442 GetSettingForProcessPlugin(Debugger &debugger, ConstString setting_name);
444 static bool CreateSettingForProcessPlugin(
445 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
446 ConstString description, bool is_global_property);
448 static lldb::OptionValuePropertiesSP
449 GetSettingForSymbolFilePlugin(Debugger &debugger, ConstString setting_name);
451 static bool CreateSettingForSymbolFilePlugin(
452 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
453 ConstString description, bool is_global_property);
455 static lldb::OptionValuePropertiesSP
456 GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name);
458 static bool CreateSettingForJITLoaderPlugin(
459 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
460 ConstString description, bool is_global_property);
462 static lldb::OptionValuePropertiesSP
463 GetSettingForOperatingSystemPlugin(Debugger &debugger,
464 ConstString setting_name);
466 static bool CreateSettingForOperatingSystemPlugin(
467 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
468 ConstString description, bool is_global_property);
470 static lldb::OptionValuePropertiesSP
471 GetSettingForStructuredDataPlugin(Debugger &debugger,
472 ConstString setting_name);
474 static bool CreateSettingForStructuredDataPlugin(
475 Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
476 ConstString description, bool is_global_property);
479 } // namespace lldb_private
481 #endif // liblldb_PluginManager_h_