| 1 | //===-- PluginManager.cpp -------------------------------------------------===// |
| 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 | #include "lldb/Core/PluginManager.h" |
| 10 | |
| 11 | #include "lldb/Core/Debugger.h" |
| 12 | #include "lldb/Host/FileSystem.h" |
| 13 | #include "lldb/Host/HostInfo.h" |
| 14 | #include "lldb/Interpreter/OptionValueProperties.h" |
| 15 | #include "lldb/Symbol/SaveCoreOptions.h" |
| 16 | #include "lldb/Target/Process.h" |
| 17 | #include "lldb/Utility/FileSpec.h" |
| 18 | #include "lldb/Utility/Status.h" |
| 19 | #include "lldb/Utility/StringList.h" |
| 20 | #include "llvm/ADT/StringRef.h" |
| 21 | #include "llvm/Support/DynamicLibrary.h" |
| 22 | #include "llvm/Support/FileSystem.h" |
| 23 | #include "llvm/Support/raw_ostream.h" |
| 24 | #include <cassert> |
| 25 | #include <map> |
| 26 | #include <memory> |
| 27 | #include <mutex> |
| 28 | #include <string> |
| 29 | #include <utility> |
| 30 | #include <vector> |
| 31 | #if defined(_WIN32) |
| 32 | #include "lldb/Host/windows/PosixApi.h" |
| 33 | #endif |
| 34 | |
| 35 | using namespace lldb; |
| 36 | using namespace lldb_private; |
| 37 | |
| 38 | typedef bool (*PluginInitCallback)(); |
| 39 | typedef void (*PluginTermCallback)(); |
| 40 | |
| 41 | struct PluginInfo { |
| 42 | PluginInfo() = default; |
| 43 | |
| 44 | llvm::sys::DynamicLibrary library; |
| 45 | PluginInitCallback plugin_init_callback = nullptr; |
| 46 | PluginTermCallback plugin_term_callback = nullptr; |
| 47 | }; |
| 48 | |
| 49 | typedef std::map<FileSpec, PluginInfo> PluginTerminateMap; |
| 50 | |
| 51 | static std::recursive_mutex &GetPluginMapMutex() { |
| 52 | static std::recursive_mutex g_plugin_map_mutex; |
| 53 | return g_plugin_map_mutex; |
| 54 | } |
| 55 | |
| 56 | static PluginTerminateMap &GetPluginMap() { |
| 57 | static PluginTerminateMap g_plugin_map; |
| 58 | return g_plugin_map; |
| 59 | } |
| 60 | |
| 61 | static bool PluginIsLoaded(const FileSpec &plugin_file_spec) { |
| 62 | std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex()); |
| 63 | PluginTerminateMap &plugin_map = GetPluginMap(); |
| 64 | return plugin_map.find(x: plugin_file_spec) != plugin_map.end(); |
| 65 | } |
| 66 | |
| 67 | static void SetPluginInfo(const FileSpec &plugin_file_spec, |
| 68 | const PluginInfo &plugin_info) { |
| 69 | std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex()); |
| 70 | PluginTerminateMap &plugin_map = GetPluginMap(); |
| 71 | assert(plugin_map.find(plugin_file_spec) == plugin_map.end()); |
| 72 | plugin_map[plugin_file_spec] = plugin_info; |
| 73 | } |
| 74 | |
| 75 | template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) { |
| 76 | return reinterpret_cast<FPtrTy>(VPtr); |
| 77 | } |
| 78 | |
| 79 | static FileSystem::EnumerateDirectoryResult |
| 80 | LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, |
| 81 | llvm::StringRef path) { |
| 82 | Status error; |
| 83 | |
| 84 | namespace fs = llvm::sys::fs; |
| 85 | // If we have a regular file, a symbolic link or unknown file type, try and |
| 86 | // process the file. We must handle unknown as sometimes the directory |
| 87 | // enumeration might be enumerating a file system that doesn't have correct |
| 88 | // file type information. |
| 89 | if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file || |
| 90 | ft == fs::file_type::type_unknown) { |
| 91 | FileSpec plugin_file_spec(path); |
| 92 | FileSystem::Instance().Resolve(file_spec&: plugin_file_spec); |
| 93 | |
| 94 | if (PluginIsLoaded(plugin_file_spec)) |
| 95 | return FileSystem::eEnumerateDirectoryResultNext; |
| 96 | else { |
| 97 | PluginInfo plugin_info; |
| 98 | |
| 99 | std::string pluginLoadError; |
| 100 | plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary( |
| 101 | filename: plugin_file_spec.GetPath().c_str(), errMsg: &pluginLoadError); |
| 102 | if (plugin_info.library.isValid()) { |
| 103 | bool success = false; |
| 104 | plugin_info.plugin_init_callback = CastToFPtr<PluginInitCallback>( |
| 105 | VPtr: plugin_info.library.getAddressOfSymbol(symbolName: "LLDBPluginInitialize" )); |
| 106 | if (plugin_info.plugin_init_callback) { |
| 107 | // Call the plug-in "bool LLDBPluginInitialize(void)" function |
| 108 | success = plugin_info.plugin_init_callback(); |
| 109 | } |
| 110 | |
| 111 | if (success) { |
| 112 | // It is ok for the "LLDBPluginTerminate" symbol to be nullptr |
| 113 | plugin_info.plugin_term_callback = CastToFPtr<PluginTermCallback>( |
| 114 | VPtr: plugin_info.library.getAddressOfSymbol(symbolName: "LLDBPluginTerminate" )); |
| 115 | } else { |
| 116 | // The initialize function returned FALSE which means the plug-in |
| 117 | // might not be compatible, or might be too new or too old, or might |
| 118 | // not want to run on this machine. Set it to a default-constructed |
| 119 | // instance to invalidate it. |
| 120 | plugin_info = PluginInfo(); |
| 121 | } |
| 122 | |
| 123 | // Regardless of success or failure, cache the plug-in load in our |
| 124 | // plug-in info so we don't try to load it again and again. |
| 125 | SetPluginInfo(plugin_file_spec, plugin_info); |
| 126 | |
| 127 | return FileSystem::eEnumerateDirectoryResultNext; |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | if (ft == fs::file_type::directory_file || |
| 133 | ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { |
| 134 | // Try and recurse into anything that a directory or symbolic link. We must |
| 135 | // also do this for unknown as sometimes the directory enumeration might be |
| 136 | // enumerating a file system that doesn't have correct file type |
| 137 | // information. |
| 138 | return FileSystem::eEnumerateDirectoryResultEnter; |
| 139 | } |
| 140 | |
| 141 | return FileSystem::eEnumerateDirectoryResultNext; |
| 142 | } |
| 143 | |
| 144 | void PluginManager::Initialize() { |
| 145 | const bool find_directories = true; |
| 146 | const bool find_files = true; |
| 147 | const bool find_other = true; |
| 148 | char dir_path[PATH_MAX]; |
| 149 | if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) { |
| 150 | if (FileSystem::Instance().Exists(file_spec: dir_spec) && |
| 151 | dir_spec.GetPath(path: dir_path, max_path_length: sizeof(dir_path))) { |
| 152 | FileSystem::Instance().EnumerateDirectory(path: dir_path, find_directories, |
| 153 | find_files, find_other, |
| 154 | callback: LoadPluginCallback, callback_baton: nullptr); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) { |
| 159 | if (FileSystem::Instance().Exists(file_spec: dir_spec) && |
| 160 | dir_spec.GetPath(path: dir_path, max_path_length: sizeof(dir_path))) { |
| 161 | FileSystem::Instance().EnumerateDirectory(path: dir_path, find_directories, |
| 162 | find_files, find_other, |
| 163 | callback: LoadPluginCallback, callback_baton: nullptr); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | void PluginManager::Terminate() { |
| 169 | std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex()); |
| 170 | PluginTerminateMap &plugin_map = GetPluginMap(); |
| 171 | |
| 172 | PluginTerminateMap::const_iterator pos, end = plugin_map.end(); |
| 173 | for (pos = plugin_map.begin(); pos != end; ++pos) { |
| 174 | // Call the plug-in "void LLDBPluginTerminate (void)" function if there is |
| 175 | // one (if the symbol was not nullptr). |
| 176 | if (pos->second.library.isValid()) { |
| 177 | if (pos->second.plugin_term_callback) |
| 178 | pos->second.plugin_term_callback(); |
| 179 | } |
| 180 | } |
| 181 | plugin_map.clear(); |
| 182 | } |
| 183 | |
| 184 | llvm::ArrayRef<PluginNamespace> PluginManager::GetPluginNamespaces() { |
| 185 | static PluginNamespace PluginNamespaces[] = { |
| 186 | |
| 187 | { |
| 188 | .name: "abi" , |
| 189 | .get_info: PluginManager::GetABIPluginInfo, |
| 190 | .set_enabled: PluginManager::SetABIPluginEnabled, |
| 191 | }, |
| 192 | |
| 193 | { |
| 194 | .name: "architecture" , |
| 195 | .get_info: PluginManager::GetArchitecturePluginInfo, |
| 196 | .set_enabled: PluginManager::SetArchitecturePluginEnabled, |
| 197 | }, |
| 198 | |
| 199 | { |
| 200 | .name: "disassembler" , |
| 201 | .get_info: PluginManager::GetDisassemblerPluginInfo, |
| 202 | .set_enabled: PluginManager::SetDisassemblerPluginEnabled, |
| 203 | }, |
| 204 | |
| 205 | { |
| 206 | .name: "dynamic-loader" , |
| 207 | .get_info: PluginManager::GetDynamicLoaderPluginInfo, |
| 208 | .set_enabled: PluginManager::SetDynamicLoaderPluginEnabled, |
| 209 | }, |
| 210 | |
| 211 | { |
| 212 | .name: "emulate-instruction" , |
| 213 | .get_info: PluginManager::GetEmulateInstructionPluginInfo, |
| 214 | .set_enabled: PluginManager::SetEmulateInstructionPluginEnabled, |
| 215 | }, |
| 216 | |
| 217 | { |
| 218 | .name: "instrumentation-runtime" , |
| 219 | .get_info: PluginManager::GetInstrumentationRuntimePluginInfo, |
| 220 | .set_enabled: PluginManager::SetInstrumentationRuntimePluginEnabled, |
| 221 | }, |
| 222 | |
| 223 | { |
| 224 | .name: "jit-loader" , |
| 225 | .get_info: PluginManager::GetJITLoaderPluginInfo, |
| 226 | .set_enabled: PluginManager::SetJITLoaderPluginEnabled, |
| 227 | }, |
| 228 | |
| 229 | { |
| 230 | .name: "language" , |
| 231 | .get_info: PluginManager::GetLanguagePluginInfo, |
| 232 | .set_enabled: PluginManager::SetLanguagePluginEnabled, |
| 233 | }, |
| 234 | |
| 235 | { |
| 236 | .name: "language-runtime" , |
| 237 | .get_info: PluginManager::GetLanguageRuntimePluginInfo, |
| 238 | .set_enabled: PluginManager::SetLanguageRuntimePluginEnabled, |
| 239 | }, |
| 240 | |
| 241 | { |
| 242 | .name: "memory-history" , |
| 243 | .get_info: PluginManager::GetMemoryHistoryPluginInfo, |
| 244 | .set_enabled: PluginManager::SetMemoryHistoryPluginEnabled, |
| 245 | }, |
| 246 | |
| 247 | { |
| 248 | .name: "object-container" , |
| 249 | .get_info: PluginManager::GetObjectContainerPluginInfo, |
| 250 | .set_enabled: PluginManager::SetObjectContainerPluginEnabled, |
| 251 | }, |
| 252 | |
| 253 | { |
| 254 | .name: "object-file" , |
| 255 | .get_info: PluginManager::GetObjectFilePluginInfo, |
| 256 | .set_enabled: PluginManager::SetObjectFilePluginEnabled, |
| 257 | }, |
| 258 | |
| 259 | { |
| 260 | .name: "operating-system" , |
| 261 | .get_info: PluginManager::GetOperatingSystemPluginInfo, |
| 262 | .set_enabled: PluginManager::SetOperatingSystemPluginEnabled, |
| 263 | }, |
| 264 | |
| 265 | { |
| 266 | .name: "platform" , |
| 267 | .get_info: PluginManager::GetPlatformPluginInfo, |
| 268 | .set_enabled: PluginManager::SetPlatformPluginEnabled, |
| 269 | }, |
| 270 | |
| 271 | { |
| 272 | .name: "process" , |
| 273 | .get_info: PluginManager::GetProcessPluginInfo, |
| 274 | .set_enabled: PluginManager::SetProcessPluginEnabled, |
| 275 | }, |
| 276 | |
| 277 | { |
| 278 | .name: "repl" , |
| 279 | .get_info: PluginManager::GetREPLPluginInfo, |
| 280 | .set_enabled: PluginManager::SetREPLPluginEnabled, |
| 281 | }, |
| 282 | |
| 283 | { |
| 284 | .name: "register-type-builder" , |
| 285 | .get_info: PluginManager::GetRegisterTypeBuilderPluginInfo, |
| 286 | .set_enabled: PluginManager::SetRegisterTypeBuilderPluginEnabled, |
| 287 | }, |
| 288 | |
| 289 | { |
| 290 | .name: "script-interpreter" , |
| 291 | .get_info: PluginManager::GetScriptInterpreterPluginInfo, |
| 292 | .set_enabled: PluginManager::SetScriptInterpreterPluginEnabled, |
| 293 | }, |
| 294 | |
| 295 | { |
| 296 | .name: "scripted-interface" , |
| 297 | .get_info: PluginManager::GetScriptedInterfacePluginInfo, |
| 298 | .set_enabled: PluginManager::SetScriptedInterfacePluginEnabled, |
| 299 | }, |
| 300 | |
| 301 | { |
| 302 | .name: "structured-data" , |
| 303 | .get_info: PluginManager::GetStructuredDataPluginInfo, |
| 304 | .set_enabled: PluginManager::SetStructuredDataPluginEnabled, |
| 305 | }, |
| 306 | |
| 307 | { |
| 308 | .name: "symbol-file" , |
| 309 | .get_info: PluginManager::GetSymbolFilePluginInfo, |
| 310 | .set_enabled: PluginManager::SetSymbolFilePluginEnabled, |
| 311 | }, |
| 312 | |
| 313 | { |
| 314 | .name: "symbol-locator" , |
| 315 | .get_info: PluginManager::GetSymbolLocatorPluginInfo, |
| 316 | .set_enabled: PluginManager::SetSymbolLocatorPluginEnabled, |
| 317 | }, |
| 318 | |
| 319 | { |
| 320 | .name: "symbol-vendor" , |
| 321 | .get_info: PluginManager::GetSymbolVendorPluginInfo, |
| 322 | .set_enabled: PluginManager::SetSymbolVendorPluginEnabled, |
| 323 | }, |
| 324 | |
| 325 | { |
| 326 | .name: "system-runtime" , |
| 327 | .get_info: PluginManager::GetSystemRuntimePluginInfo, |
| 328 | .set_enabled: PluginManager::SetSystemRuntimePluginEnabled, |
| 329 | }, |
| 330 | |
| 331 | { |
| 332 | .name: "trace" , |
| 333 | .get_info: PluginManager::GetTracePluginInfo, |
| 334 | .set_enabled: PluginManager::SetTracePluginEnabled, |
| 335 | }, |
| 336 | |
| 337 | { |
| 338 | .name: "trace-exporter" , |
| 339 | .get_info: PluginManager::GetTraceExporterPluginInfo, |
| 340 | .set_enabled: PluginManager::SetTraceExporterPluginEnabled, |
| 341 | }, |
| 342 | |
| 343 | { |
| 344 | .name: "type-system" , |
| 345 | .get_info: PluginManager::GetTypeSystemPluginInfo, |
| 346 | .set_enabled: PluginManager::SetTypeSystemPluginEnabled, |
| 347 | }, |
| 348 | |
| 349 | { |
| 350 | .name: "unwind-assembly" , |
| 351 | .get_info: PluginManager::GetUnwindAssemblyPluginInfo, |
| 352 | .set_enabled: PluginManager::SetUnwindAssemblyPluginEnabled, |
| 353 | }, |
| 354 | }; |
| 355 | |
| 356 | return PluginNamespaces; |
| 357 | } |
| 358 | |
| 359 | llvm::json::Object PluginManager::GetJSON(llvm::StringRef pattern) { |
| 360 | llvm::json::Object plugin_stats; |
| 361 | |
| 362 | for (const PluginNamespace &plugin_ns : GetPluginNamespaces()) { |
| 363 | llvm::json::Array namespace_stats; |
| 364 | |
| 365 | for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) { |
| 366 | if (MatchPluginName(pattern, plugin_ns, plugin)) { |
| 367 | llvm::json::Object plugin_json; |
| 368 | plugin_json.try_emplace(K: "name" , Args: plugin.name); |
| 369 | plugin_json.try_emplace(K: "enabled" , Args: plugin.enabled); |
| 370 | namespace_stats.emplace_back(A: std::move(plugin_json)); |
| 371 | } |
| 372 | } |
| 373 | if (!namespace_stats.empty()) |
| 374 | plugin_stats.try_emplace(K: plugin_ns.name, Args: std::move(namespace_stats)); |
| 375 | } |
| 376 | |
| 377 | return plugin_stats; |
| 378 | } |
| 379 | |
| 380 | bool PluginManager::MatchPluginName(llvm::StringRef pattern, |
| 381 | const PluginNamespace &plugin_ns, |
| 382 | const RegisteredPluginInfo &plugin_info) { |
| 383 | // The empty pattern matches all plugins. |
| 384 | if (pattern.empty()) |
| 385 | return true; |
| 386 | |
| 387 | // Check if the pattern matches the namespace. |
| 388 | if (pattern == plugin_ns.name) |
| 389 | return true; |
| 390 | |
| 391 | // Check if the pattern matches the qualified name. |
| 392 | std::string qualified_name = (plugin_ns.name + "." + plugin_info.name).str(); |
| 393 | return pattern == qualified_name; |
| 394 | } |
| 395 | |
| 396 | template <typename Callback> struct PluginInstance { |
| 397 | typedef Callback CallbackType; |
| 398 | |
| 399 | PluginInstance() = default; |
| 400 | PluginInstance(llvm::StringRef name, llvm::StringRef description, |
| 401 | Callback create_callback, |
| 402 | DebuggerInitializeCallback debugger_init_callback = nullptr) |
| 403 | : name(name), description(description), enabled(true), |
| 404 | create_callback(create_callback), |
| 405 | debugger_init_callback(debugger_init_callback) {} |
| 406 | |
| 407 | llvm::StringRef name; |
| 408 | llvm::StringRef description; |
| 409 | bool enabled; |
| 410 | Callback create_callback; |
| 411 | DebuggerInitializeCallback debugger_init_callback; |
| 412 | }; |
| 413 | |
| 414 | template <typename Instance> class PluginInstances { |
| 415 | public: |
| 416 | template <typename... Args> |
| 417 | bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, |
| 418 | typename Instance::CallbackType callback, |
| 419 | Args &&...args) { |
| 420 | if (!callback) |
| 421 | return false; |
| 422 | assert(!name.empty()); |
| 423 | m_instances.emplace_back(name, description, callback, |
| 424 | std::forward<Args>(args)...); |
| 425 | return true; |
| 426 | } |
| 427 | |
| 428 | bool UnregisterPlugin(typename Instance::CallbackType callback) { |
| 429 | if (!callback) |
| 430 | return false; |
| 431 | auto pos = m_instances.begin(); |
| 432 | auto end = m_instances.end(); |
| 433 | for (; pos != end; ++pos) { |
| 434 | if (pos->create_callback == callback) { |
| 435 | m_instances.erase(pos); |
| 436 | return true; |
| 437 | } |
| 438 | } |
| 439 | return false; |
| 440 | } |
| 441 | |
| 442 | typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) { |
| 443 | if (const Instance *instance = GetInstanceAtIndex(idx)) |
| 444 | return instance->create_callback; |
| 445 | return nullptr; |
| 446 | } |
| 447 | |
| 448 | llvm::StringRef GetDescriptionAtIndex(uint32_t idx) { |
| 449 | if (const Instance *instance = GetInstanceAtIndex(idx)) |
| 450 | return instance->description; |
| 451 | return "" ; |
| 452 | } |
| 453 | |
| 454 | llvm::StringRef GetNameAtIndex(uint32_t idx) { |
| 455 | if (const Instance *instance = GetInstanceAtIndex(idx)) |
| 456 | return instance->name; |
| 457 | return "" ; |
| 458 | } |
| 459 | |
| 460 | typename Instance::CallbackType GetCallbackForName(llvm::StringRef name) { |
| 461 | if (const Instance *instance = GetInstanceForName(name)) |
| 462 | return instance->create_callback; |
| 463 | return nullptr; |
| 464 | } |
| 465 | |
| 466 | void PerformDebuggerCallback(Debugger &debugger) { |
| 467 | for (const auto &instance : m_instances) { |
| 468 | if (!instance.enabled) |
| 469 | continue; |
| 470 | if (instance.debugger_init_callback) |
| 471 | instance.debugger_init_callback(debugger); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | // Return a copy of all the enabled instances. |
| 476 | // Note that this is a copy of the internal state so modifications |
| 477 | // to the returned instances will not be reflected back to instances |
| 478 | // stored by the PluginInstances object. |
| 479 | std::vector<Instance> GetSnapshot() { |
| 480 | std::vector<Instance> enabled_instances; |
| 481 | for (const auto &instance : m_instances) { |
| 482 | if (instance.enabled) |
| 483 | enabled_instances.push_back(instance); |
| 484 | } |
| 485 | return enabled_instances; |
| 486 | } |
| 487 | |
| 488 | const Instance *GetInstanceAtIndex(uint32_t idx) { |
| 489 | uint32_t count = 0; |
| 490 | |
| 491 | return FindEnabledInstance( |
| 492 | predicate: [&](const Instance &instance) { return count++ == idx; }); |
| 493 | } |
| 494 | |
| 495 | const Instance *GetInstanceForName(llvm::StringRef name) { |
| 496 | if (name.empty()) |
| 497 | return nullptr; |
| 498 | |
| 499 | return FindEnabledInstance( |
| 500 | predicate: [&](const Instance &instance) { return instance.name == name; }); |
| 501 | } |
| 502 | |
| 503 | const Instance * |
| 504 | FindEnabledInstance(std::function<bool(const Instance &)> predicate) const { |
| 505 | for (const auto &instance : m_instances) { |
| 506 | if (!instance.enabled) |
| 507 | continue; |
| 508 | if (predicate(instance)) |
| 509 | return &instance; |
| 510 | } |
| 511 | return nullptr; |
| 512 | } |
| 513 | |
| 514 | // Return a list of all the registered plugin instances. This includes both |
| 515 | // enabled and disabled instances. The instances are listed in the order they |
| 516 | // were registered which is the order they would be queried if they were all |
| 517 | // enabled. |
| 518 | std::vector<RegisteredPluginInfo> GetPluginInfoForAllInstances() { |
| 519 | // Lookup the plugin info for each instance in the sorted order. |
| 520 | std::vector<RegisteredPluginInfo> plugin_infos; |
| 521 | plugin_infos.reserve(n: m_instances.size()); |
| 522 | for (const Instance &instance : m_instances) |
| 523 | plugin_infos.push_back( |
| 524 | {instance.name, instance.description, instance.enabled}); |
| 525 | |
| 526 | return plugin_infos; |
| 527 | } |
| 528 | |
| 529 | bool SetInstanceEnabled(llvm::StringRef name, bool enable) { |
| 530 | auto it = llvm::find_if(m_instances, [&](const Instance &instance) { |
| 531 | return instance.name == name; |
| 532 | }); |
| 533 | |
| 534 | if (it == m_instances.end()) |
| 535 | return false; |
| 536 | |
| 537 | it->enabled = enable; |
| 538 | return true; |
| 539 | } |
| 540 | |
| 541 | private: |
| 542 | std::vector<Instance> m_instances; |
| 543 | }; |
| 544 | |
| 545 | #pragma mark ABI |
| 546 | |
| 547 | typedef PluginInstance<ABICreateInstance> ABIInstance; |
| 548 | typedef PluginInstances<ABIInstance> ABIInstances; |
| 549 | |
| 550 | static ABIInstances &GetABIInstances() { |
| 551 | static ABIInstances g_instances; |
| 552 | return g_instances; |
| 553 | } |
| 554 | |
| 555 | bool PluginManager::RegisterPlugin(llvm::StringRef name, |
| 556 | llvm::StringRef description, |
| 557 | ABICreateInstance create_callback) { |
| 558 | return GetABIInstances().RegisterPlugin(name, description, callback: create_callback); |
| 559 | } |
| 560 | |
| 561 | bool PluginManager::UnregisterPlugin(ABICreateInstance create_callback) { |
| 562 | return GetABIInstances().UnregisterPlugin(callback: create_callback); |
| 563 | } |
| 564 | |
| 565 | ABICreateInstance PluginManager::GetABICreateCallbackAtIndex(uint32_t idx) { |
| 566 | return GetABIInstances().GetCallbackAtIndex(idx); |
| 567 | } |
| 568 | |
| 569 | #pragma mark Architecture |
| 570 | |
| 571 | typedef PluginInstance<ArchitectureCreateInstance> ArchitectureInstance; |
| 572 | typedef PluginInstances<ArchitectureInstance> ArchitectureInstances; |
| 573 | |
| 574 | static ArchitectureInstances &GetArchitectureInstances() { |
| 575 | static ArchitectureInstances g_instances; |
| 576 | return g_instances; |
| 577 | } |
| 578 | |
| 579 | void PluginManager::RegisterPlugin(llvm::StringRef name, |
| 580 | llvm::StringRef description, |
| 581 | ArchitectureCreateInstance create_callback) { |
| 582 | GetArchitectureInstances().RegisterPlugin(name, description, callback: create_callback); |
| 583 | } |
| 584 | |
| 585 | void PluginManager::UnregisterPlugin( |
| 586 | ArchitectureCreateInstance create_callback) { |
| 587 | auto &instances = GetArchitectureInstances(); |
| 588 | instances.UnregisterPlugin(callback: create_callback); |
| 589 | } |
| 590 | |
| 591 | std::unique_ptr<Architecture> |
| 592 | PluginManager::CreateArchitectureInstance(const ArchSpec &arch) { |
| 593 | for (const auto &instances : GetArchitectureInstances().GetSnapshot()) { |
| 594 | if (auto plugin_up = instances.create_callback(arch)) |
| 595 | return plugin_up; |
| 596 | } |
| 597 | return nullptr; |
| 598 | } |
| 599 | |
| 600 | #pragma mark Disassembler |
| 601 | |
| 602 | typedef PluginInstance<DisassemblerCreateInstance> DisassemblerInstance; |
| 603 | typedef PluginInstances<DisassemblerInstance> DisassemblerInstances; |
| 604 | |
| 605 | static DisassemblerInstances &GetDisassemblerInstances() { |
| 606 | static DisassemblerInstances g_instances; |
| 607 | return g_instances; |
| 608 | } |
| 609 | |
| 610 | bool PluginManager::RegisterPlugin(llvm::StringRef name, |
| 611 | llvm::StringRef description, |
| 612 | DisassemblerCreateInstance create_callback) { |
| 613 | return GetDisassemblerInstances().RegisterPlugin(name, description, |
| 614 | callback: create_callback); |
| 615 | } |
| 616 | |
| 617 | bool PluginManager::UnregisterPlugin( |
| 618 | DisassemblerCreateInstance create_callback) { |
| 619 | return GetDisassemblerInstances().UnregisterPlugin(callback: create_callback); |
| 620 | } |
| 621 | |
| 622 | DisassemblerCreateInstance |
| 623 | PluginManager::GetDisassemblerCreateCallbackAtIndex(uint32_t idx) { |
| 624 | return GetDisassemblerInstances().GetCallbackAtIndex(idx); |
| 625 | } |
| 626 | |
| 627 | DisassemblerCreateInstance |
| 628 | PluginManager::GetDisassemblerCreateCallbackForPluginName( |
| 629 | llvm::StringRef name) { |
| 630 | return GetDisassemblerInstances().GetCallbackForName(name); |
| 631 | } |
| 632 | |
| 633 | #pragma mark DynamicLoader |
| 634 | |
| 635 | typedef PluginInstance<DynamicLoaderCreateInstance> DynamicLoaderInstance; |
| 636 | typedef PluginInstances<DynamicLoaderInstance> DynamicLoaderInstances; |
| 637 | |
| 638 | static DynamicLoaderInstances &GetDynamicLoaderInstances() { |
| 639 | static DynamicLoaderInstances g_instances; |
| 640 | return g_instances; |
| 641 | } |
| 642 | |
| 643 | bool PluginManager::RegisterPlugin( |
| 644 | llvm::StringRef name, llvm::StringRef description, |
| 645 | DynamicLoaderCreateInstance create_callback, |
| 646 | DebuggerInitializeCallback debugger_init_callback) { |
| 647 | return GetDynamicLoaderInstances().RegisterPlugin( |
| 648 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 649 | } |
| 650 | |
| 651 | bool PluginManager::UnregisterPlugin( |
| 652 | DynamicLoaderCreateInstance create_callback) { |
| 653 | return GetDynamicLoaderInstances().UnregisterPlugin(callback: create_callback); |
| 654 | } |
| 655 | |
| 656 | DynamicLoaderCreateInstance |
| 657 | PluginManager::GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx) { |
| 658 | return GetDynamicLoaderInstances().GetCallbackAtIndex(idx); |
| 659 | } |
| 660 | |
| 661 | DynamicLoaderCreateInstance |
| 662 | PluginManager::GetDynamicLoaderCreateCallbackForPluginName( |
| 663 | llvm::StringRef name) { |
| 664 | return GetDynamicLoaderInstances().GetCallbackForName(name); |
| 665 | } |
| 666 | |
| 667 | #pragma mark JITLoader |
| 668 | |
| 669 | typedef PluginInstance<JITLoaderCreateInstance> JITLoaderInstance; |
| 670 | typedef PluginInstances<JITLoaderInstance> JITLoaderInstances; |
| 671 | |
| 672 | static JITLoaderInstances &GetJITLoaderInstances() { |
| 673 | static JITLoaderInstances g_instances; |
| 674 | return g_instances; |
| 675 | } |
| 676 | |
| 677 | bool PluginManager::RegisterPlugin( |
| 678 | llvm::StringRef name, llvm::StringRef description, |
| 679 | JITLoaderCreateInstance create_callback, |
| 680 | DebuggerInitializeCallback debugger_init_callback) { |
| 681 | return GetJITLoaderInstances().RegisterPlugin( |
| 682 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 683 | } |
| 684 | |
| 685 | bool PluginManager::UnregisterPlugin(JITLoaderCreateInstance create_callback) { |
| 686 | return GetJITLoaderInstances().UnregisterPlugin(callback: create_callback); |
| 687 | } |
| 688 | |
| 689 | JITLoaderCreateInstance |
| 690 | PluginManager::GetJITLoaderCreateCallbackAtIndex(uint32_t idx) { |
| 691 | return GetJITLoaderInstances().GetCallbackAtIndex(idx); |
| 692 | } |
| 693 | |
| 694 | #pragma mark EmulateInstruction |
| 695 | |
| 696 | typedef PluginInstance<EmulateInstructionCreateInstance> |
| 697 | EmulateInstructionInstance; |
| 698 | typedef PluginInstances<EmulateInstructionInstance> EmulateInstructionInstances; |
| 699 | |
| 700 | static EmulateInstructionInstances &GetEmulateInstructionInstances() { |
| 701 | static EmulateInstructionInstances g_instances; |
| 702 | return g_instances; |
| 703 | } |
| 704 | |
| 705 | bool PluginManager::RegisterPlugin( |
| 706 | llvm::StringRef name, llvm::StringRef description, |
| 707 | EmulateInstructionCreateInstance create_callback) { |
| 708 | return GetEmulateInstructionInstances().RegisterPlugin(name, description, |
| 709 | callback: create_callback); |
| 710 | } |
| 711 | |
| 712 | bool PluginManager::UnregisterPlugin( |
| 713 | EmulateInstructionCreateInstance create_callback) { |
| 714 | return GetEmulateInstructionInstances().UnregisterPlugin(callback: create_callback); |
| 715 | } |
| 716 | |
| 717 | EmulateInstructionCreateInstance |
| 718 | PluginManager::GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx) { |
| 719 | return GetEmulateInstructionInstances().GetCallbackAtIndex(idx); |
| 720 | } |
| 721 | |
| 722 | EmulateInstructionCreateInstance |
| 723 | PluginManager::GetEmulateInstructionCreateCallbackForPluginName( |
| 724 | llvm::StringRef name) { |
| 725 | return GetEmulateInstructionInstances().GetCallbackForName(name); |
| 726 | } |
| 727 | |
| 728 | #pragma mark OperatingSystem |
| 729 | |
| 730 | typedef PluginInstance<OperatingSystemCreateInstance> OperatingSystemInstance; |
| 731 | typedef PluginInstances<OperatingSystemInstance> OperatingSystemInstances; |
| 732 | |
| 733 | static OperatingSystemInstances &GetOperatingSystemInstances() { |
| 734 | static OperatingSystemInstances g_instances; |
| 735 | return g_instances; |
| 736 | } |
| 737 | |
| 738 | bool PluginManager::RegisterPlugin( |
| 739 | llvm::StringRef name, llvm::StringRef description, |
| 740 | OperatingSystemCreateInstance create_callback, |
| 741 | DebuggerInitializeCallback debugger_init_callback) { |
| 742 | return GetOperatingSystemInstances().RegisterPlugin( |
| 743 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 744 | } |
| 745 | |
| 746 | bool PluginManager::UnregisterPlugin( |
| 747 | OperatingSystemCreateInstance create_callback) { |
| 748 | return GetOperatingSystemInstances().UnregisterPlugin(callback: create_callback); |
| 749 | } |
| 750 | |
| 751 | OperatingSystemCreateInstance |
| 752 | PluginManager::GetOperatingSystemCreateCallbackAtIndex(uint32_t idx) { |
| 753 | return GetOperatingSystemInstances().GetCallbackAtIndex(idx); |
| 754 | } |
| 755 | |
| 756 | OperatingSystemCreateInstance |
| 757 | PluginManager::GetOperatingSystemCreateCallbackForPluginName( |
| 758 | llvm::StringRef name) { |
| 759 | return GetOperatingSystemInstances().GetCallbackForName(name); |
| 760 | } |
| 761 | |
| 762 | #pragma mark Language |
| 763 | |
| 764 | typedef PluginInstance<LanguageCreateInstance> LanguageInstance; |
| 765 | typedef PluginInstances<LanguageInstance> LanguageInstances; |
| 766 | |
| 767 | static LanguageInstances &GetLanguageInstances() { |
| 768 | static LanguageInstances g_instances; |
| 769 | return g_instances; |
| 770 | } |
| 771 | |
| 772 | bool PluginManager::RegisterPlugin( |
| 773 | llvm::StringRef name, llvm::StringRef description, |
| 774 | LanguageCreateInstance create_callback, |
| 775 | DebuggerInitializeCallback debugger_init_callback) { |
| 776 | return GetLanguageInstances().RegisterPlugin( |
| 777 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 778 | } |
| 779 | |
| 780 | bool PluginManager::UnregisterPlugin(LanguageCreateInstance create_callback) { |
| 781 | return GetLanguageInstances().UnregisterPlugin(callback: create_callback); |
| 782 | } |
| 783 | |
| 784 | LanguageCreateInstance |
| 785 | PluginManager::GetLanguageCreateCallbackAtIndex(uint32_t idx) { |
| 786 | return GetLanguageInstances().GetCallbackAtIndex(idx); |
| 787 | } |
| 788 | |
| 789 | #pragma mark LanguageRuntime |
| 790 | |
| 791 | struct LanguageRuntimeInstance |
| 792 | : public PluginInstance<LanguageRuntimeCreateInstance> { |
| 793 | LanguageRuntimeInstance( |
| 794 | llvm::StringRef name, llvm::StringRef description, |
| 795 | CallbackType create_callback, |
| 796 | DebuggerInitializeCallback debugger_init_callback, |
| 797 | LanguageRuntimeGetCommandObject command_callback, |
| 798 | LanguageRuntimeGetExceptionPrecondition precondition_callback) |
| 799 | : PluginInstance<LanguageRuntimeCreateInstance>( |
| 800 | name, description, create_callback, debugger_init_callback), |
| 801 | command_callback(command_callback), |
| 802 | precondition_callback(precondition_callback) {} |
| 803 | |
| 804 | LanguageRuntimeGetCommandObject command_callback; |
| 805 | LanguageRuntimeGetExceptionPrecondition precondition_callback; |
| 806 | }; |
| 807 | |
| 808 | typedef PluginInstances<LanguageRuntimeInstance> LanguageRuntimeInstances; |
| 809 | |
| 810 | static LanguageRuntimeInstances &GetLanguageRuntimeInstances() { |
| 811 | static LanguageRuntimeInstances g_instances; |
| 812 | return g_instances; |
| 813 | } |
| 814 | |
| 815 | bool PluginManager::RegisterPlugin( |
| 816 | llvm::StringRef name, llvm::StringRef description, |
| 817 | LanguageRuntimeCreateInstance create_callback, |
| 818 | LanguageRuntimeGetCommandObject command_callback, |
| 819 | LanguageRuntimeGetExceptionPrecondition precondition_callback) { |
| 820 | return GetLanguageRuntimeInstances().RegisterPlugin( |
| 821 | name, description, callback: create_callback, args: nullptr, args&: command_callback, |
| 822 | args&: precondition_callback); |
| 823 | } |
| 824 | |
| 825 | bool PluginManager::UnregisterPlugin( |
| 826 | LanguageRuntimeCreateInstance create_callback) { |
| 827 | return GetLanguageRuntimeInstances().UnregisterPlugin(callback: create_callback); |
| 828 | } |
| 829 | |
| 830 | LanguageRuntimeCreateInstance |
| 831 | PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx) { |
| 832 | return GetLanguageRuntimeInstances().GetCallbackAtIndex(idx); |
| 833 | } |
| 834 | |
| 835 | LanguageRuntimeGetCommandObject |
| 836 | PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx) { |
| 837 | if (auto instance = GetLanguageRuntimeInstances().GetInstanceAtIndex(idx)) |
| 838 | return instance->command_callback; |
| 839 | return nullptr; |
| 840 | } |
| 841 | |
| 842 | LanguageRuntimeGetExceptionPrecondition |
| 843 | PluginManager::GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx) { |
| 844 | if (auto instance = GetLanguageRuntimeInstances().GetInstanceAtIndex(idx)) |
| 845 | return instance->precondition_callback; |
| 846 | return nullptr; |
| 847 | } |
| 848 | |
| 849 | #pragma mark SystemRuntime |
| 850 | |
| 851 | typedef PluginInstance<SystemRuntimeCreateInstance> SystemRuntimeInstance; |
| 852 | typedef PluginInstances<SystemRuntimeInstance> SystemRuntimeInstances; |
| 853 | |
| 854 | static SystemRuntimeInstances &GetSystemRuntimeInstances() { |
| 855 | static SystemRuntimeInstances g_instances; |
| 856 | return g_instances; |
| 857 | } |
| 858 | |
| 859 | bool PluginManager::RegisterPlugin( |
| 860 | llvm::StringRef name, llvm::StringRef description, |
| 861 | SystemRuntimeCreateInstance create_callback) { |
| 862 | return GetSystemRuntimeInstances().RegisterPlugin(name, description, |
| 863 | callback: create_callback); |
| 864 | } |
| 865 | |
| 866 | bool PluginManager::UnregisterPlugin( |
| 867 | SystemRuntimeCreateInstance create_callback) { |
| 868 | return GetSystemRuntimeInstances().UnregisterPlugin(callback: create_callback); |
| 869 | } |
| 870 | |
| 871 | SystemRuntimeCreateInstance |
| 872 | PluginManager::GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx) { |
| 873 | return GetSystemRuntimeInstances().GetCallbackAtIndex(idx); |
| 874 | } |
| 875 | |
| 876 | #pragma mark ObjectFile |
| 877 | |
| 878 | struct ObjectFileInstance : public PluginInstance<ObjectFileCreateInstance> { |
| 879 | ObjectFileInstance( |
| 880 | llvm::StringRef name, llvm::StringRef description, |
| 881 | CallbackType create_callback, |
| 882 | ObjectFileCreateMemoryInstance create_memory_callback, |
| 883 | ObjectFileGetModuleSpecifications get_module_specifications, |
| 884 | ObjectFileSaveCore save_core, |
| 885 | DebuggerInitializeCallback debugger_init_callback) |
| 886 | : PluginInstance<ObjectFileCreateInstance>( |
| 887 | name, description, create_callback, debugger_init_callback), |
| 888 | create_memory_callback(create_memory_callback), |
| 889 | get_module_specifications(get_module_specifications), |
| 890 | save_core(save_core) {} |
| 891 | |
| 892 | ObjectFileCreateMemoryInstance create_memory_callback; |
| 893 | ObjectFileGetModuleSpecifications get_module_specifications; |
| 894 | ObjectFileSaveCore save_core; |
| 895 | }; |
| 896 | typedef PluginInstances<ObjectFileInstance> ObjectFileInstances; |
| 897 | |
| 898 | static ObjectFileInstances &GetObjectFileInstances() { |
| 899 | static ObjectFileInstances g_instances; |
| 900 | return g_instances; |
| 901 | } |
| 902 | |
| 903 | bool PluginManager::IsRegisteredObjectFilePluginName(llvm::StringRef name) { |
| 904 | if (name.empty()) |
| 905 | return false; |
| 906 | |
| 907 | return GetObjectFileInstances().GetInstanceForName(name) != nullptr; |
| 908 | } |
| 909 | |
| 910 | bool PluginManager::RegisterPlugin( |
| 911 | llvm::StringRef name, llvm::StringRef description, |
| 912 | ObjectFileCreateInstance create_callback, |
| 913 | ObjectFileCreateMemoryInstance create_memory_callback, |
| 914 | ObjectFileGetModuleSpecifications get_module_specifications, |
| 915 | ObjectFileSaveCore save_core, |
| 916 | DebuggerInitializeCallback debugger_init_callback) { |
| 917 | return GetObjectFileInstances().RegisterPlugin( |
| 918 | name, description, callback: create_callback, args&: create_memory_callback, |
| 919 | args&: get_module_specifications, args&: save_core, args&: debugger_init_callback); |
| 920 | } |
| 921 | |
| 922 | bool PluginManager::UnregisterPlugin(ObjectFileCreateInstance create_callback) { |
| 923 | return GetObjectFileInstances().UnregisterPlugin(callback: create_callback); |
| 924 | } |
| 925 | |
| 926 | ObjectFileCreateInstance |
| 927 | PluginManager::GetObjectFileCreateCallbackAtIndex(uint32_t idx) { |
| 928 | return GetObjectFileInstances().GetCallbackAtIndex(idx); |
| 929 | } |
| 930 | |
| 931 | ObjectFileCreateMemoryInstance |
| 932 | PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx) { |
| 933 | if (auto instance = GetObjectFileInstances().GetInstanceAtIndex(idx)) |
| 934 | return instance->create_memory_callback; |
| 935 | return nullptr; |
| 936 | } |
| 937 | |
| 938 | ObjectFileGetModuleSpecifications |
| 939 | PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex( |
| 940 | uint32_t idx) { |
| 941 | if (auto instance = GetObjectFileInstances().GetInstanceAtIndex(idx)) |
| 942 | return instance->get_module_specifications; |
| 943 | return nullptr; |
| 944 | } |
| 945 | |
| 946 | ObjectFileCreateMemoryInstance |
| 947 | PluginManager::GetObjectFileCreateMemoryCallbackForPluginName( |
| 948 | llvm::StringRef name) { |
| 949 | if (auto instance = GetObjectFileInstances().GetInstanceForName(name)) |
| 950 | return instance->create_memory_callback; |
| 951 | return nullptr; |
| 952 | } |
| 953 | |
| 954 | Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp, |
| 955 | lldb_private::SaveCoreOptions &options) { |
| 956 | Status error; |
| 957 | if (!options.GetOutputFile()) { |
| 958 | error = Status::FromErrorString(str: "No output file specified" ); |
| 959 | return error; |
| 960 | } |
| 961 | |
| 962 | if (!process_sp) { |
| 963 | error = Status::FromErrorString(str: "Invalid process" ); |
| 964 | return error; |
| 965 | } |
| 966 | |
| 967 | error = options.EnsureValidConfiguration(process_sp); |
| 968 | if (error.Fail()) |
| 969 | return error; |
| 970 | |
| 971 | if (!options.GetPluginName().has_value()) { |
| 972 | // Try saving core directly from the process plugin first. |
| 973 | llvm::Expected<bool> ret = |
| 974 | process_sp->SaveCore(outfile: options.GetOutputFile()->GetPath()); |
| 975 | if (!ret) |
| 976 | return Status::FromError(error: ret.takeError()); |
| 977 | if (ret.get()) |
| 978 | return Status(); |
| 979 | } |
| 980 | |
| 981 | // Fall back to object plugins. |
| 982 | const auto &plugin_name = options.GetPluginName().value_or(u: "" ); |
| 983 | auto instances = GetObjectFileInstances().GetSnapshot(); |
| 984 | for (auto &instance : instances) { |
| 985 | if (plugin_name.empty() || instance.name == plugin_name) { |
| 986 | if (instance.save_core && instance.save_core(process_sp, options, error)) |
| 987 | return error; |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | // Check to see if any of the object file plugins tried and failed to save. |
| 992 | // if any failure, return the error message. |
| 993 | if (error.Fail()) |
| 994 | return error; |
| 995 | |
| 996 | // Report only for the plugin that was specified. |
| 997 | if (!plugin_name.empty()) |
| 998 | return Status::FromErrorStringWithFormatv( |
| 999 | format: "The \"{}\" plugin is not able to save a core for this process." , |
| 1000 | args: plugin_name); |
| 1001 | |
| 1002 | return Status::FromErrorString( |
| 1003 | str: "no ObjectFile plugins were able to save a core for this process" ); |
| 1004 | } |
| 1005 | |
| 1006 | std::vector<llvm::StringRef> PluginManager::GetSaveCorePluginNames() { |
| 1007 | std::vector<llvm::StringRef> plugin_names; |
| 1008 | auto instances = GetObjectFileInstances().GetSnapshot(); |
| 1009 | for (auto &instance : instances) { |
| 1010 | if (instance.save_core) |
| 1011 | plugin_names.emplace_back(args&: instance.name); |
| 1012 | } |
| 1013 | return plugin_names; |
| 1014 | } |
| 1015 | |
| 1016 | #pragma mark ObjectContainer |
| 1017 | |
| 1018 | struct ObjectContainerInstance |
| 1019 | : public PluginInstance<ObjectContainerCreateInstance> { |
| 1020 | ObjectContainerInstance( |
| 1021 | llvm::StringRef name, llvm::StringRef description, |
| 1022 | CallbackType create_callback, |
| 1023 | ObjectContainerCreateMemoryInstance create_memory_callback, |
| 1024 | ObjectFileGetModuleSpecifications get_module_specifications) |
| 1025 | : PluginInstance<ObjectContainerCreateInstance>(name, description, |
| 1026 | create_callback), |
| 1027 | create_memory_callback(create_memory_callback), |
| 1028 | get_module_specifications(get_module_specifications) {} |
| 1029 | |
| 1030 | ObjectContainerCreateMemoryInstance create_memory_callback; |
| 1031 | ObjectFileGetModuleSpecifications get_module_specifications; |
| 1032 | }; |
| 1033 | typedef PluginInstances<ObjectContainerInstance> ObjectContainerInstances; |
| 1034 | |
| 1035 | static ObjectContainerInstances &GetObjectContainerInstances() { |
| 1036 | static ObjectContainerInstances g_instances; |
| 1037 | return g_instances; |
| 1038 | } |
| 1039 | |
| 1040 | bool PluginManager::RegisterPlugin( |
| 1041 | llvm::StringRef name, llvm::StringRef description, |
| 1042 | ObjectContainerCreateInstance create_callback, |
| 1043 | ObjectFileGetModuleSpecifications get_module_specifications, |
| 1044 | ObjectContainerCreateMemoryInstance create_memory_callback) { |
| 1045 | return GetObjectContainerInstances().RegisterPlugin( |
| 1046 | name, description, callback: create_callback, args&: create_memory_callback, |
| 1047 | args&: get_module_specifications); |
| 1048 | } |
| 1049 | |
| 1050 | bool PluginManager::UnregisterPlugin( |
| 1051 | ObjectContainerCreateInstance create_callback) { |
| 1052 | return GetObjectContainerInstances().UnregisterPlugin(callback: create_callback); |
| 1053 | } |
| 1054 | |
| 1055 | ObjectContainerCreateInstance |
| 1056 | PluginManager::GetObjectContainerCreateCallbackAtIndex(uint32_t idx) { |
| 1057 | return GetObjectContainerInstances().GetCallbackAtIndex(idx); |
| 1058 | } |
| 1059 | |
| 1060 | ObjectContainerCreateMemoryInstance |
| 1061 | PluginManager::GetObjectContainerCreateMemoryCallbackAtIndex(uint32_t idx) { |
| 1062 | if (auto instance = GetObjectContainerInstances().GetInstanceAtIndex(idx)) |
| 1063 | return instance->create_memory_callback; |
| 1064 | return nullptr; |
| 1065 | } |
| 1066 | |
| 1067 | ObjectFileGetModuleSpecifications |
| 1068 | PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex( |
| 1069 | uint32_t idx) { |
| 1070 | if (auto instance = GetObjectContainerInstances().GetInstanceAtIndex(idx)) |
| 1071 | return instance->get_module_specifications; |
| 1072 | return nullptr; |
| 1073 | } |
| 1074 | |
| 1075 | #pragma mark Platform |
| 1076 | |
| 1077 | typedef PluginInstance<PlatformCreateInstance> PlatformInstance; |
| 1078 | typedef PluginInstances<PlatformInstance> PlatformInstances; |
| 1079 | |
| 1080 | static PlatformInstances &GetPlatformInstances() { |
| 1081 | static PlatformInstances g_platform_instances; |
| 1082 | return g_platform_instances; |
| 1083 | } |
| 1084 | |
| 1085 | bool PluginManager::RegisterPlugin( |
| 1086 | llvm::StringRef name, llvm::StringRef description, |
| 1087 | PlatformCreateInstance create_callback, |
| 1088 | DebuggerInitializeCallback debugger_init_callback) { |
| 1089 | return GetPlatformInstances().RegisterPlugin( |
| 1090 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 1091 | } |
| 1092 | |
| 1093 | bool PluginManager::UnregisterPlugin(PlatformCreateInstance create_callback) { |
| 1094 | return GetPlatformInstances().UnregisterPlugin(callback: create_callback); |
| 1095 | } |
| 1096 | |
| 1097 | llvm::StringRef PluginManager::GetPlatformPluginNameAtIndex(uint32_t idx) { |
| 1098 | return GetPlatformInstances().GetNameAtIndex(idx); |
| 1099 | } |
| 1100 | |
| 1101 | llvm::StringRef |
| 1102 | PluginManager::GetPlatformPluginDescriptionAtIndex(uint32_t idx) { |
| 1103 | return GetPlatformInstances().GetDescriptionAtIndex(idx); |
| 1104 | } |
| 1105 | |
| 1106 | PlatformCreateInstance |
| 1107 | PluginManager::GetPlatformCreateCallbackAtIndex(uint32_t idx) { |
| 1108 | return GetPlatformInstances().GetCallbackAtIndex(idx); |
| 1109 | } |
| 1110 | |
| 1111 | PlatformCreateInstance |
| 1112 | PluginManager::GetPlatformCreateCallbackForPluginName(llvm::StringRef name) { |
| 1113 | return GetPlatformInstances().GetCallbackForName(name); |
| 1114 | } |
| 1115 | |
| 1116 | void PluginManager::AutoCompletePlatformName(llvm::StringRef name, |
| 1117 | CompletionRequest &request) { |
| 1118 | for (const auto &instance : GetPlatformInstances().GetSnapshot()) { |
| 1119 | if (instance.name.starts_with(Prefix: name)) |
| 1120 | request.AddCompletion(completion: instance.name); |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | #pragma mark Process |
| 1125 | |
| 1126 | typedef PluginInstance<ProcessCreateInstance> ProcessInstance; |
| 1127 | typedef PluginInstances<ProcessInstance> ProcessInstances; |
| 1128 | |
| 1129 | static ProcessInstances &GetProcessInstances() { |
| 1130 | static ProcessInstances g_instances; |
| 1131 | return g_instances; |
| 1132 | } |
| 1133 | |
| 1134 | bool PluginManager::RegisterPlugin( |
| 1135 | llvm::StringRef name, llvm::StringRef description, |
| 1136 | ProcessCreateInstance create_callback, |
| 1137 | DebuggerInitializeCallback debugger_init_callback) { |
| 1138 | return GetProcessInstances().RegisterPlugin( |
| 1139 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 1140 | } |
| 1141 | |
| 1142 | bool PluginManager::UnregisterPlugin(ProcessCreateInstance create_callback) { |
| 1143 | return GetProcessInstances().UnregisterPlugin(callback: create_callback); |
| 1144 | } |
| 1145 | |
| 1146 | llvm::StringRef PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) { |
| 1147 | return GetProcessInstances().GetNameAtIndex(idx); |
| 1148 | } |
| 1149 | |
| 1150 | llvm::StringRef PluginManager::GetProcessPluginDescriptionAtIndex(uint32_t idx) { |
| 1151 | return GetProcessInstances().GetDescriptionAtIndex(idx); |
| 1152 | } |
| 1153 | |
| 1154 | ProcessCreateInstance |
| 1155 | PluginManager::GetProcessCreateCallbackAtIndex(uint32_t idx) { |
| 1156 | return GetProcessInstances().GetCallbackAtIndex(idx); |
| 1157 | } |
| 1158 | |
| 1159 | ProcessCreateInstance |
| 1160 | PluginManager::GetProcessCreateCallbackForPluginName(llvm::StringRef name) { |
| 1161 | return GetProcessInstances().GetCallbackForName(name); |
| 1162 | } |
| 1163 | |
| 1164 | void PluginManager::AutoCompleteProcessName(llvm::StringRef name, |
| 1165 | CompletionRequest &request) { |
| 1166 | for (const auto &instance : GetProcessInstances().GetSnapshot()) { |
| 1167 | if (instance.name.starts_with(Prefix: name)) |
| 1168 | request.AddCompletion(completion: instance.name, description: instance.description); |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | #pragma mark ProtocolServer |
| 1173 | |
| 1174 | typedef PluginInstance<ProtocolServerCreateInstance> ProtocolServerInstance; |
| 1175 | typedef PluginInstances<ProtocolServerInstance> ProtocolServerInstances; |
| 1176 | |
| 1177 | static ProtocolServerInstances &GetProtocolServerInstances() { |
| 1178 | static ProtocolServerInstances g_instances; |
| 1179 | return g_instances; |
| 1180 | } |
| 1181 | |
| 1182 | bool PluginManager::RegisterPlugin( |
| 1183 | llvm::StringRef name, llvm::StringRef description, |
| 1184 | ProtocolServerCreateInstance create_callback) { |
| 1185 | return GetProtocolServerInstances().RegisterPlugin(name, description, |
| 1186 | callback: create_callback); |
| 1187 | } |
| 1188 | |
| 1189 | bool PluginManager::UnregisterPlugin( |
| 1190 | ProtocolServerCreateInstance create_callback) { |
| 1191 | return GetProtocolServerInstances().UnregisterPlugin(callback: create_callback); |
| 1192 | } |
| 1193 | |
| 1194 | llvm::StringRef |
| 1195 | PluginManager::GetProtocolServerPluginNameAtIndex(uint32_t idx) { |
| 1196 | return GetProtocolServerInstances().GetNameAtIndex(idx); |
| 1197 | } |
| 1198 | |
| 1199 | ProtocolServerCreateInstance |
| 1200 | PluginManager::GetProtocolCreateCallbackForPluginName(llvm::StringRef name) { |
| 1201 | return GetProtocolServerInstances().GetCallbackForName(name); |
| 1202 | } |
| 1203 | |
| 1204 | #pragma mark RegisterTypeBuilder |
| 1205 | |
| 1206 | struct RegisterTypeBuilderInstance |
| 1207 | : public PluginInstance<RegisterTypeBuilderCreateInstance> { |
| 1208 | RegisterTypeBuilderInstance(llvm::StringRef name, llvm::StringRef description, |
| 1209 | CallbackType create_callback) |
| 1210 | : PluginInstance<RegisterTypeBuilderCreateInstance>(name, description, |
| 1211 | create_callback) {} |
| 1212 | }; |
| 1213 | |
| 1214 | typedef PluginInstances<RegisterTypeBuilderInstance> |
| 1215 | RegisterTypeBuilderInstances; |
| 1216 | |
| 1217 | static RegisterTypeBuilderInstances &GetRegisterTypeBuilderInstances() { |
| 1218 | static RegisterTypeBuilderInstances g_instances; |
| 1219 | return g_instances; |
| 1220 | } |
| 1221 | |
| 1222 | bool PluginManager::RegisterPlugin( |
| 1223 | llvm::StringRef name, llvm::StringRef description, |
| 1224 | RegisterTypeBuilderCreateInstance create_callback) { |
| 1225 | return GetRegisterTypeBuilderInstances().RegisterPlugin(name, description, |
| 1226 | callback: create_callback); |
| 1227 | } |
| 1228 | |
| 1229 | bool PluginManager::UnregisterPlugin( |
| 1230 | RegisterTypeBuilderCreateInstance create_callback) { |
| 1231 | return GetRegisterTypeBuilderInstances().UnregisterPlugin(callback: create_callback); |
| 1232 | } |
| 1233 | |
| 1234 | lldb::RegisterTypeBuilderSP |
| 1235 | PluginManager::GetRegisterTypeBuilder(Target &target) { |
| 1236 | // We assume that RegisterTypeBuilderClang is the only instance of this plugin |
| 1237 | // type and is always present. |
| 1238 | auto instance = GetRegisterTypeBuilderInstances().GetInstanceAtIndex(idx: 0); |
| 1239 | assert(instance); |
| 1240 | return instance->create_callback(target); |
| 1241 | } |
| 1242 | |
| 1243 | #pragma mark ScriptInterpreter |
| 1244 | |
| 1245 | struct ScriptInterpreterInstance |
| 1246 | : public PluginInstance<ScriptInterpreterCreateInstance> { |
| 1247 | ScriptInterpreterInstance(llvm::StringRef name, llvm::StringRef description, |
| 1248 | CallbackType create_callback, |
| 1249 | lldb::ScriptLanguage language) |
| 1250 | : PluginInstance<ScriptInterpreterCreateInstance>(name, description, |
| 1251 | create_callback), |
| 1252 | language(language) {} |
| 1253 | |
| 1254 | lldb::ScriptLanguage language = lldb::eScriptLanguageNone; |
| 1255 | }; |
| 1256 | |
| 1257 | typedef PluginInstances<ScriptInterpreterInstance> ScriptInterpreterInstances; |
| 1258 | |
| 1259 | static ScriptInterpreterInstances &GetScriptInterpreterInstances() { |
| 1260 | static ScriptInterpreterInstances g_instances; |
| 1261 | return g_instances; |
| 1262 | } |
| 1263 | |
| 1264 | bool PluginManager::RegisterPlugin( |
| 1265 | llvm::StringRef name, llvm::StringRef description, |
| 1266 | lldb::ScriptLanguage script_language, |
| 1267 | ScriptInterpreterCreateInstance create_callback) { |
| 1268 | return GetScriptInterpreterInstances().RegisterPlugin( |
| 1269 | name, description, callback: create_callback, args&: script_language); |
| 1270 | } |
| 1271 | |
| 1272 | bool PluginManager::UnregisterPlugin( |
| 1273 | ScriptInterpreterCreateInstance create_callback) { |
| 1274 | return GetScriptInterpreterInstances().UnregisterPlugin(callback: create_callback); |
| 1275 | } |
| 1276 | |
| 1277 | ScriptInterpreterCreateInstance |
| 1278 | PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx) { |
| 1279 | return GetScriptInterpreterInstances().GetCallbackAtIndex(idx); |
| 1280 | } |
| 1281 | |
| 1282 | lldb::ScriptInterpreterSP |
| 1283 | PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, |
| 1284 | Debugger &debugger) { |
| 1285 | const auto instances = GetScriptInterpreterInstances().GetSnapshot(); |
| 1286 | ScriptInterpreterCreateInstance none_instance = nullptr; |
| 1287 | for (const auto &instance : instances) { |
| 1288 | if (instance.language == lldb::eScriptLanguageNone) |
| 1289 | none_instance = instance.create_callback; |
| 1290 | |
| 1291 | if (script_lang == instance.language) |
| 1292 | return instance.create_callback(debugger); |
| 1293 | } |
| 1294 | |
| 1295 | // If we didn't find one, return the ScriptInterpreter for the null language. |
| 1296 | assert(none_instance != nullptr); |
| 1297 | return none_instance(debugger); |
| 1298 | } |
| 1299 | |
| 1300 | #pragma mark StructuredDataPlugin |
| 1301 | |
| 1302 | struct StructuredDataPluginInstance |
| 1303 | : public PluginInstance<StructuredDataPluginCreateInstance> { |
| 1304 | StructuredDataPluginInstance( |
| 1305 | llvm::StringRef name, llvm::StringRef description, |
| 1306 | CallbackType create_callback, |
| 1307 | DebuggerInitializeCallback debugger_init_callback, |
| 1308 | StructuredDataFilterLaunchInfo filter_callback) |
| 1309 | : PluginInstance<StructuredDataPluginCreateInstance>( |
| 1310 | name, description, create_callback, debugger_init_callback), |
| 1311 | filter_callback(filter_callback) {} |
| 1312 | |
| 1313 | StructuredDataFilterLaunchInfo filter_callback = nullptr; |
| 1314 | }; |
| 1315 | |
| 1316 | typedef PluginInstances<StructuredDataPluginInstance> |
| 1317 | StructuredDataPluginInstances; |
| 1318 | |
| 1319 | static StructuredDataPluginInstances &GetStructuredDataPluginInstances() { |
| 1320 | static StructuredDataPluginInstances g_instances; |
| 1321 | return g_instances; |
| 1322 | } |
| 1323 | |
| 1324 | bool PluginManager::RegisterPlugin( |
| 1325 | llvm::StringRef name, llvm::StringRef description, |
| 1326 | StructuredDataPluginCreateInstance create_callback, |
| 1327 | DebuggerInitializeCallback debugger_init_callback, |
| 1328 | StructuredDataFilterLaunchInfo filter_callback) { |
| 1329 | return GetStructuredDataPluginInstances().RegisterPlugin( |
| 1330 | name, description, callback: create_callback, args&: debugger_init_callback, |
| 1331 | args&: filter_callback); |
| 1332 | } |
| 1333 | |
| 1334 | bool PluginManager::UnregisterPlugin( |
| 1335 | StructuredDataPluginCreateInstance create_callback) { |
| 1336 | return GetStructuredDataPluginInstances().UnregisterPlugin(callback: create_callback); |
| 1337 | } |
| 1338 | |
| 1339 | StructuredDataPluginCreateInstance |
| 1340 | PluginManager::GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx) { |
| 1341 | return GetStructuredDataPluginInstances().GetCallbackAtIndex(idx); |
| 1342 | } |
| 1343 | |
| 1344 | StructuredDataFilterLaunchInfo |
| 1345 | PluginManager::GetStructuredDataFilterCallbackAtIndex( |
| 1346 | uint32_t idx, bool &iteration_complete) { |
| 1347 | if (auto instance = |
| 1348 | GetStructuredDataPluginInstances().GetInstanceAtIndex(idx)) { |
| 1349 | iteration_complete = false; |
| 1350 | return instance->filter_callback; |
| 1351 | } |
| 1352 | iteration_complete = true; |
| 1353 | return nullptr; |
| 1354 | } |
| 1355 | |
| 1356 | #pragma mark SymbolFile |
| 1357 | |
| 1358 | typedef PluginInstance<SymbolFileCreateInstance> SymbolFileInstance; |
| 1359 | typedef PluginInstances<SymbolFileInstance> SymbolFileInstances; |
| 1360 | |
| 1361 | static SymbolFileInstances &GetSymbolFileInstances() { |
| 1362 | static SymbolFileInstances g_instances; |
| 1363 | return g_instances; |
| 1364 | } |
| 1365 | |
| 1366 | bool PluginManager::RegisterPlugin( |
| 1367 | llvm::StringRef name, llvm::StringRef description, |
| 1368 | SymbolFileCreateInstance create_callback, |
| 1369 | DebuggerInitializeCallback debugger_init_callback) { |
| 1370 | return GetSymbolFileInstances().RegisterPlugin( |
| 1371 | name, description, callback: create_callback, args&: debugger_init_callback); |
| 1372 | } |
| 1373 | |
| 1374 | bool PluginManager::UnregisterPlugin(SymbolFileCreateInstance create_callback) { |
| 1375 | return GetSymbolFileInstances().UnregisterPlugin(callback: create_callback); |
| 1376 | } |
| 1377 | |
| 1378 | SymbolFileCreateInstance |
| 1379 | PluginManager::GetSymbolFileCreateCallbackAtIndex(uint32_t idx) { |
| 1380 | return GetSymbolFileInstances().GetCallbackAtIndex(idx); |
| 1381 | } |
| 1382 | |
| 1383 | #pragma mark SymbolVendor |
| 1384 | |
| 1385 | typedef PluginInstance<SymbolVendorCreateInstance> SymbolVendorInstance; |
| 1386 | typedef PluginInstances<SymbolVendorInstance> SymbolVendorInstances; |
| 1387 | |
| 1388 | static SymbolVendorInstances &GetSymbolVendorInstances() { |
| 1389 | static SymbolVendorInstances g_instances; |
| 1390 | return g_instances; |
| 1391 | } |
| 1392 | |
| 1393 | bool PluginManager::RegisterPlugin(llvm::StringRef name, |
| 1394 | llvm::StringRef description, |
| 1395 | SymbolVendorCreateInstance create_callback) { |
| 1396 | return GetSymbolVendorInstances().RegisterPlugin(name, description, |
| 1397 | callback: create_callback); |
| 1398 | } |
| 1399 | |
| 1400 | bool PluginManager::UnregisterPlugin( |
| 1401 | SymbolVendorCreateInstance create_callback) { |
| 1402 | return GetSymbolVendorInstances().UnregisterPlugin(callback: create_callback); |
| 1403 | } |
| 1404 | |
| 1405 | SymbolVendorCreateInstance |
| 1406 | PluginManager::GetSymbolVendorCreateCallbackAtIndex(uint32_t idx) { |
| 1407 | return GetSymbolVendorInstances().GetCallbackAtIndex(idx); |
| 1408 | } |
| 1409 | |
| 1410 | #pragma mark SymbolLocator |
| 1411 | |
| 1412 | struct SymbolLocatorInstance |
| 1413 | : public PluginInstance<SymbolLocatorCreateInstance> { |
| 1414 | SymbolLocatorInstance( |
| 1415 | llvm::StringRef name, llvm::StringRef description, |
| 1416 | CallbackType create_callback, |
| 1417 | SymbolLocatorLocateExecutableObjectFile locate_executable_object_file, |
| 1418 | SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file, |
| 1419 | SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file, |
| 1420 | SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle, |
| 1421 | DebuggerInitializeCallback debugger_init_callback) |
| 1422 | : PluginInstance<SymbolLocatorCreateInstance>( |
| 1423 | name, description, create_callback, debugger_init_callback), |
| 1424 | locate_executable_object_file(locate_executable_object_file), |
| 1425 | locate_executable_symbol_file(locate_executable_symbol_file), |
| 1426 | download_object_symbol_file(download_object_symbol_file), |
| 1427 | find_symbol_file_in_bundle(find_symbol_file_in_bundle) {} |
| 1428 | |
| 1429 | SymbolLocatorLocateExecutableObjectFile locate_executable_object_file; |
| 1430 | SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file; |
| 1431 | SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file; |
| 1432 | SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle; |
| 1433 | }; |
| 1434 | typedef PluginInstances<SymbolLocatorInstance> SymbolLocatorInstances; |
| 1435 | |
| 1436 | static SymbolLocatorInstances &GetSymbolLocatorInstances() { |
| 1437 | static SymbolLocatorInstances g_instances; |
| 1438 | return g_instances; |
| 1439 | } |
| 1440 | |
| 1441 | bool PluginManager::RegisterPlugin( |
| 1442 | llvm::StringRef name, llvm::StringRef description, |
| 1443 | SymbolLocatorCreateInstance create_callback, |
| 1444 | SymbolLocatorLocateExecutableObjectFile locate_executable_object_file, |
| 1445 | SymbolLocatorLocateExecutableSymbolFile locate_executable_symbol_file, |
| 1446 | SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file, |
| 1447 | SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle, |
| 1448 | DebuggerInitializeCallback debugger_init_callback) { |
| 1449 | return GetSymbolLocatorInstances().RegisterPlugin( |
| 1450 | name, description, callback: create_callback, args&: locate_executable_object_file, |
| 1451 | args&: locate_executable_symbol_file, args&: download_object_symbol_file, |
| 1452 | args&: find_symbol_file_in_bundle, args&: debugger_init_callback); |
| 1453 | } |
| 1454 | |
| 1455 | bool PluginManager::UnregisterPlugin( |
| 1456 | SymbolLocatorCreateInstance create_callback) { |
| 1457 | return GetSymbolLocatorInstances().UnregisterPlugin(callback: create_callback); |
| 1458 | } |
| 1459 | |
| 1460 | SymbolLocatorCreateInstance |
| 1461 | PluginManager::GetSymbolLocatorCreateCallbackAtIndex(uint32_t idx) { |
| 1462 | return GetSymbolLocatorInstances().GetCallbackAtIndex(idx); |
| 1463 | } |
| 1464 | |
| 1465 | ModuleSpec |
| 1466 | PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec, |
| 1467 | StatisticsMap &map) { |
| 1468 | auto instances = GetSymbolLocatorInstances().GetSnapshot(); |
| 1469 | for (auto &instance : instances) { |
| 1470 | if (instance.locate_executable_object_file) { |
| 1471 | StatsDuration time; |
| 1472 | std::optional<ModuleSpec> result; |
| 1473 | { |
| 1474 | ElapsedTime elapsed(time); |
| 1475 | result = instance.locate_executable_object_file(module_spec); |
| 1476 | } |
| 1477 | map.add(key: instance.name, value: time.get().count()); |
| 1478 | if (result) |
| 1479 | return *result; |
| 1480 | } |
| 1481 | } |
| 1482 | return {}; |
| 1483 | } |
| 1484 | |
| 1485 | FileSpec PluginManager::LocateExecutableSymbolFile( |
| 1486 | const ModuleSpec &module_spec, const FileSpecList &default_search_paths, |
| 1487 | StatisticsMap &map) { |
| 1488 | auto instances = GetSymbolLocatorInstances().GetSnapshot(); |
| 1489 | for (auto &instance : instances) { |
| 1490 | if (instance.locate_executable_symbol_file) { |
| 1491 | StatsDuration time; |
| 1492 | std::optional<FileSpec> result; |
| 1493 | { |
| 1494 | ElapsedTime elapsed(time); |
| 1495 | result = instance.locate_executable_symbol_file(module_spec, |
| 1496 | default_search_paths); |
| 1497 | } |
| 1498 | map.add(key: instance.name, value: time.get().count()); |
| 1499 | if (result) |
| 1500 | return *result; |
| 1501 | } |
| 1502 | } |
| 1503 | return {}; |
| 1504 | } |
| 1505 | |
| 1506 | bool PluginManager::DownloadObjectAndSymbolFile(ModuleSpec &module_spec, |
| 1507 | Status &error, |
| 1508 | bool force_lookup, |
| 1509 | bool copy_executable) { |
| 1510 | auto instances = GetSymbolLocatorInstances().GetSnapshot(); |
| 1511 | for (auto &instance : instances) { |
| 1512 | if (instance.download_object_symbol_file) { |
| 1513 | if (instance.download_object_symbol_file(module_spec, error, force_lookup, |
| 1514 | copy_executable)) |
| 1515 | return true; |
| 1516 | } |
| 1517 | } |
| 1518 | return false; |
| 1519 | } |
| 1520 | |
| 1521 | FileSpec PluginManager::FindSymbolFileInBundle(const FileSpec &symfile_bundle, |
| 1522 | const UUID *uuid, |
| 1523 | const ArchSpec *arch) { |
| 1524 | auto instances = GetSymbolLocatorInstances().GetSnapshot(); |
| 1525 | for (auto &instance : instances) { |
| 1526 | if (instance.find_symbol_file_in_bundle) { |
| 1527 | std::optional<FileSpec> result = |
| 1528 | instance.find_symbol_file_in_bundle(symfile_bundle, uuid, arch); |
| 1529 | if (result) |
| 1530 | return *result; |
| 1531 | } |
| 1532 | } |
| 1533 | return {}; |
| 1534 | } |
| 1535 | |
| 1536 | #pragma mark Trace |
| 1537 | |
| 1538 | struct TraceInstance |
| 1539 | : public PluginInstance<TraceCreateInstanceFromBundle> { |
| 1540 | TraceInstance( |
| 1541 | llvm::StringRef name, llvm::StringRef description, |
| 1542 | CallbackType create_callback_from_bundle, |
| 1543 | TraceCreateInstanceForLiveProcess create_callback_for_live_process, |
| 1544 | llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) |
| 1545 | : PluginInstance<TraceCreateInstanceFromBundle>( |
| 1546 | name, description, create_callback_from_bundle, |
| 1547 | debugger_init_callback), |
| 1548 | schema(schema), |
| 1549 | create_callback_for_live_process(create_callback_for_live_process) {} |
| 1550 | |
| 1551 | llvm::StringRef schema; |
| 1552 | TraceCreateInstanceForLiveProcess create_callback_for_live_process; |
| 1553 | }; |
| 1554 | |
| 1555 | typedef PluginInstances<TraceInstance> TraceInstances; |
| 1556 | |
| 1557 | static TraceInstances &GetTracePluginInstances() { |
| 1558 | static TraceInstances g_instances; |
| 1559 | return g_instances; |
| 1560 | } |
| 1561 | |
| 1562 | bool PluginManager::RegisterPlugin( |
| 1563 | llvm::StringRef name, llvm::StringRef description, |
| 1564 | TraceCreateInstanceFromBundle create_callback_from_bundle, |
| 1565 | TraceCreateInstanceForLiveProcess create_callback_for_live_process, |
| 1566 | llvm::StringRef schema, DebuggerInitializeCallback debugger_init_callback) { |
| 1567 | return GetTracePluginInstances().RegisterPlugin( |
| 1568 | name, description, callback: create_callback_from_bundle, |
| 1569 | args&: create_callback_for_live_process, args&: schema, args&: debugger_init_callback); |
| 1570 | } |
| 1571 | |
| 1572 | bool PluginManager::UnregisterPlugin( |
| 1573 | TraceCreateInstanceFromBundle create_callback_from_bundle) { |
| 1574 | return GetTracePluginInstances().UnregisterPlugin( |
| 1575 | callback: create_callback_from_bundle); |
| 1576 | } |
| 1577 | |
| 1578 | TraceCreateInstanceFromBundle |
| 1579 | PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) { |
| 1580 | return GetTracePluginInstances().GetCallbackForName(name: plugin_name); |
| 1581 | } |
| 1582 | |
| 1583 | TraceCreateInstanceForLiveProcess |
| 1584 | PluginManager::GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name) { |
| 1585 | if (auto instance = GetTracePluginInstances().GetInstanceForName(name: plugin_name)) |
| 1586 | return instance->create_callback_for_live_process; |
| 1587 | |
| 1588 | return nullptr; |
| 1589 | } |
| 1590 | |
| 1591 | llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) { |
| 1592 | if (auto instance = GetTracePluginInstances().GetInstanceForName(name: plugin_name)) |
| 1593 | return instance->schema; |
| 1594 | return llvm::StringRef(); |
| 1595 | } |
| 1596 | |
| 1597 | llvm::StringRef PluginManager::GetTraceSchema(size_t index) { |
| 1598 | if (const TraceInstance *instance = |
| 1599 | GetTracePluginInstances().GetInstanceAtIndex(idx: index)) |
| 1600 | return instance->schema; |
| 1601 | return llvm::StringRef(); |
| 1602 | } |
| 1603 | |
| 1604 | #pragma mark TraceExporter |
| 1605 | |
| 1606 | struct TraceExporterInstance |
| 1607 | : public PluginInstance<TraceExporterCreateInstance> { |
| 1608 | TraceExporterInstance( |
| 1609 | llvm::StringRef name, llvm::StringRef description, |
| 1610 | TraceExporterCreateInstance create_instance, |
| 1611 | ThreadTraceExportCommandCreator create_thread_trace_export_command) |
| 1612 | : PluginInstance<TraceExporterCreateInstance>(name, description, |
| 1613 | create_instance), |
| 1614 | create_thread_trace_export_command(create_thread_trace_export_command) { |
| 1615 | } |
| 1616 | |
| 1617 | ThreadTraceExportCommandCreator create_thread_trace_export_command; |
| 1618 | }; |
| 1619 | |
| 1620 | typedef PluginInstances<TraceExporterInstance> TraceExporterInstances; |
| 1621 | |
| 1622 | static TraceExporterInstances &GetTraceExporterInstances() { |
| 1623 | static TraceExporterInstances g_instances; |
| 1624 | return g_instances; |
| 1625 | } |
| 1626 | |
| 1627 | bool PluginManager::RegisterPlugin( |
| 1628 | llvm::StringRef name, llvm::StringRef description, |
| 1629 | TraceExporterCreateInstance create_callback, |
| 1630 | ThreadTraceExportCommandCreator create_thread_trace_export_command) { |
| 1631 | return GetTraceExporterInstances().RegisterPlugin( |
| 1632 | name, description, callback: create_callback, args&: create_thread_trace_export_command); |
| 1633 | } |
| 1634 | |
| 1635 | TraceExporterCreateInstance |
| 1636 | PluginManager::GetTraceExporterCreateCallback(llvm::StringRef plugin_name) { |
| 1637 | return GetTraceExporterInstances().GetCallbackForName(name: plugin_name); |
| 1638 | } |
| 1639 | |
| 1640 | bool PluginManager::UnregisterPlugin( |
| 1641 | TraceExporterCreateInstance create_callback) { |
| 1642 | return GetTraceExporterInstances().UnregisterPlugin(callback: create_callback); |
| 1643 | } |
| 1644 | |
| 1645 | ThreadTraceExportCommandCreator |
| 1646 | PluginManager::GetThreadTraceExportCommandCreatorAtIndex(uint32_t index) { |
| 1647 | if (const TraceExporterInstance *instance = |
| 1648 | GetTraceExporterInstances().GetInstanceAtIndex(idx: index)) |
| 1649 | return instance->create_thread_trace_export_command; |
| 1650 | return nullptr; |
| 1651 | } |
| 1652 | |
| 1653 | llvm::StringRef |
| 1654 | PluginManager::GetTraceExporterPluginNameAtIndex(uint32_t index) { |
| 1655 | return GetTraceExporterInstances().GetNameAtIndex(idx: index); |
| 1656 | } |
| 1657 | |
| 1658 | #pragma mark UnwindAssembly |
| 1659 | |
| 1660 | typedef PluginInstance<UnwindAssemblyCreateInstance> UnwindAssemblyInstance; |
| 1661 | typedef PluginInstances<UnwindAssemblyInstance> UnwindAssemblyInstances; |
| 1662 | |
| 1663 | static UnwindAssemblyInstances &GetUnwindAssemblyInstances() { |
| 1664 | static UnwindAssemblyInstances g_instances; |
| 1665 | return g_instances; |
| 1666 | } |
| 1667 | |
| 1668 | bool PluginManager::RegisterPlugin( |
| 1669 | llvm::StringRef name, llvm::StringRef description, |
| 1670 | UnwindAssemblyCreateInstance create_callback) { |
| 1671 | return GetUnwindAssemblyInstances().RegisterPlugin(name, description, |
| 1672 | callback: create_callback); |
| 1673 | } |
| 1674 | |
| 1675 | bool PluginManager::UnregisterPlugin( |
| 1676 | UnwindAssemblyCreateInstance create_callback) { |
| 1677 | return GetUnwindAssemblyInstances().UnregisterPlugin(callback: create_callback); |
| 1678 | } |
| 1679 | |
| 1680 | UnwindAssemblyCreateInstance |
| 1681 | PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx) { |
| 1682 | return GetUnwindAssemblyInstances().GetCallbackAtIndex(idx); |
| 1683 | } |
| 1684 | |
| 1685 | #pragma mark MemoryHistory |
| 1686 | |
| 1687 | typedef PluginInstance<MemoryHistoryCreateInstance> MemoryHistoryInstance; |
| 1688 | typedef PluginInstances<MemoryHistoryInstance> MemoryHistoryInstances; |
| 1689 | |
| 1690 | static MemoryHistoryInstances &GetMemoryHistoryInstances() { |
| 1691 | static MemoryHistoryInstances g_instances; |
| 1692 | return g_instances; |
| 1693 | } |
| 1694 | |
| 1695 | bool PluginManager::RegisterPlugin( |
| 1696 | llvm::StringRef name, llvm::StringRef description, |
| 1697 | MemoryHistoryCreateInstance create_callback) { |
| 1698 | return GetMemoryHistoryInstances().RegisterPlugin(name, description, |
| 1699 | callback: create_callback); |
| 1700 | } |
| 1701 | |
| 1702 | bool PluginManager::UnregisterPlugin( |
| 1703 | MemoryHistoryCreateInstance create_callback) { |
| 1704 | return GetMemoryHistoryInstances().UnregisterPlugin(callback: create_callback); |
| 1705 | } |
| 1706 | |
| 1707 | MemoryHistoryCreateInstance |
| 1708 | PluginManager::GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx) { |
| 1709 | return GetMemoryHistoryInstances().GetCallbackAtIndex(idx); |
| 1710 | } |
| 1711 | |
| 1712 | #pragma mark InstrumentationRuntime |
| 1713 | |
| 1714 | struct InstrumentationRuntimeInstance |
| 1715 | : public PluginInstance<InstrumentationRuntimeCreateInstance> { |
| 1716 | InstrumentationRuntimeInstance( |
| 1717 | llvm::StringRef name, llvm::StringRef description, |
| 1718 | CallbackType create_callback, |
| 1719 | InstrumentationRuntimeGetType get_type_callback) |
| 1720 | : PluginInstance<InstrumentationRuntimeCreateInstance>(name, description, |
| 1721 | create_callback), |
| 1722 | get_type_callback(get_type_callback) {} |
| 1723 | |
| 1724 | InstrumentationRuntimeGetType get_type_callback = nullptr; |
| 1725 | }; |
| 1726 | |
| 1727 | typedef PluginInstances<InstrumentationRuntimeInstance> |
| 1728 | InstrumentationRuntimeInstances; |
| 1729 | |
| 1730 | static InstrumentationRuntimeInstances &GetInstrumentationRuntimeInstances() { |
| 1731 | static InstrumentationRuntimeInstances g_instances; |
| 1732 | return g_instances; |
| 1733 | } |
| 1734 | |
| 1735 | bool PluginManager::RegisterPlugin( |
| 1736 | llvm::StringRef name, llvm::StringRef description, |
| 1737 | InstrumentationRuntimeCreateInstance create_callback, |
| 1738 | InstrumentationRuntimeGetType get_type_callback) { |
| 1739 | return GetInstrumentationRuntimeInstances().RegisterPlugin( |
| 1740 | name, description, callback: create_callback, args&: get_type_callback); |
| 1741 | } |
| 1742 | |
| 1743 | bool PluginManager::UnregisterPlugin( |
| 1744 | InstrumentationRuntimeCreateInstance create_callback) { |
| 1745 | return GetInstrumentationRuntimeInstances().UnregisterPlugin(callback: create_callback); |
| 1746 | } |
| 1747 | |
| 1748 | InstrumentationRuntimeGetType |
| 1749 | PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx) { |
| 1750 | if (auto instance = |
| 1751 | GetInstrumentationRuntimeInstances().GetInstanceAtIndex(idx)) |
| 1752 | return instance->get_type_callback; |
| 1753 | return nullptr; |
| 1754 | } |
| 1755 | |
| 1756 | InstrumentationRuntimeCreateInstance |
| 1757 | PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx) { |
| 1758 | return GetInstrumentationRuntimeInstances().GetCallbackAtIndex(idx); |
| 1759 | } |
| 1760 | |
| 1761 | #pragma mark TypeSystem |
| 1762 | |
| 1763 | struct TypeSystemInstance : public PluginInstance<TypeSystemCreateInstance> { |
| 1764 | TypeSystemInstance(llvm::StringRef name, llvm::StringRef description, |
| 1765 | CallbackType create_callback, |
| 1766 | LanguageSet supported_languages_for_types, |
| 1767 | LanguageSet supported_languages_for_expressions) |
| 1768 | : PluginInstance<TypeSystemCreateInstance>(name, description, |
| 1769 | create_callback), |
| 1770 | supported_languages_for_types(supported_languages_for_types), |
| 1771 | supported_languages_for_expressions( |
| 1772 | supported_languages_for_expressions) {} |
| 1773 | |
| 1774 | LanguageSet supported_languages_for_types; |
| 1775 | LanguageSet supported_languages_for_expressions; |
| 1776 | }; |
| 1777 | |
| 1778 | typedef PluginInstances<TypeSystemInstance> TypeSystemInstances; |
| 1779 | |
| 1780 | static TypeSystemInstances &GetTypeSystemInstances() { |
| 1781 | static TypeSystemInstances g_instances; |
| 1782 | return g_instances; |
| 1783 | } |
| 1784 | |
| 1785 | bool PluginManager::RegisterPlugin( |
| 1786 | llvm::StringRef name, llvm::StringRef description, |
| 1787 | TypeSystemCreateInstance create_callback, |
| 1788 | LanguageSet supported_languages_for_types, |
| 1789 | LanguageSet supported_languages_for_expressions) { |
| 1790 | return GetTypeSystemInstances().RegisterPlugin( |
| 1791 | name, description, callback: create_callback, args&: supported_languages_for_types, |
| 1792 | args&: supported_languages_for_expressions); |
| 1793 | } |
| 1794 | |
| 1795 | bool PluginManager::UnregisterPlugin(TypeSystemCreateInstance create_callback) { |
| 1796 | return GetTypeSystemInstances().UnregisterPlugin(callback: create_callback); |
| 1797 | } |
| 1798 | |
| 1799 | TypeSystemCreateInstance |
| 1800 | PluginManager::GetTypeSystemCreateCallbackAtIndex(uint32_t idx) { |
| 1801 | return GetTypeSystemInstances().GetCallbackAtIndex(idx); |
| 1802 | } |
| 1803 | |
| 1804 | LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForTypes() { |
| 1805 | const auto instances = GetTypeSystemInstances().GetSnapshot(); |
| 1806 | LanguageSet all; |
| 1807 | for (unsigned i = 0; i < instances.size(); ++i) |
| 1808 | all.bitvector |= instances[i].supported_languages_for_types.bitvector; |
| 1809 | return all; |
| 1810 | } |
| 1811 | |
| 1812 | LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() { |
| 1813 | const auto instances = GetTypeSystemInstances().GetSnapshot(); |
| 1814 | LanguageSet all; |
| 1815 | for (unsigned i = 0; i < instances.size(); ++i) |
| 1816 | all.bitvector |= instances[i].supported_languages_for_expressions.bitvector; |
| 1817 | return all; |
| 1818 | } |
| 1819 | |
| 1820 | #pragma mark ScriptedInterfaces |
| 1821 | |
| 1822 | struct ScriptedInterfaceInstance |
| 1823 | : public PluginInstance<ScriptedInterfaceCreateInstance> { |
| 1824 | ScriptedInterfaceInstance(llvm::StringRef name, llvm::StringRef description, |
| 1825 | ScriptedInterfaceCreateInstance create_callback, |
| 1826 | lldb::ScriptLanguage language, |
| 1827 | ScriptedInterfaceUsages usages) |
| 1828 | : PluginInstance<ScriptedInterfaceCreateInstance>(name, description, |
| 1829 | create_callback), |
| 1830 | language(language), usages(usages) {} |
| 1831 | |
| 1832 | lldb::ScriptLanguage language; |
| 1833 | ScriptedInterfaceUsages usages; |
| 1834 | }; |
| 1835 | |
| 1836 | typedef PluginInstances<ScriptedInterfaceInstance> ScriptedInterfaceInstances; |
| 1837 | |
| 1838 | static ScriptedInterfaceInstances &GetScriptedInterfaceInstances() { |
| 1839 | static ScriptedInterfaceInstances g_instances; |
| 1840 | return g_instances; |
| 1841 | } |
| 1842 | |
| 1843 | bool PluginManager::RegisterPlugin( |
| 1844 | llvm::StringRef name, llvm::StringRef description, |
| 1845 | ScriptedInterfaceCreateInstance create_callback, |
| 1846 | lldb::ScriptLanguage language, ScriptedInterfaceUsages usages) { |
| 1847 | return GetScriptedInterfaceInstances().RegisterPlugin( |
| 1848 | name, description, callback: create_callback, args&: language, args&: usages); |
| 1849 | } |
| 1850 | |
| 1851 | bool PluginManager::UnregisterPlugin( |
| 1852 | ScriptedInterfaceCreateInstance create_callback) { |
| 1853 | return GetScriptedInterfaceInstances().UnregisterPlugin(callback: create_callback); |
| 1854 | } |
| 1855 | |
| 1856 | uint32_t PluginManager::GetNumScriptedInterfaces() { |
| 1857 | return GetScriptedInterfaceInstances().GetSnapshot().size(); |
| 1858 | } |
| 1859 | |
| 1860 | llvm::StringRef PluginManager::GetScriptedInterfaceNameAtIndex(uint32_t index) { |
| 1861 | return GetScriptedInterfaceInstances().GetNameAtIndex(idx: index); |
| 1862 | } |
| 1863 | |
| 1864 | llvm::StringRef |
| 1865 | PluginManager::GetScriptedInterfaceDescriptionAtIndex(uint32_t index) { |
| 1866 | return GetScriptedInterfaceInstances().GetDescriptionAtIndex(idx: index); |
| 1867 | } |
| 1868 | |
| 1869 | lldb::ScriptLanguage |
| 1870 | PluginManager::GetScriptedInterfaceLanguageAtIndex(uint32_t idx) { |
| 1871 | if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx)) |
| 1872 | return instance->language; |
| 1873 | return ScriptLanguage::eScriptLanguageNone; |
| 1874 | } |
| 1875 | |
| 1876 | ScriptedInterfaceUsages |
| 1877 | PluginManager::GetScriptedInterfaceUsagesAtIndex(uint32_t idx) { |
| 1878 | if (auto instance = GetScriptedInterfaceInstances().GetInstanceAtIndex(idx)) |
| 1879 | return instance->usages; |
| 1880 | return {}; |
| 1881 | } |
| 1882 | |
| 1883 | #pragma mark REPL |
| 1884 | |
| 1885 | struct REPLInstance : public PluginInstance<REPLCreateInstance> { |
| 1886 | REPLInstance(llvm::StringRef name, llvm::StringRef description, |
| 1887 | CallbackType create_callback, LanguageSet supported_languages) |
| 1888 | : PluginInstance<REPLCreateInstance>(name, description, create_callback), |
| 1889 | supported_languages(supported_languages) {} |
| 1890 | |
| 1891 | LanguageSet supported_languages; |
| 1892 | }; |
| 1893 | |
| 1894 | typedef PluginInstances<REPLInstance> REPLInstances; |
| 1895 | |
| 1896 | static REPLInstances &GetREPLInstances() { |
| 1897 | static REPLInstances g_instances; |
| 1898 | return g_instances; |
| 1899 | } |
| 1900 | |
| 1901 | bool PluginManager::RegisterPlugin(llvm::StringRef name, llvm::StringRef description, |
| 1902 | REPLCreateInstance create_callback, |
| 1903 | LanguageSet supported_languages) { |
| 1904 | return GetREPLInstances().RegisterPlugin(name, description, callback: create_callback, |
| 1905 | args&: supported_languages); |
| 1906 | } |
| 1907 | |
| 1908 | bool PluginManager::UnregisterPlugin(REPLCreateInstance create_callback) { |
| 1909 | return GetREPLInstances().UnregisterPlugin(callback: create_callback); |
| 1910 | } |
| 1911 | |
| 1912 | REPLCreateInstance PluginManager::GetREPLCreateCallbackAtIndex(uint32_t idx) { |
| 1913 | return GetREPLInstances().GetCallbackAtIndex(idx); |
| 1914 | } |
| 1915 | |
| 1916 | LanguageSet PluginManager::GetREPLSupportedLanguagesAtIndex(uint32_t idx) { |
| 1917 | if (auto instance = GetREPLInstances().GetInstanceAtIndex(idx)) |
| 1918 | return instance->supported_languages; |
| 1919 | return LanguageSet(); |
| 1920 | } |
| 1921 | |
| 1922 | LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() { |
| 1923 | const auto instances = GetREPLInstances().GetSnapshot(); |
| 1924 | LanguageSet all; |
| 1925 | for (unsigned i = 0; i < instances.size(); ++i) |
| 1926 | all.bitvector |= instances[i].supported_languages.bitvector; |
| 1927 | return all; |
| 1928 | } |
| 1929 | |
| 1930 | #pragma mark PluginManager |
| 1931 | |
| 1932 | void PluginManager::DebuggerInitialize(Debugger &debugger) { |
| 1933 | GetDynamicLoaderInstances().PerformDebuggerCallback(debugger); |
| 1934 | GetJITLoaderInstances().PerformDebuggerCallback(debugger); |
| 1935 | GetObjectFileInstances().PerformDebuggerCallback(debugger); |
| 1936 | GetPlatformInstances().PerformDebuggerCallback(debugger); |
| 1937 | GetProcessInstances().PerformDebuggerCallback(debugger); |
| 1938 | GetSymbolFileInstances().PerformDebuggerCallback(debugger); |
| 1939 | GetSymbolLocatorInstances().PerformDebuggerCallback(debugger); |
| 1940 | GetOperatingSystemInstances().PerformDebuggerCallback(debugger); |
| 1941 | GetStructuredDataPluginInstances().PerformDebuggerCallback(debugger); |
| 1942 | GetTracePluginInstances().PerformDebuggerCallback(debugger); |
| 1943 | GetScriptedInterfaceInstances().PerformDebuggerCallback(debugger); |
| 1944 | GetLanguageInstances().PerformDebuggerCallback(debugger); |
| 1945 | } |
| 1946 | |
| 1947 | // This is the preferred new way to register plugin specific settings. e.g. |
| 1948 | // This will put a plugin's settings under e.g. |
| 1949 | // "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME". |
| 1950 | static lldb::OptionValuePropertiesSP |
| 1951 | GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_name, |
| 1952 | llvm::StringRef plugin_type_desc, |
| 1953 | bool can_create) { |
| 1954 | lldb::OptionValuePropertiesSP parent_properties_sp( |
| 1955 | debugger.GetValueProperties()); |
| 1956 | if (parent_properties_sp) { |
| 1957 | static constexpr llvm::StringLiteral g_property_name("plugin" ); |
| 1958 | |
| 1959 | OptionValuePropertiesSP plugin_properties_sp = |
| 1960 | parent_properties_sp->GetSubProperty(exe_ctx: nullptr, name: g_property_name); |
| 1961 | if (!plugin_properties_sp && can_create) { |
| 1962 | plugin_properties_sp = |
| 1963 | std::make_shared<OptionValueProperties>(args: g_property_name); |
| 1964 | parent_properties_sp->AppendProperty(name: g_property_name, |
| 1965 | desc: "Settings specify to plugins." , is_global: true, |
| 1966 | value_sp: plugin_properties_sp); |
| 1967 | } |
| 1968 | |
| 1969 | if (plugin_properties_sp) { |
| 1970 | lldb::OptionValuePropertiesSP plugin_type_properties_sp = |
| 1971 | plugin_properties_sp->GetSubProperty(exe_ctx: nullptr, name: plugin_type_name); |
| 1972 | if (!plugin_type_properties_sp && can_create) { |
| 1973 | plugin_type_properties_sp = |
| 1974 | std::make_shared<OptionValueProperties>(args&: plugin_type_name); |
| 1975 | plugin_properties_sp->AppendProperty(name: plugin_type_name, desc: plugin_type_desc, |
| 1976 | is_global: true, value_sp: plugin_type_properties_sp); |
| 1977 | } |
| 1978 | return plugin_type_properties_sp; |
| 1979 | } |
| 1980 | } |
| 1981 | return lldb::OptionValuePropertiesSP(); |
| 1982 | } |
| 1983 | |
| 1984 | // This is deprecated way to register plugin specific settings. e.g. |
| 1985 | // "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform |
| 1986 | // generic settings would be under "platform.SETTINGNAME". |
| 1987 | static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle( |
| 1988 | Debugger &debugger, llvm::StringRef plugin_type_name, |
| 1989 | llvm::StringRef plugin_type_desc, bool can_create) { |
| 1990 | static constexpr llvm::StringLiteral g_property_name("plugin" ); |
| 1991 | lldb::OptionValuePropertiesSP parent_properties_sp( |
| 1992 | debugger.GetValueProperties()); |
| 1993 | if (parent_properties_sp) { |
| 1994 | OptionValuePropertiesSP plugin_properties_sp = |
| 1995 | parent_properties_sp->GetSubProperty(exe_ctx: nullptr, name: plugin_type_name); |
| 1996 | if (!plugin_properties_sp && can_create) { |
| 1997 | plugin_properties_sp = |
| 1998 | std::make_shared<OptionValueProperties>(args&: plugin_type_name); |
| 1999 | parent_properties_sp->AppendProperty(name: plugin_type_name, desc: plugin_type_desc, |
| 2000 | is_global: true, value_sp: plugin_properties_sp); |
| 2001 | } |
| 2002 | |
| 2003 | if (plugin_properties_sp) { |
| 2004 | lldb::OptionValuePropertiesSP plugin_type_properties_sp = |
| 2005 | plugin_properties_sp->GetSubProperty(exe_ctx: nullptr, name: g_property_name); |
| 2006 | if (!plugin_type_properties_sp && can_create) { |
| 2007 | plugin_type_properties_sp = |
| 2008 | std::make_shared<OptionValueProperties>(args: g_property_name); |
| 2009 | plugin_properties_sp->AppendProperty(name: g_property_name, |
| 2010 | desc: "Settings specific to plugins" , |
| 2011 | is_global: true, value_sp: plugin_type_properties_sp); |
| 2012 | } |
| 2013 | return plugin_type_properties_sp; |
| 2014 | } |
| 2015 | } |
| 2016 | return lldb::OptionValuePropertiesSP(); |
| 2017 | } |
| 2018 | |
| 2019 | namespace { |
| 2020 | |
| 2021 | typedef lldb::OptionValuePropertiesSP |
| 2022 | GetDebuggerPropertyForPluginsPtr(Debugger &, llvm::StringRef, llvm::StringRef, |
| 2023 | bool can_create); |
| 2024 | } |
| 2025 | |
| 2026 | static lldb::OptionValuePropertiesSP |
| 2027 | GetSettingForPlugin(Debugger &debugger, llvm::StringRef setting_name, |
| 2028 | llvm::StringRef plugin_type_name, |
| 2029 | GetDebuggerPropertyForPluginsPtr get_debugger_property = |
| 2030 | GetDebuggerPropertyForPlugins) { |
| 2031 | lldb::OptionValuePropertiesSP properties_sp; |
| 2032 | lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property( |
| 2033 | debugger, plugin_type_name, |
| 2034 | "" , // not creating to so we don't need the description |
| 2035 | false)); |
| 2036 | if (plugin_type_properties_sp) |
| 2037 | properties_sp = |
| 2038 | plugin_type_properties_sp->GetSubProperty(exe_ctx: nullptr, name: setting_name); |
| 2039 | return properties_sp; |
| 2040 | } |
| 2041 | |
| 2042 | static bool |
| 2043 | CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name, |
| 2044 | llvm::StringRef plugin_type_desc, |
| 2045 | const lldb::OptionValuePropertiesSP &properties_sp, |
| 2046 | llvm::StringRef description, bool is_global_property, |
| 2047 | GetDebuggerPropertyForPluginsPtr get_debugger_property = |
| 2048 | GetDebuggerPropertyForPlugins) { |
| 2049 | if (properties_sp) { |
| 2050 | lldb::OptionValuePropertiesSP plugin_type_properties_sp( |
| 2051 | get_debugger_property(debugger, plugin_type_name, plugin_type_desc, |
| 2052 | true)); |
| 2053 | if (plugin_type_properties_sp) { |
| 2054 | plugin_type_properties_sp->AppendProperty(name: properties_sp->GetName(), |
| 2055 | desc: description, is_global: is_global_property, |
| 2056 | value_sp: properties_sp); |
| 2057 | return true; |
| 2058 | } |
| 2059 | } |
| 2060 | return false; |
| 2061 | } |
| 2062 | |
| 2063 | static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader" ); |
| 2064 | static constexpr llvm::StringLiteral kPlatformPluginName("platform" ); |
| 2065 | static constexpr llvm::StringLiteral kProcessPluginName("process" ); |
| 2066 | static constexpr llvm::StringLiteral kTracePluginName("trace" ); |
| 2067 | static constexpr llvm::StringLiteral kObjectFilePluginName("object-file" ); |
| 2068 | static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file" ); |
| 2069 | static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator" ); |
| 2070 | static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader" ); |
| 2071 | static constexpr llvm::StringLiteral |
| 2072 | kStructuredDataPluginName("structured-data" ); |
| 2073 | static constexpr llvm::StringLiteral kCPlusPlusLanguagePlugin("cplusplus" ); |
| 2074 | |
| 2075 | lldb::OptionValuePropertiesSP |
| 2076 | PluginManager::GetSettingForDynamicLoaderPlugin(Debugger &debugger, |
| 2077 | llvm::StringRef setting_name) { |
| 2078 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kDynamicLoaderPluginName); |
| 2079 | } |
| 2080 | |
| 2081 | bool PluginManager::CreateSettingForDynamicLoaderPlugin( |
| 2082 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2083 | llvm::StringRef description, bool is_global_property) { |
| 2084 | return CreateSettingForPlugin(debugger, plugin_type_name: kDynamicLoaderPluginName, |
| 2085 | plugin_type_desc: "Settings for dynamic loader plug-ins" , |
| 2086 | properties_sp, description, is_global_property); |
| 2087 | } |
| 2088 | |
| 2089 | lldb::OptionValuePropertiesSP |
| 2090 | PluginManager::GetSettingForPlatformPlugin(Debugger &debugger, |
| 2091 | llvm::StringRef setting_name) { |
| 2092 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kPlatformPluginName, |
| 2093 | get_debugger_property: GetDebuggerPropertyForPluginsOldStyle); |
| 2094 | } |
| 2095 | |
| 2096 | bool PluginManager::CreateSettingForPlatformPlugin( |
| 2097 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2098 | llvm::StringRef description, bool is_global_property) { |
| 2099 | return CreateSettingForPlugin(debugger, plugin_type_name: kPlatformPluginName, |
| 2100 | plugin_type_desc: "Settings for platform plug-ins" , properties_sp, |
| 2101 | description, is_global_property, |
| 2102 | get_debugger_property: GetDebuggerPropertyForPluginsOldStyle); |
| 2103 | } |
| 2104 | |
| 2105 | lldb::OptionValuePropertiesSP |
| 2106 | PluginManager::GetSettingForProcessPlugin(Debugger &debugger, |
| 2107 | llvm::StringRef setting_name) { |
| 2108 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kProcessPluginName); |
| 2109 | } |
| 2110 | |
| 2111 | bool PluginManager::CreateSettingForProcessPlugin( |
| 2112 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2113 | llvm::StringRef description, bool is_global_property) { |
| 2114 | return CreateSettingForPlugin(debugger, plugin_type_name: kProcessPluginName, |
| 2115 | plugin_type_desc: "Settings for process plug-ins" , properties_sp, |
| 2116 | description, is_global_property); |
| 2117 | } |
| 2118 | |
| 2119 | lldb::OptionValuePropertiesSP |
| 2120 | PluginManager::GetSettingForSymbolLocatorPlugin(Debugger &debugger, |
| 2121 | llvm::StringRef setting_name) { |
| 2122 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kSymbolLocatorPluginName); |
| 2123 | } |
| 2124 | |
| 2125 | bool PluginManager::CreateSettingForSymbolLocatorPlugin( |
| 2126 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2127 | llvm::StringRef description, bool is_global_property) { |
| 2128 | return CreateSettingForPlugin(debugger, plugin_type_name: kSymbolLocatorPluginName, |
| 2129 | plugin_type_desc: "Settings for symbol locator plug-ins" , |
| 2130 | properties_sp, description, is_global_property); |
| 2131 | } |
| 2132 | |
| 2133 | bool PluginManager::CreateSettingForTracePlugin( |
| 2134 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2135 | llvm::StringRef description, bool is_global_property) { |
| 2136 | return CreateSettingForPlugin(debugger, plugin_type_name: kTracePluginName, |
| 2137 | plugin_type_desc: "Settings for trace plug-ins" , properties_sp, |
| 2138 | description, is_global_property); |
| 2139 | } |
| 2140 | |
| 2141 | lldb::OptionValuePropertiesSP |
| 2142 | PluginManager::GetSettingForObjectFilePlugin(Debugger &debugger, |
| 2143 | llvm::StringRef setting_name) { |
| 2144 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kObjectFilePluginName); |
| 2145 | } |
| 2146 | |
| 2147 | bool PluginManager::CreateSettingForObjectFilePlugin( |
| 2148 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2149 | llvm::StringRef description, bool is_global_property) { |
| 2150 | return CreateSettingForPlugin(debugger, plugin_type_name: kObjectFilePluginName, |
| 2151 | plugin_type_desc: "Settings for object file plug-ins" , |
| 2152 | properties_sp, description, is_global_property); |
| 2153 | } |
| 2154 | |
| 2155 | lldb::OptionValuePropertiesSP |
| 2156 | PluginManager::GetSettingForSymbolFilePlugin(Debugger &debugger, |
| 2157 | llvm::StringRef setting_name) { |
| 2158 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kSymbolFilePluginName); |
| 2159 | } |
| 2160 | |
| 2161 | bool PluginManager::CreateSettingForSymbolFilePlugin( |
| 2162 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2163 | llvm::StringRef description, bool is_global_property) { |
| 2164 | return CreateSettingForPlugin(debugger, plugin_type_name: kSymbolFilePluginName, |
| 2165 | plugin_type_desc: "Settings for symbol file plug-ins" , |
| 2166 | properties_sp, description, is_global_property); |
| 2167 | } |
| 2168 | |
| 2169 | lldb::OptionValuePropertiesSP |
| 2170 | PluginManager::GetSettingForJITLoaderPlugin(Debugger &debugger, |
| 2171 | llvm::StringRef setting_name) { |
| 2172 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kJITLoaderPluginName); |
| 2173 | } |
| 2174 | |
| 2175 | bool PluginManager::CreateSettingForJITLoaderPlugin( |
| 2176 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2177 | llvm::StringRef description, bool is_global_property) { |
| 2178 | return CreateSettingForPlugin(debugger, plugin_type_name: kJITLoaderPluginName, |
| 2179 | plugin_type_desc: "Settings for JIT loader plug-ins" , |
| 2180 | properties_sp, description, is_global_property); |
| 2181 | } |
| 2182 | |
| 2183 | static const char *kOperatingSystemPluginName("os" ); |
| 2184 | |
| 2185 | lldb::OptionValuePropertiesSP |
| 2186 | PluginManager::GetSettingForOperatingSystemPlugin(Debugger &debugger, |
| 2187 | llvm::StringRef setting_name) { |
| 2188 | lldb::OptionValuePropertiesSP properties_sp; |
| 2189 | lldb::OptionValuePropertiesSP plugin_type_properties_sp( |
| 2190 | GetDebuggerPropertyForPlugins( |
| 2191 | debugger, plugin_type_name: kOperatingSystemPluginName, |
| 2192 | plugin_type_desc: "" , // not creating to so we don't need the description |
| 2193 | can_create: false)); |
| 2194 | if (plugin_type_properties_sp) |
| 2195 | properties_sp = |
| 2196 | plugin_type_properties_sp->GetSubProperty(exe_ctx: nullptr, name: setting_name); |
| 2197 | return properties_sp; |
| 2198 | } |
| 2199 | |
| 2200 | bool PluginManager::CreateSettingForOperatingSystemPlugin( |
| 2201 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2202 | llvm::StringRef description, bool is_global_property) { |
| 2203 | if (properties_sp) { |
| 2204 | lldb::OptionValuePropertiesSP plugin_type_properties_sp( |
| 2205 | GetDebuggerPropertyForPlugins(debugger, plugin_type_name: kOperatingSystemPluginName, |
| 2206 | plugin_type_desc: "Settings for operating system plug-ins" , |
| 2207 | can_create: true)); |
| 2208 | if (plugin_type_properties_sp) { |
| 2209 | plugin_type_properties_sp->AppendProperty(name: properties_sp->GetName(), |
| 2210 | desc: description, is_global: is_global_property, |
| 2211 | value_sp: properties_sp); |
| 2212 | return true; |
| 2213 | } |
| 2214 | } |
| 2215 | return false; |
| 2216 | } |
| 2217 | |
| 2218 | lldb::OptionValuePropertiesSP |
| 2219 | PluginManager::GetSettingForStructuredDataPlugin(Debugger &debugger, |
| 2220 | llvm::StringRef setting_name) { |
| 2221 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kStructuredDataPluginName); |
| 2222 | } |
| 2223 | |
| 2224 | bool PluginManager::CreateSettingForStructuredDataPlugin( |
| 2225 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2226 | llvm::StringRef description, bool is_global_property) { |
| 2227 | return CreateSettingForPlugin(debugger, plugin_type_name: kStructuredDataPluginName, |
| 2228 | plugin_type_desc: "Settings for structured data plug-ins" , |
| 2229 | properties_sp, description, is_global_property); |
| 2230 | } |
| 2231 | |
| 2232 | lldb::OptionValuePropertiesSP |
| 2233 | PluginManager::GetSettingForCPlusPlusLanguagePlugin( |
| 2234 | Debugger &debugger, llvm::StringRef setting_name) { |
| 2235 | return GetSettingForPlugin(debugger, setting_name, plugin_type_name: kCPlusPlusLanguagePlugin); |
| 2236 | } |
| 2237 | |
| 2238 | bool PluginManager::CreateSettingForCPlusPlusLanguagePlugin( |
| 2239 | Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, |
| 2240 | llvm::StringRef description, bool is_global_property) { |
| 2241 | return CreateSettingForPlugin(debugger, plugin_type_name: kCPlusPlusLanguagePlugin, |
| 2242 | plugin_type_desc: "Settings for CPlusPlus language plug-ins" , |
| 2243 | properties_sp, description, is_global_property); |
| 2244 | } |
| 2245 | |
| 2246 | // |
| 2247 | // Plugin Info+Enable Implementations |
| 2248 | // |
| 2249 | std::vector<RegisteredPluginInfo> PluginManager::GetABIPluginInfo() { |
| 2250 | return GetABIInstances().GetPluginInfoForAllInstances(); |
| 2251 | } |
| 2252 | bool PluginManager::SetABIPluginEnabled(llvm::StringRef name, bool enable) { |
| 2253 | return GetABIInstances().SetInstanceEnabled(name, enable); |
| 2254 | } |
| 2255 | |
| 2256 | std::vector<RegisteredPluginInfo> PluginManager::GetArchitecturePluginInfo() { |
| 2257 | return GetArchitectureInstances().GetPluginInfoForAllInstances(); |
| 2258 | } |
| 2259 | bool PluginManager::SetArchitecturePluginEnabled(llvm::StringRef name, |
| 2260 | bool enable) { |
| 2261 | return GetArchitectureInstances().SetInstanceEnabled(name, enable); |
| 2262 | } |
| 2263 | |
| 2264 | std::vector<RegisteredPluginInfo> PluginManager::GetDisassemblerPluginInfo() { |
| 2265 | return GetDisassemblerInstances().GetPluginInfoForAllInstances(); |
| 2266 | } |
| 2267 | bool PluginManager::SetDisassemblerPluginEnabled(llvm::StringRef name, |
| 2268 | bool enable) { |
| 2269 | return GetDisassemblerInstances().SetInstanceEnabled(name, enable); |
| 2270 | } |
| 2271 | |
| 2272 | std::vector<RegisteredPluginInfo> PluginManager::GetDynamicLoaderPluginInfo() { |
| 2273 | return GetDynamicLoaderInstances().GetPluginInfoForAllInstances(); |
| 2274 | } |
| 2275 | bool PluginManager::SetDynamicLoaderPluginEnabled(llvm::StringRef name, |
| 2276 | bool enable) { |
| 2277 | return GetDynamicLoaderInstances().SetInstanceEnabled(name, enable); |
| 2278 | } |
| 2279 | |
| 2280 | std::vector<RegisteredPluginInfo> |
| 2281 | PluginManager::GetEmulateInstructionPluginInfo() { |
| 2282 | return GetEmulateInstructionInstances().GetPluginInfoForAllInstances(); |
| 2283 | } |
| 2284 | bool PluginManager::SetEmulateInstructionPluginEnabled(llvm::StringRef name, |
| 2285 | bool enable) { |
| 2286 | return GetEmulateInstructionInstances().SetInstanceEnabled(name, enable); |
| 2287 | } |
| 2288 | |
| 2289 | std::vector<RegisteredPluginInfo> |
| 2290 | PluginManager::GetInstrumentationRuntimePluginInfo() { |
| 2291 | return GetInstrumentationRuntimeInstances().GetPluginInfoForAllInstances(); |
| 2292 | } |
| 2293 | bool PluginManager::SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, |
| 2294 | bool enable) { |
| 2295 | return GetInstrumentationRuntimeInstances().SetInstanceEnabled(name, enable); |
| 2296 | } |
| 2297 | |
| 2298 | std::vector<RegisteredPluginInfo> PluginManager::GetJITLoaderPluginInfo() { |
| 2299 | return GetJITLoaderInstances().GetPluginInfoForAllInstances(); |
| 2300 | } |
| 2301 | bool PluginManager::SetJITLoaderPluginEnabled(llvm::StringRef name, |
| 2302 | bool enable) { |
| 2303 | return GetJITLoaderInstances().SetInstanceEnabled(name, enable); |
| 2304 | } |
| 2305 | |
| 2306 | std::vector<RegisteredPluginInfo> PluginManager::GetLanguagePluginInfo() { |
| 2307 | return GetLanguageInstances().GetPluginInfoForAllInstances(); |
| 2308 | } |
| 2309 | bool PluginManager::SetLanguagePluginEnabled(llvm::StringRef name, |
| 2310 | bool enable) { |
| 2311 | return GetLanguageInstances().SetInstanceEnabled(name, enable); |
| 2312 | } |
| 2313 | |
| 2314 | std::vector<RegisteredPluginInfo> |
| 2315 | PluginManager::GetLanguageRuntimePluginInfo() { |
| 2316 | return GetLanguageRuntimeInstances().GetPluginInfoForAllInstances(); |
| 2317 | } |
| 2318 | bool PluginManager::SetLanguageRuntimePluginEnabled(llvm::StringRef name, |
| 2319 | bool enable) { |
| 2320 | return GetLanguageRuntimeInstances().SetInstanceEnabled(name, enable); |
| 2321 | } |
| 2322 | |
| 2323 | std::vector<RegisteredPluginInfo> PluginManager::GetMemoryHistoryPluginInfo() { |
| 2324 | return GetMemoryHistoryInstances().GetPluginInfoForAllInstances(); |
| 2325 | } |
| 2326 | bool PluginManager::SetMemoryHistoryPluginEnabled(llvm::StringRef name, |
| 2327 | bool enable) { |
| 2328 | return GetMemoryHistoryInstances().SetInstanceEnabled(name, enable); |
| 2329 | } |
| 2330 | |
| 2331 | std::vector<RegisteredPluginInfo> |
| 2332 | PluginManager::GetObjectContainerPluginInfo() { |
| 2333 | return GetObjectContainerInstances().GetPluginInfoForAllInstances(); |
| 2334 | } |
| 2335 | bool PluginManager::SetObjectContainerPluginEnabled(llvm::StringRef name, |
| 2336 | bool enable) { |
| 2337 | return GetObjectContainerInstances().SetInstanceEnabled(name, enable); |
| 2338 | } |
| 2339 | |
| 2340 | std::vector<RegisteredPluginInfo> PluginManager::GetObjectFilePluginInfo() { |
| 2341 | return GetObjectFileInstances().GetPluginInfoForAllInstances(); |
| 2342 | } |
| 2343 | bool PluginManager::SetObjectFilePluginEnabled(llvm::StringRef name, |
| 2344 | bool enable) { |
| 2345 | return GetObjectFileInstances().SetInstanceEnabled(name, enable); |
| 2346 | } |
| 2347 | |
| 2348 | std::vector<RegisteredPluginInfo> |
| 2349 | PluginManager::GetOperatingSystemPluginInfo() { |
| 2350 | return GetOperatingSystemInstances().GetPluginInfoForAllInstances(); |
| 2351 | } |
| 2352 | bool PluginManager::SetOperatingSystemPluginEnabled(llvm::StringRef name, |
| 2353 | bool enable) { |
| 2354 | return GetOperatingSystemInstances().SetInstanceEnabled(name, enable); |
| 2355 | } |
| 2356 | |
| 2357 | std::vector<RegisteredPluginInfo> PluginManager::GetPlatformPluginInfo() { |
| 2358 | return GetPlatformInstances().GetPluginInfoForAllInstances(); |
| 2359 | } |
| 2360 | bool PluginManager::SetPlatformPluginEnabled(llvm::StringRef name, |
| 2361 | bool enable) { |
| 2362 | return GetPlatformInstances().SetInstanceEnabled(name, enable); |
| 2363 | } |
| 2364 | |
| 2365 | std::vector<RegisteredPluginInfo> PluginManager::GetProcessPluginInfo() { |
| 2366 | return GetProcessInstances().GetPluginInfoForAllInstances(); |
| 2367 | } |
| 2368 | bool PluginManager::SetProcessPluginEnabled(llvm::StringRef name, bool enable) { |
| 2369 | return GetProcessInstances().SetInstanceEnabled(name, enable); |
| 2370 | } |
| 2371 | |
| 2372 | std::vector<RegisteredPluginInfo> PluginManager::GetREPLPluginInfo() { |
| 2373 | return GetREPLInstances().GetPluginInfoForAllInstances(); |
| 2374 | } |
| 2375 | bool PluginManager::SetREPLPluginEnabled(llvm::StringRef name, bool enable) { |
| 2376 | return GetREPLInstances().SetInstanceEnabled(name, enable); |
| 2377 | } |
| 2378 | |
| 2379 | std::vector<RegisteredPluginInfo> |
| 2380 | PluginManager::GetRegisterTypeBuilderPluginInfo() { |
| 2381 | return GetRegisterTypeBuilderInstances().GetPluginInfoForAllInstances(); |
| 2382 | } |
| 2383 | bool PluginManager::SetRegisterTypeBuilderPluginEnabled(llvm::StringRef name, |
| 2384 | bool enable) { |
| 2385 | return GetRegisterTypeBuilderInstances().SetInstanceEnabled(name, enable); |
| 2386 | } |
| 2387 | |
| 2388 | std::vector<RegisteredPluginInfo> |
| 2389 | PluginManager::GetScriptInterpreterPluginInfo() { |
| 2390 | return GetScriptInterpreterInstances().GetPluginInfoForAllInstances(); |
| 2391 | } |
| 2392 | bool PluginManager::SetScriptInterpreterPluginEnabled(llvm::StringRef name, |
| 2393 | bool enable) { |
| 2394 | return GetScriptInterpreterInstances().SetInstanceEnabled(name, enable); |
| 2395 | } |
| 2396 | |
| 2397 | std::vector<RegisteredPluginInfo> |
| 2398 | PluginManager::GetScriptedInterfacePluginInfo() { |
| 2399 | return GetScriptedInterfaceInstances().GetPluginInfoForAllInstances(); |
| 2400 | } |
| 2401 | bool PluginManager::SetScriptedInterfacePluginEnabled(llvm::StringRef name, |
| 2402 | bool enable) { |
| 2403 | return GetScriptedInterfaceInstances().SetInstanceEnabled(name, enable); |
| 2404 | } |
| 2405 | |
| 2406 | std::vector<RegisteredPluginInfo> PluginManager::GetStructuredDataPluginInfo() { |
| 2407 | return GetStructuredDataPluginInstances().GetPluginInfoForAllInstances(); |
| 2408 | } |
| 2409 | bool PluginManager::SetStructuredDataPluginEnabled(llvm::StringRef name, |
| 2410 | bool enable) { |
| 2411 | return GetStructuredDataPluginInstances().SetInstanceEnabled(name, enable); |
| 2412 | } |
| 2413 | |
| 2414 | std::vector<RegisteredPluginInfo> PluginManager::GetSymbolFilePluginInfo() { |
| 2415 | return GetSymbolFileInstances().GetPluginInfoForAllInstances(); |
| 2416 | } |
| 2417 | bool PluginManager::SetSymbolFilePluginEnabled(llvm::StringRef name, |
| 2418 | bool enable) { |
| 2419 | return GetSymbolFileInstances().SetInstanceEnabled(name, enable); |
| 2420 | } |
| 2421 | |
| 2422 | std::vector<RegisteredPluginInfo> PluginManager::GetSymbolLocatorPluginInfo() { |
| 2423 | return GetSymbolLocatorInstances().GetPluginInfoForAllInstances(); |
| 2424 | } |
| 2425 | bool PluginManager::SetSymbolLocatorPluginEnabled(llvm::StringRef name, |
| 2426 | bool enable) { |
| 2427 | return GetSymbolLocatorInstances().SetInstanceEnabled(name, enable); |
| 2428 | } |
| 2429 | |
| 2430 | std::vector<RegisteredPluginInfo> PluginManager::GetSymbolVendorPluginInfo() { |
| 2431 | return GetSymbolVendorInstances().GetPluginInfoForAllInstances(); |
| 2432 | } |
| 2433 | bool PluginManager::SetSymbolVendorPluginEnabled(llvm::StringRef name, |
| 2434 | bool enable) { |
| 2435 | return GetSymbolVendorInstances().SetInstanceEnabled(name, enable); |
| 2436 | } |
| 2437 | |
| 2438 | std::vector<RegisteredPluginInfo> PluginManager::GetSystemRuntimePluginInfo() { |
| 2439 | return GetSystemRuntimeInstances().GetPluginInfoForAllInstances(); |
| 2440 | } |
| 2441 | bool PluginManager::SetSystemRuntimePluginEnabled(llvm::StringRef name, |
| 2442 | bool enable) { |
| 2443 | return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable); |
| 2444 | } |
| 2445 | |
| 2446 | std::vector<RegisteredPluginInfo> PluginManager::GetTracePluginInfo() { |
| 2447 | return GetTracePluginInstances().GetPluginInfoForAllInstances(); |
| 2448 | } |
| 2449 | bool PluginManager::SetTracePluginEnabled(llvm::StringRef name, bool enable) { |
| 2450 | return GetTracePluginInstances().SetInstanceEnabled(name, enable); |
| 2451 | } |
| 2452 | |
| 2453 | std::vector<RegisteredPluginInfo> PluginManager::GetTraceExporterPluginInfo() { |
| 2454 | return GetTraceExporterInstances().GetPluginInfoForAllInstances(); |
| 2455 | } |
| 2456 | bool PluginManager::SetTraceExporterPluginEnabled(llvm::StringRef name, |
| 2457 | bool enable) { |
| 2458 | return GetTraceExporterInstances().SetInstanceEnabled(name, enable); |
| 2459 | } |
| 2460 | |
| 2461 | std::vector<RegisteredPluginInfo> PluginManager::GetTypeSystemPluginInfo() { |
| 2462 | return GetTypeSystemInstances().GetPluginInfoForAllInstances(); |
| 2463 | } |
| 2464 | bool PluginManager::SetTypeSystemPluginEnabled(llvm::StringRef name, |
| 2465 | bool enable) { |
| 2466 | return GetTypeSystemInstances().SetInstanceEnabled(name, enable); |
| 2467 | } |
| 2468 | |
| 2469 | std::vector<RegisteredPluginInfo> PluginManager::GetUnwindAssemblyPluginInfo() { |
| 2470 | return GetUnwindAssemblyInstances().GetPluginInfoForAllInstances(); |
| 2471 | } |
| 2472 | bool PluginManager::SetUnwindAssemblyPluginEnabled(llvm::StringRef name, |
| 2473 | bool enable) { |
| 2474 | return GetUnwindAssemblyInstances().SetInstanceEnabled(name, enable); |
| 2475 | } |
| 2476 | |