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