]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/PluginManager.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Core / PluginManager.h
1 //===-- PluginManager.h -----------------------------------------*- C++ -*-===//
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
9 #ifndef liblldb_PluginManager_h_
10 #define liblldb_PluginManager_h_
11
12 #include "lldb/Core/Architecture.h"
13 #include "lldb/Utility/FileSpec.h"
14 #include "lldb/Utility/Status.h"
15 #include "lldb/lldb-enumerations.h"
16 #include "lldb/lldb-forward.h"
17 #include "lldb/lldb-private-interfaces.h"
18 #include "llvm/ADT/StringRef.h"
19
20 #include <stddef.h>
21 #include <stdint.h>
22
23 namespace lldb_private {
24 class CommandInterpreter;
25 class ConstString;
26 class Debugger;
27 class StringList;
28
29 class PluginManager {
30 public:
31   static void Initialize();
32
33   static void Terminate();
34
35   // ABI
36   static bool RegisterPlugin(ConstString name, const char *description,
37                              ABICreateInstance create_callback);
38
39   static bool UnregisterPlugin(ABICreateInstance create_callback);
40
41   static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
42
43   static ABICreateInstance
44   GetABICreateCallbackForPluginName(ConstString name);
45
46   // Architecture
47   using ArchitectureCreateInstance =
48       std::unique_ptr<Architecture> (*)(const ArchSpec &);
49
50   static void RegisterPlugin(ConstString name,
51                              llvm::StringRef description,
52                              ArchitectureCreateInstance create_callback);
53
54   static void UnregisterPlugin(ArchitectureCreateInstance create_callback);
55
56   static std::unique_ptr<Architecture>
57   CreateArchitectureInstance(const ArchSpec &arch);
58
59   // Disassembler
60   static bool RegisterPlugin(ConstString name, const char *description,
61                              DisassemblerCreateInstance create_callback);
62
63   static bool UnregisterPlugin(DisassemblerCreateInstance create_callback);
64
65   static DisassemblerCreateInstance
66   GetDisassemblerCreateCallbackAtIndex(uint32_t idx);
67
68   static DisassemblerCreateInstance
69   GetDisassemblerCreateCallbackForPluginName(ConstString name);
70
71   // DynamicLoader
72   static bool
73   RegisterPlugin(ConstString name, const char *description,
74                  DynamicLoaderCreateInstance create_callback,
75                  DebuggerInitializeCallback debugger_init_callback = nullptr);
76
77   static bool UnregisterPlugin(DynamicLoaderCreateInstance create_callback);
78
79   static DynamicLoaderCreateInstance
80   GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
81
82   static DynamicLoaderCreateInstance
83   GetDynamicLoaderCreateCallbackForPluginName(ConstString name);
84
85   // JITLoader
86   static bool
87   RegisterPlugin(ConstString name, const char *description,
88                  JITLoaderCreateInstance create_callback,
89                  DebuggerInitializeCallback debugger_init_callback = nullptr);
90
91   static bool UnregisterPlugin(JITLoaderCreateInstance create_callback);
92
93   static JITLoaderCreateInstance
94   GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
95
96   static JITLoaderCreateInstance
97   GetJITLoaderCreateCallbackForPluginName(ConstString name);
98
99   // EmulateInstruction
100   static bool RegisterPlugin(ConstString name, const char *description,
101                              EmulateInstructionCreateInstance create_callback);
102
103   static bool
104   UnregisterPlugin(EmulateInstructionCreateInstance create_callback);
105
106   static EmulateInstructionCreateInstance
107   GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
108
109   static EmulateInstructionCreateInstance
110   GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
111
112   // OperatingSystem
113   static bool RegisterPlugin(ConstString name, const char *description,
114                              OperatingSystemCreateInstance create_callback,
115                              DebuggerInitializeCallback debugger_init_callback);
116
117   static bool UnregisterPlugin(OperatingSystemCreateInstance create_callback);
118
119   static OperatingSystemCreateInstance
120   GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
121
122   static OperatingSystemCreateInstance
123   GetOperatingSystemCreateCallbackForPluginName(ConstString name);
124
125   // Language
126   static bool RegisterPlugin(ConstString name, const char *description,
127                              LanguageCreateInstance create_callback);
128
129   static bool UnregisterPlugin(LanguageCreateInstance create_callback);
130
131   static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
132
133   static LanguageCreateInstance
134   GetLanguageCreateCallbackForPluginName(ConstString name);
135
136   // LanguageRuntime
137   static bool RegisterPlugin(
138       ConstString name, const char *description,
139       LanguageRuntimeCreateInstance create_callback,
140       LanguageRuntimeGetCommandObject command_callback = nullptr,
141       LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr);
142
143   static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback);
144
145   static LanguageRuntimeCreateInstance
146   GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx);
147
148   static LanguageRuntimeGetCommandObject
149   GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx);
150
151   static LanguageRuntimeGetExceptionPrecondition
152   GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
153
154   static LanguageRuntimeCreateInstance
155   GetLanguageRuntimeCreateCallbackForPluginName(ConstString name);
156
157   // SystemRuntime
158   static bool RegisterPlugin(ConstString name, const char *description,
159                              SystemRuntimeCreateInstance create_callback);
160
161   static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
162
163   static SystemRuntimeCreateInstance
164   GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
165
166   static SystemRuntimeCreateInstance
167   GetSystemRuntimeCreateCallbackForPluginName(ConstString name);
168
169   // ObjectFile
170   static bool
171   RegisterPlugin(ConstString name, const char *description,
172                  ObjectFileCreateInstance create_callback,
173                  ObjectFileCreateMemoryInstance create_memory_callback,
174                  ObjectFileGetModuleSpecifications get_module_specifications,
175                  ObjectFileSaveCore save_core = nullptr);
176
177   static bool UnregisterPlugin(ObjectFileCreateInstance create_callback);
178
179   static ObjectFileCreateInstance
180   GetObjectFileCreateCallbackAtIndex(uint32_t idx);
181
182   static ObjectFileCreateMemoryInstance
183   GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx);
184
185   static ObjectFileGetModuleSpecifications
186   GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
187
188   static ObjectFileCreateInstance
189   GetObjectFileCreateCallbackForPluginName(ConstString name);
190
191   static ObjectFileCreateMemoryInstance
192   GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
193
194   static Status SaveCore(const lldb::ProcessSP &process_sp,
195                          const FileSpec &outfile);
196
197   // ObjectContainer
198   static bool
199   RegisterPlugin(ConstString name, const char *description,
200                  ObjectContainerCreateInstance create_callback,
201                  ObjectFileGetModuleSpecifications get_module_specifications);
202
203   static bool UnregisterPlugin(ObjectContainerCreateInstance create_callback);
204
205   static ObjectContainerCreateInstance
206   GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
207
208   static ObjectContainerCreateInstance
209   GetObjectContainerCreateCallbackForPluginName(ConstString name);
210
211   static ObjectFileGetModuleSpecifications
212   GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
213
214   // Platform
215   static bool
216   RegisterPlugin(ConstString name, const char *description,
217                  PlatformCreateInstance create_callback,
218                  DebuggerInitializeCallback debugger_init_callback = nullptr);
219
220   static bool UnregisterPlugin(PlatformCreateInstance create_callback);
221
222   static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
223
224   static PlatformCreateInstance
225   GetPlatformCreateCallbackForPluginName(ConstString name);
226
227   static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
228
229   static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx);
230
231   static size_t AutoCompletePlatformName(llvm::StringRef partial_name,
232                                          StringList &matches);
233   // Process
234   static bool
235   RegisterPlugin(ConstString name, const char *description,
236                  ProcessCreateInstance create_callback,
237                  DebuggerInitializeCallback debugger_init_callback = nullptr);
238
239   static bool UnregisterPlugin(ProcessCreateInstance create_callback);
240
241   static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx);
242
243   static ProcessCreateInstance
244   GetProcessCreateCallbackForPluginName(ConstString name);
245
246   static const char *GetProcessPluginNameAtIndex(uint32_t idx);
247
248   static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx);
249
250   // ScriptInterpreter
251   static bool RegisterPlugin(ConstString name, const char *description,
252                              lldb::ScriptLanguage script_lang,
253                              ScriptInterpreterCreateInstance create_callback);
254
255   static bool UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
256
257   static ScriptInterpreterCreateInstance
258   GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
259
260   static lldb::ScriptInterpreterSP
261   GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
262                                   Debugger &debugger);
263
264   // StructuredDataPlugin
265
266   /// Register a StructuredDataPlugin class along with optional
267   /// callbacks for debugger initialization and Process launch info
268   /// filtering and manipulation.
269   ///
270   /// \param[in] name
271   ///    The name of the plugin.
272   ///
273   /// \param[in] description
274   ///    A description string for the plugin.
275   ///
276   /// \param[in] create_callback
277   ///    The callback that will be invoked to create an instance of
278   ///    the callback.  This may not be nullptr.
279   ///
280   /// \param[in] debugger_init_callback
281   ///    An optional callback that will be made when a Debugger
282   ///    instance is initialized.
283   ///
284   /// \param[in] filter_callback
285   ///    An optional callback that will be invoked before LLDB
286   ///    launches a process for debugging.  The callback must
287   ///    do the following:
288   ///    1. Only do something if the plugin's behavior is enabled.
289   ///    2. Only make changes for processes that are relevant to the
290   ///       plugin.  The callback gets a pointer to the Target, which
291   ///       can be inspected as needed.  The ProcessLaunchInfo is
292   ///       provided in read-write mode, and may be modified by the
293   ///       plugin if, for instance, additional environment variables
294   ///       are needed to support the feature when enabled.
295   ///
296   /// \return
297   ///    Returns true upon success; otherwise, false.
298   static bool
299   RegisterPlugin(ConstString name, const char *description,
300                  StructuredDataPluginCreateInstance create_callback,
301                  DebuggerInitializeCallback debugger_init_callback = nullptr,
302                  StructuredDataFilterLaunchInfo filter_callback = nullptr);
303
304   static bool
305   UnregisterPlugin(StructuredDataPluginCreateInstance create_callback);
306
307   static StructuredDataPluginCreateInstance
308   GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
309
310   static StructuredDataPluginCreateInstance
311   GetStructuredDataPluginCreateCallbackForPluginName(ConstString name);
312
313   static StructuredDataFilterLaunchInfo
314   GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
315                                          bool &iteration_complete);
316
317   // SymbolFile
318   static bool
319   RegisterPlugin(ConstString name, const char *description,
320                  SymbolFileCreateInstance create_callback,
321                  DebuggerInitializeCallback debugger_init_callback = nullptr);
322
323   static bool UnregisterPlugin(SymbolFileCreateInstance create_callback);
324
325   static SymbolFileCreateInstance
326   GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
327
328   static SymbolFileCreateInstance
329   GetSymbolFileCreateCallbackForPluginName(ConstString name);
330
331   // SymbolVendor
332   static bool RegisterPlugin(ConstString name, const char *description,
333                              SymbolVendorCreateInstance create_callback);
334
335   static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
336
337   static SymbolVendorCreateInstance
338   GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
339
340   static SymbolVendorCreateInstance
341   GetSymbolVendorCreateCallbackForPluginName(ConstString name);
342
343   // UnwindAssembly
344   static bool RegisterPlugin(ConstString name, const char *description,
345                              UnwindAssemblyCreateInstance create_callback);
346
347   static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback);
348
349   static UnwindAssemblyCreateInstance
350   GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
351
352   static UnwindAssemblyCreateInstance
353   GetUnwindAssemblyCreateCallbackForPluginName(ConstString name);
354
355   // MemoryHistory
356   static bool RegisterPlugin(ConstString name, const char *description,
357                              MemoryHistoryCreateInstance create_callback);
358
359   static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
360
361   static MemoryHistoryCreateInstance
362   GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
363
364   static MemoryHistoryCreateInstance
365   GetMemoryHistoryCreateCallbackForPluginName(ConstString name);
366
367   // InstrumentationRuntime
368   static bool
369   RegisterPlugin(ConstString name, const char *description,
370                  InstrumentationRuntimeCreateInstance create_callback,
371                  InstrumentationRuntimeGetType get_type_callback);
372
373   static bool
374   UnregisterPlugin(InstrumentationRuntimeCreateInstance create_callback);
375
376   static InstrumentationRuntimeGetType
377   GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx);
378
379   static InstrumentationRuntimeCreateInstance
380   GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
381
382   static InstrumentationRuntimeCreateInstance
383   GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
384
385   // TypeSystem
386   static bool RegisterPlugin(
387       ConstString name, const char *description,
388       TypeSystemCreateInstance create_callback,
389       TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
390
391   static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
392
393   static TypeSystemCreateInstance
394   GetTypeSystemCreateCallbackAtIndex(uint32_t idx);
395
396   static TypeSystemCreateInstance
397   GetTypeSystemCreateCallbackForPluginName(ConstString name);
398
399   static TypeSystemEnumerateSupportedLanguages
400   GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
401
402   static TypeSystemEnumerateSupportedLanguages
403   GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
404       ConstString name);
405
406   // REPL
407   static bool
408   RegisterPlugin(ConstString name, const char *description,
409                  REPLCreateInstance create_callback,
410                  REPLEnumerateSupportedLanguages enumerate_languages_callback);
411
412   static bool UnregisterPlugin(REPLCreateInstance create_callback);
413
414   static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx);
415
416   static REPLCreateInstance
417   GetREPLCreateCallbackForPluginName(ConstString name);
418
419   static REPLEnumerateSupportedLanguages
420   GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
421
422   static REPLEnumerateSupportedLanguages
423   GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
424       ConstString name);
425
426   // Some plug-ins might register a DebuggerInitializeCallback callback when
427   // registering the plug-in. After a new Debugger instance is created, this
428   // DebuggerInitialize function will get called. This allows plug-ins to
429   // install Properties and do any other initialization that requires a
430   // debugger instance.
431   static void DebuggerInitialize(Debugger &debugger);
432
433   static lldb::OptionValuePropertiesSP
434   GetSettingForDynamicLoaderPlugin(Debugger &debugger,
435                                    ConstString setting_name);
436
437   static bool CreateSettingForDynamicLoaderPlugin(
438       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
439       ConstString description, bool is_global_property);
440
441   static lldb::OptionValuePropertiesSP
442   GetSettingForPlatformPlugin(Debugger &debugger,
443                               ConstString setting_name);
444
445   static bool CreateSettingForPlatformPlugin(
446       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
447       ConstString description, bool is_global_property);
448
449   static lldb::OptionValuePropertiesSP
450   GetSettingForProcessPlugin(Debugger &debugger,
451                              ConstString setting_name);
452
453   static bool CreateSettingForProcessPlugin(
454       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
455       ConstString description, bool is_global_property);
456
457   static lldb::OptionValuePropertiesSP
458   GetSettingForSymbolFilePlugin(Debugger &debugger,
459                                 ConstString setting_name);
460
461   static bool CreateSettingForSymbolFilePlugin(
462       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
463       ConstString description, bool is_global_property);
464
465   static lldb::OptionValuePropertiesSP
466   GetSettingForJITLoaderPlugin(Debugger &debugger,
467                                ConstString setting_name);
468
469   static bool CreateSettingForJITLoaderPlugin(
470       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
471       ConstString description, bool is_global_property);
472
473   static lldb::OptionValuePropertiesSP
474   GetSettingForOperatingSystemPlugin(Debugger &debugger,
475                                      ConstString setting_name);
476
477   static bool CreateSettingForOperatingSystemPlugin(
478       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
479       ConstString description, bool is_global_property);
480
481   static lldb::OptionValuePropertiesSP
482   GetSettingForStructuredDataPlugin(Debugger &debugger,
483                                     ConstString setting_name);
484
485   static bool CreateSettingForStructuredDataPlugin(
486       Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
487       ConstString description, bool is_global_property);
488 };
489
490 } // namespace lldb_private
491
492 #endif // liblldb_PluginManager_h_