PluginManager.h revision 360784
1156952Sume//===-- PluginManager.h -----------------------------------------*- C++ -*-===// 2156952Sume// 3156952Sume// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4156952Sume// See https://llvm.org/LICENSE.txt for license information. 5156952Sume// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6156952Sume// 7156952Sume//===----------------------------------------------------------------------===// 8156952Sume 9156952Sume#ifndef liblldb_PluginManager_h_ 10156952Sume#define liblldb_PluginManager_h_ 11156952Sume 12156952Sume#include "lldb/Core/Architecture.h" 13156952Sume#include "lldb/Symbol/TypeSystem.h" 14156952Sume#include "lldb/Utility/CompletionRequest.h" 15156952Sume#include "lldb/Utility/FileSpec.h" 16156952Sume#include "lldb/Utility/Status.h" 17156952Sume#include "lldb/lldb-enumerations.h" 18156952Sume#include "lldb/lldb-forward.h" 19156952Sume#include "lldb/lldb-private-interfaces.h" 20156952Sume#include "llvm/ADT/StringRef.h" 21156952Sume 22156952Sume#include <stddef.h> 23156952Sume#include <stdint.h> 24156952Sume 25156952Sumenamespace lldb_private { 26156952Sumeclass CommandInterpreter; 27156952Sumeclass ConstString; 28156952Sumeclass Debugger; 29156952Sumeclass StringList; 30156952Sume 31156952Sumeclass PluginManager { 32156952Sumepublic: 33156952Sume static void Initialize(); 34156952Sume 35156952Sume static void Terminate(); 36156952Sume 37156952Sume // ABI 38156952Sume static bool RegisterPlugin(ConstString name, const char *description, 39156952Sume ABICreateInstance create_callback); 40156952Sume 41156952Sume static bool UnregisterPlugin(ABICreateInstance create_callback); 42156952Sume 43156952Sume static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx); 44156952Sume 45156952Sume static ABICreateInstance 46156952Sume GetABICreateCallbackForPluginName(ConstString name); 47156952Sume 48156952Sume // Architecture 49156952Sume using ArchitectureCreateInstance = 50156952Sume std::unique_ptr<Architecture> (*)(const ArchSpec &); 51156952Sume 52156952Sume static void RegisterPlugin(ConstString name, 53156952Sume llvm::StringRef description, 54156952Sume ArchitectureCreateInstance create_callback); 55156952Sume 56156952Sume static void UnregisterPlugin(ArchitectureCreateInstance create_callback); 57156952Sume 58156952Sume static std::unique_ptr<Architecture> 59156952Sume CreateArchitectureInstance(const ArchSpec &arch); 60156952Sume 61156952Sume // Disassembler 62156952Sume static bool RegisterPlugin(ConstString name, const char *description, 63156952Sume DisassemblerCreateInstance create_callback); 64156952Sume 65156952Sume static bool UnregisterPlugin(DisassemblerCreateInstance create_callback); 66156952Sume 67156952Sume static DisassemblerCreateInstance 68156952Sume GetDisassemblerCreateCallbackAtIndex(uint32_t idx); 69186090Sume 70156952Sume static DisassemblerCreateInstance 71156956Sume GetDisassemblerCreateCallbackForPluginName(ConstString name); 72156956Sume 73156952Sume // DynamicLoader 74170244Sume static bool 75170244Sume RegisterPlugin(ConstString name, const char *description, 76156952Sume DynamicLoaderCreateInstance create_callback, 77156952Sume DebuggerInitializeCallback debugger_init_callback = nullptr); 78156952Sume 79156952Sume static bool UnregisterPlugin(DynamicLoaderCreateInstance create_callback); 80156956Sume 81156952Sume static DynamicLoaderCreateInstance 82156956Sume GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx); 83156952Sume 84156956Sume static DynamicLoaderCreateInstance 85156952Sume GetDynamicLoaderCreateCallbackForPluginName(ConstString name); 86156952Sume 87156952Sume // JITLoader 88156952Sume static bool 89156952Sume RegisterPlugin(ConstString name, const char *description, 90156952Sume JITLoaderCreateInstance create_callback, 91156952Sume DebuggerInitializeCallback debugger_init_callback = nullptr); 92156952Sume 93156952Sume static bool UnregisterPlugin(JITLoaderCreateInstance create_callback); 94156952Sume 95156952Sume static JITLoaderCreateInstance 96156952Sume GetJITLoaderCreateCallbackAtIndex(uint32_t idx); 97156952Sume 98156952Sume static JITLoaderCreateInstance 99156952Sume GetJITLoaderCreateCallbackForPluginName(ConstString name); 100156952Sume 101156952Sume // EmulateInstruction 102156952Sume static bool RegisterPlugin(ConstString name, const char *description, 103156952Sume EmulateInstructionCreateInstance create_callback); 104156952Sume 105156952Sume static bool 106156952Sume UnregisterPlugin(EmulateInstructionCreateInstance create_callback); 107156952Sume 108156956Sume static EmulateInstructionCreateInstance 109156956Sume GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx); 110156956Sume 111156952Sume static EmulateInstructionCreateInstance 112156952Sume GetEmulateInstructionCreateCallbackForPluginName(ConstString name); 113156952Sume 114156952Sume // OperatingSystem 115156952Sume static bool RegisterPlugin(ConstString name, const char *description, 116156952Sume OperatingSystemCreateInstance create_callback, 117156956Sume DebuggerInitializeCallback debugger_init_callback); 118156952Sume 119156956Sume static bool UnregisterPlugin(OperatingSystemCreateInstance create_callback); 120156956Sume 121156952Sume static OperatingSystemCreateInstance 122156952Sume GetOperatingSystemCreateCallbackAtIndex(uint32_t idx); 123156952Sume 124156952Sume static OperatingSystemCreateInstance 125156952Sume GetOperatingSystemCreateCallbackForPluginName(ConstString name); 126156952Sume 127156952Sume // Language 128167246Sjhb static bool RegisterPlugin(ConstString name, const char *description, 129156952Sume LanguageCreateInstance create_callback); 130156952Sume 131156952Sume static bool UnregisterPlugin(LanguageCreateInstance create_callback); 132156952Sume 133156952Sume static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx); 134156956Sume 135156956Sume static LanguageCreateInstance 136156952Sume GetLanguageCreateCallbackForPluginName(ConstString name); 137156952Sume 138156956Sume // LanguageRuntime 139156956Sume static bool RegisterPlugin( 140156956Sume ConstString name, const char *description, 141156956Sume LanguageRuntimeCreateInstance create_callback, 142156956Sume LanguageRuntimeGetCommandObject command_callback = nullptr, 143163661Sume LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr); 144156952Sume 145156952Sume static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback); 146156952Sume 147156952Sume static LanguageRuntimeCreateInstance 148156952Sume GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx); 149156956Sume 150156952Sume static LanguageRuntimeGetCommandObject 151156952Sume GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx); 152156952Sume 153156952Sume static LanguageRuntimeGetExceptionPrecondition 154156952Sume GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx); 155156952Sume 156156952Sume static LanguageRuntimeCreateInstance 157156952Sume GetLanguageRuntimeCreateCallbackForPluginName(ConstString name); 158156952Sume 159156952Sume // SystemRuntime 160170244Sume static bool RegisterPlugin(ConstString name, const char *description, 161156952Sume SystemRuntimeCreateInstance create_callback); 162170244Sume 163156952Sume static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback); 164170244Sume 165170244Sume static SystemRuntimeCreateInstance 166170244Sume GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx); 167156952Sume 168170244Sume static SystemRuntimeCreateInstance 169156952Sume GetSystemRuntimeCreateCallbackForPluginName(ConstString name); 170156952Sume 171156952Sume // ObjectFile 172156952Sume static bool 173156952Sume RegisterPlugin(ConstString name, const char *description, 174156952Sume ObjectFileCreateInstance create_callback, 175156952Sume ObjectFileCreateMemoryInstance create_memory_callback, 176156952Sume ObjectFileGetModuleSpecifications get_module_specifications, 177156952Sume ObjectFileSaveCore save_core = nullptr); 178156952Sume 179156952Sume static bool UnregisterPlugin(ObjectFileCreateInstance create_callback); 180156952Sume 181156952Sume static ObjectFileCreateInstance 182156952Sume GetObjectFileCreateCallbackAtIndex(uint32_t idx); 183156952Sume 184156952Sume static ObjectFileCreateMemoryInstance 185156952Sume GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx); 186156952Sume 187156952Sume static ObjectFileGetModuleSpecifications 188156952Sume GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx); 189156952Sume 190156952Sume static ObjectFileCreateInstance 191156952Sume GetObjectFileCreateCallbackForPluginName(ConstString name); 192156952Sume 193156952Sume static ObjectFileCreateMemoryInstance 194156952Sume GetObjectFileCreateMemoryCallbackForPluginName(ConstString name); 195156952Sume 196156952Sume static Status SaveCore(const lldb::ProcessSP &process_sp, 197156952Sume const FileSpec &outfile); 198156952Sume 199156952Sume // ObjectContainer 200156952Sume static bool 201156952Sume RegisterPlugin(ConstString name, const char *description, 202156952Sume ObjectContainerCreateInstance create_callback, 203156952Sume ObjectFileGetModuleSpecifications get_module_specifications); 204156952Sume 205156952Sume static bool UnregisterPlugin(ObjectContainerCreateInstance create_callback); 206156952Sume 207156952Sume static ObjectContainerCreateInstance 208156952Sume GetObjectContainerCreateCallbackAtIndex(uint32_t idx); 209156952Sume 210156952Sume static ObjectContainerCreateInstance 211170244Sume GetObjectContainerCreateCallbackForPluginName(ConstString name); 212156952Sume 213170244Sume static ObjectFileGetModuleSpecifications 214156952Sume GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx); 215170244Sume 216170244Sume // Platform 217156952Sume static bool 218170244Sume RegisterPlugin(ConstString name, const char *description, 219170244Sume PlatformCreateInstance create_callback, 220170244Sume DebuggerInitializeCallback debugger_init_callback = nullptr); 221170244Sume 222156952Sume static bool UnregisterPlugin(PlatformCreateInstance create_callback); 223170244Sume 224156952Sume static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx); 225156952Sume 226156952Sume static PlatformCreateInstance 227156952Sume GetPlatformCreateCallbackForPluginName(ConstString name); 228156952Sume 229156952Sume static const char *GetPlatformPluginNameAtIndex(uint32_t idx); 230156952Sume 231156952Sume static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx); 232156952Sume 233156952Sume static void AutoCompletePlatformName(llvm::StringRef partial_name, 234156952Sume CompletionRequest &request); 235156952Sume // Process 236156952Sume static bool 237156952Sume RegisterPlugin(ConstString name, const char *description, 238156952Sume ProcessCreateInstance create_callback, 239156952Sume DebuggerInitializeCallback debugger_init_callback = nullptr); 240156952Sume 241156952Sume static bool UnregisterPlugin(ProcessCreateInstance create_callback); 242156952Sume 243156952Sume static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx); 244156952Sume 245156952Sume static ProcessCreateInstance 246156952Sume GetProcessCreateCallbackForPluginName(ConstString name); 247156952Sume 248156952Sume static const char *GetProcessPluginNameAtIndex(uint32_t idx); 249156952Sume 250156952Sume static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx); 251170244Sume 252156952Sume // ScriptInterpreter 253156952Sume static bool RegisterPlugin(ConstString name, const char *description, 254170244Sume lldb::ScriptLanguage script_lang, 255156952Sume ScriptInterpreterCreateInstance create_callback); 256170244Sume 257170244Sume static bool UnregisterPlugin(ScriptInterpreterCreateInstance create_callback); 258170244Sume 259170244Sume static ScriptInterpreterCreateInstance 260156952Sume GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx); 261170244Sume 262156952Sume static lldb::ScriptInterpreterSP 263156952Sume GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, 264156952Sume Debugger &debugger); 265156952Sume 266156952Sume // StructuredDataPlugin 267156952Sume 268156952Sume /// Register a StructuredDataPlugin class along with optional 269156952Sume /// callbacks for debugger initialization and Process launch info 270156952Sume /// filtering and manipulation. 271156952Sume /// 272156952Sume /// \param[in] name 273156952Sume /// The name of the plugin. 274156952Sume /// 275156952Sume /// \param[in] description 276156952Sume /// A description string for the plugin. 277156952Sume /// 278156952Sume /// \param[in] create_callback 279156952Sume /// The callback that will be invoked to create an instance of 280156952Sume /// the callback. This may not be nullptr. 281156952Sume /// 282156952Sume /// \param[in] debugger_init_callback 283156952Sume /// An optional callback that will be made when a Debugger 284156952Sume /// instance is initialized. 285156952Sume /// 286156952Sume /// \param[in] filter_callback 287156952Sume /// An optional callback that will be invoked before LLDB 288156952Sume /// launches a process for debugging. The callback must 289156952Sume /// do the following: 290156952Sume /// 1. Only do something if the plugin's behavior is enabled. 291156952Sume /// 2. Only make changes for processes that are relevant to the 292156952Sume /// plugin. The callback gets a pointer to the Target, which 293156952Sume /// can be inspected as needed. The ProcessLaunchInfo is 294156952Sume /// provided in read-write mode, and may be modified by the 295156952Sume /// plugin if, for instance, additional environment variables 296156952Sume /// are needed to support the feature when enabled. 297156952Sume /// 298156952Sume /// \return 299156952Sume /// Returns true upon success; otherwise, false. 300156952Sume static bool 301156952Sume RegisterPlugin(ConstString name, const char *description, 302156952Sume StructuredDataPluginCreateInstance create_callback, 303156952Sume DebuggerInitializeCallback debugger_init_callback = nullptr, 304156952Sume StructuredDataFilterLaunchInfo filter_callback = nullptr); 305186090Sume 306156956Sume static bool 307156956Sume UnregisterPlugin(StructuredDataPluginCreateInstance create_callback); 308156956Sume 309156952Sume static StructuredDataPluginCreateInstance 310156952Sume GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx); 311165258Sume 312165258Sume static StructuredDataPluginCreateInstance 313156952Sume GetStructuredDataPluginCreateCallbackForPluginName(ConstString name); 314156952Sume 315156952Sume static StructuredDataFilterLaunchInfo 316156952Sume GetStructuredDataFilterCallbackAtIndex(uint32_t idx, 317156952Sume bool &iteration_complete); 318156952Sume 319156952Sume // SymbolFile 320156952Sume static bool 321156952Sume RegisterPlugin(ConstString name, const char *description, 322156952Sume SymbolFileCreateInstance create_callback, 323156952Sume DebuggerInitializeCallback debugger_init_callback = nullptr); 324156952Sume 325156952Sume static bool UnregisterPlugin(SymbolFileCreateInstance create_callback); 326156956Sume 327156956Sume static SymbolFileCreateInstance 328156956Sume GetSymbolFileCreateCallbackAtIndex(uint32_t idx); 329156956Sume 330156956Sume static SymbolFileCreateInstance 331156956Sume GetSymbolFileCreateCallbackForPluginName(ConstString name); 332156956Sume 333156952Sume // SymbolVendor 334156952Sume static bool RegisterPlugin(ConstString name, const char *description, 335156952Sume SymbolVendorCreateInstance create_callback); 336156952Sume 337156952Sume static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback); 338156952Sume 339156952Sume static SymbolVendorCreateInstance 340156952Sume GetSymbolVendorCreateCallbackAtIndex(uint32_t idx); 341156952Sume 342156952Sume static SymbolVendorCreateInstance 343156952Sume GetSymbolVendorCreateCallbackForPluginName(ConstString name); 344156952Sume 345156952Sume // UnwindAssembly 346156952Sume static bool RegisterPlugin(ConstString name, const char *description, 347156952Sume UnwindAssemblyCreateInstance create_callback); 348156952Sume 349156952Sume static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback); 350156952Sume 351156952Sume static UnwindAssemblyCreateInstance 352156952Sume GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx); 353156952Sume 354156952Sume static UnwindAssemblyCreateInstance 355156952Sume GetUnwindAssemblyCreateCallbackForPluginName(ConstString name); 356156956Sume 357156952Sume // MemoryHistory 358156952Sume static bool RegisterPlugin(ConstString name, const char *description, 359156952Sume MemoryHistoryCreateInstance create_callback); 360156952Sume 361156952Sume static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback); 362156952Sume 363156952Sume static MemoryHistoryCreateInstance 364156952Sume GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx); 365156952Sume 366156952Sume static MemoryHistoryCreateInstance 367156952Sume GetMemoryHistoryCreateCallbackForPluginName(ConstString name); 368156952Sume 369156952Sume // InstrumentationRuntime 370156952Sume static bool 371156952Sume RegisterPlugin(ConstString name, const char *description, 372156952Sume InstrumentationRuntimeCreateInstance create_callback, 373156952Sume InstrumentationRuntimeGetType get_type_callback); 374156952Sume 375156952Sume static bool 376156952Sume UnregisterPlugin(InstrumentationRuntimeCreateInstance create_callback); 377156952Sume 378156952Sume static InstrumentationRuntimeGetType 379156952Sume GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx); 380156952Sume 381156952Sume static InstrumentationRuntimeCreateInstance 382156952Sume GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx); 383156952Sume 384156952Sume static InstrumentationRuntimeCreateInstance 385156952Sume GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name); 386156952Sume 387156952Sume // TypeSystem 388156952Sume static bool RegisterPlugin(ConstString name, const char *description, 389156952Sume TypeSystemCreateInstance create_callback, 390156952Sume LanguageSet supported_languages_for_types, 391156952Sume LanguageSet supported_languages_for_expressions); 392156952Sume 393156952Sume static bool UnregisterPlugin(TypeSystemCreateInstance create_callback); 394156952Sume 395156952Sume static TypeSystemCreateInstance 396156952Sume GetTypeSystemCreateCallbackAtIndex(uint32_t idx); 397156952Sume 398156952Sume static TypeSystemCreateInstance 399156952Sume GetTypeSystemCreateCallbackForPluginName(ConstString name); 400156952Sume 401156952Sume static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes(); 402156952Sume 403156952Sume static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions(); 404156952Sume 405156952Sume // REPL 406156952Sume static bool RegisterPlugin(ConstString name, const char *description, 407156952Sume REPLCreateInstance create_callback, 408156952Sume LanguageSet supported_languages); 409156952Sume 410156952Sume static bool UnregisterPlugin(REPLCreateInstance create_callback); 411156952Sume 412156952Sume static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx); 413156952Sume 414156952Sume static REPLCreateInstance 415156952Sume GetREPLCreateCallbackForPluginName(ConstString name); 416156952Sume 417156952Sume static LanguageSet GetREPLAllTypeSystemSupportedLanguages(); 418156952Sume 419156952Sume // Some plug-ins might register a DebuggerInitializeCallback callback when 420156952Sume // registering the plug-in. After a new Debugger instance is created, this 421156952Sume // DebuggerInitialize function will get called. This allows plug-ins to 422156952Sume // install Properties and do any other initialization that requires a 423186090Sume // debugger instance. 424156952Sume static void DebuggerInitialize(Debugger &debugger); 425156952Sume 426156952Sume static lldb::OptionValuePropertiesSP 427156952Sume GetSettingForDynamicLoaderPlugin(Debugger &debugger, 428156952Sume ConstString setting_name); 429156952Sume 430156952Sume static bool CreateSettingForDynamicLoaderPlugin( 431156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 432156952Sume ConstString description, bool is_global_property); 433156952Sume 434156952Sume static lldb::OptionValuePropertiesSP 435156952Sume GetSettingForPlatformPlugin(Debugger &debugger, ConstString setting_name); 436156952Sume 437156952Sume static bool CreateSettingForPlatformPlugin( 438156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 439156952Sume ConstString description, bool is_global_property); 440156952Sume 441156952Sume static lldb::OptionValuePropertiesSP 442156952Sume GetSettingForProcessPlugin(Debugger &debugger, ConstString setting_name); 443156952Sume 444156952Sume static bool CreateSettingForProcessPlugin( 445156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 446156952Sume ConstString description, bool is_global_property); 447156952Sume 448156956Sume static lldb::OptionValuePropertiesSP 449156956Sume GetSettingForSymbolFilePlugin(Debugger &debugger, ConstString setting_name); 450156956Sume 451156952Sume static bool CreateSettingForSymbolFilePlugin( 452156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 453156952Sume ConstString description, bool is_global_property); 454156952Sume 455156952Sume static lldb::OptionValuePropertiesSP 456156952Sume GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name); 457156952Sume 458156952Sume static bool CreateSettingForJITLoaderPlugin( 459156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 460156952Sume ConstString description, bool is_global_property); 461156952Sume 462156952Sume static lldb::OptionValuePropertiesSP 463156952Sume GetSettingForOperatingSystemPlugin(Debugger &debugger, 464156952Sume ConstString setting_name); 465156952Sume 466156952Sume static bool CreateSettingForOperatingSystemPlugin( 467156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 468156952Sume ConstString description, bool is_global_property); 469156952Sume 470156952Sume static lldb::OptionValuePropertiesSP 471156952Sume GetSettingForStructuredDataPlugin(Debugger &debugger, 472156952Sume ConstString setting_name); 473156952Sume 474186090Sume static bool CreateSettingForStructuredDataPlugin( 475156952Sume Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, 476156952Sume ConstString description, bool is_global_property); 477156952Sume}; 478156952Sume 479156952Sume} // namespace lldb_private 480156952Sume 481156952Sume#endif // liblldb_PluginManager_h_ 482156952Sume