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