Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- PluginManager.cpp ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Daniel Malea | 93a6430 | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/Core/PluginManager.h" |
| 13 | |
Stephen Wilson | 8acdbb8 | 2011-04-08 13:36:44 +0000 | [diff] [blame] | 14 | #include <limits.h> |
| 15 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 16 | #include <string> |
| 17 | #include <vector> |
| 18 | |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Debugger.h" |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Error.h" |
Greg Clayton | 53239f0 | 2011-02-08 05:05:52 +0000 | [diff] [blame] | 21 | #include "lldb/Host/FileSpec.h" |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 22 | #include "lldb/Host/Host.h" |
| 23 | #include "lldb/Host/Mutex.h" |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 24 | #include "lldb/Interpreter/OptionValueProperties.h" |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 25 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/StringRef.h" |
| 27 | |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 28 | using namespace lldb; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | using namespace lldb_private; |
| 30 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 31 | enum PluginAction |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 32 | { |
| 33 | ePluginRegisterInstance, |
| 34 | ePluginUnregisterInstance, |
| 35 | ePluginGetInstanceAtIndex |
| 36 | }; |
| 37 | |
Greg Clayton | 03da4cc | 2013-04-19 21:31:16 +0000 | [diff] [blame^] | 38 | |
| 39 | typedef bool (*PluginInitCallback) (void); |
| 40 | typedef void (*PluginTermCallback) (void); |
| 41 | |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 42 | struct PluginInfo |
| 43 | { |
| 44 | void *plugin_handle; |
Greg Clayton | 03da4cc | 2013-04-19 21:31:16 +0000 | [diff] [blame^] | 45 | PluginInitCallback plugin_init_callback; |
| 46 | PluginTermCallback plugin_term_callback; |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | typedef std::map<FileSpec, PluginInfo> PluginTerminateMap; |
| 50 | |
| 51 | static Mutex & |
| 52 | GetPluginMapMutex () |
| 53 | { |
| 54 | static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive); |
| 55 | return g_plugin_map_mutex; |
| 56 | } |
| 57 | |
| 58 | static PluginTerminateMap & |
| 59 | GetPluginMap () |
| 60 | { |
| 61 | static PluginTerminateMap g_plugin_map; |
| 62 | return g_plugin_map; |
| 63 | } |
| 64 | |
| 65 | static bool |
| 66 | PluginIsLoaded (const FileSpec &plugin_file_spec) |
| 67 | { |
| 68 | Mutex::Locker locker (GetPluginMapMutex ()); |
| 69 | PluginTerminateMap &plugin_map = GetPluginMap (); |
| 70 | return plugin_map.find (plugin_file_spec) != plugin_map.end(); |
| 71 | } |
| 72 | |
| 73 | static void |
| 74 | SetPluginInfo (const FileSpec &plugin_file_spec, const PluginInfo &plugin_info) |
| 75 | { |
| 76 | Mutex::Locker locker (GetPluginMapMutex ()); |
| 77 | PluginTerminateMap &plugin_map = GetPluginMap (); |
| 78 | assert (plugin_map.find (plugin_file_spec) != plugin_map.end()); |
| 79 | plugin_map[plugin_file_spec] = plugin_info; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | static FileSpec::EnumerateDirectoryResult |
| 84 | LoadPluginCallback |
| 85 | ( |
| 86 | void *baton, |
| 87 | FileSpec::FileType file_type, |
| 88 | const FileSpec &file_spec |
| 89 | ) |
| 90 | { |
| 91 | // PluginManager *plugin_manager = (PluginManager *)baton; |
| 92 | Error error; |
| 93 | |
| 94 | // If we have a regular file, a symbolic link or unknown file type, try |
| 95 | // and process the file. We must handle unknown as sometimes the directory |
| 96 | // enumeration might be enumerating a file system that doesn't have correct |
| 97 | // file type information. |
| 98 | if (file_type == FileSpec::eFileTypeRegular || |
| 99 | file_type == FileSpec::eFileTypeSymbolicLink || |
| 100 | file_type == FileSpec::eFileTypeUnknown ) |
| 101 | { |
| 102 | FileSpec plugin_file_spec (file_spec); |
| 103 | plugin_file_spec.ResolvePath(); |
| 104 | |
| 105 | if (PluginIsLoaded (plugin_file_spec)) |
| 106 | return FileSpec::eEnumerateDirectoryResultNext; |
| 107 | else |
| 108 | { |
| 109 | PluginInfo plugin_info = { NULL, NULL, NULL }; |
Greg Clayton | 4531946 | 2011-02-08 00:35:34 +0000 | [diff] [blame] | 110 | uint32_t flags = Host::eDynamicLibraryOpenOptionLazy | |
| 111 | Host::eDynamicLibraryOpenOptionLocal | |
| 112 | Host::eDynamicLibraryOpenOptionLimitGetSymbol; |
| 113 | |
| 114 | plugin_info.plugin_handle = Host::DynamicLibraryOpen (plugin_file_spec, flags, error); |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 115 | if (plugin_info.plugin_handle) |
| 116 | { |
| 117 | bool success = false; |
Greg Clayton | 03da4cc | 2013-04-19 21:31:16 +0000 | [diff] [blame^] | 118 | plugin_info.plugin_init_callback = (PluginInitCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error); |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 119 | if (plugin_info.plugin_init_callback) |
| 120 | { |
| 121 | // Call the plug-in "bool LLDBPluginInitialize(void)" function |
Greg Clayton | 03da4cc | 2013-04-19 21:31:16 +0000 | [diff] [blame^] | 122 | success = plugin_info.plugin_init_callback(); |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | if (success) |
| 126 | { |
| 127 | // It is ok for the "LLDBPluginTerminate" symbol to be NULL |
Greg Clayton | 03da4cc | 2013-04-19 21:31:16 +0000 | [diff] [blame^] | 128 | plugin_info.plugin_term_callback = (PluginTermCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error); |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 129 | } |
| 130 | else |
| 131 | { |
| 132 | // The initialize function returned FALSE which means the |
| 133 | // plug-in might not be compatible, or might be too new or |
| 134 | // too old, or might not want to run on this machine. |
| 135 | Host::DynamicLibraryClose (plugin_info.plugin_handle); |
| 136 | plugin_info.plugin_handle = NULL; |
| 137 | plugin_info.plugin_init_callback = NULL; |
| 138 | } |
| 139 | |
| 140 | // Regardless of success or failure, cache the plug-in load |
| 141 | // in our plug-in info so we don't try to load it again and |
| 142 | // again. |
| 143 | SetPluginInfo (plugin_file_spec, plugin_info); |
| 144 | |
| 145 | return FileSpec::eEnumerateDirectoryResultNext; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | if (file_type == FileSpec::eFileTypeUnknown || |
| 151 | file_type == FileSpec::eFileTypeDirectory || |
| 152 | file_type == FileSpec::eFileTypeSymbolicLink ) |
| 153 | { |
| 154 | // Try and recurse into anything that a directory or symbolic link. |
| 155 | // We must also do this for unknown as sometimes the directory enumeration |
| 156 | // might be enurating a file system that doesn't have correct file type |
| 157 | // information. |
| 158 | return FileSpec::eEnumerateDirectoryResultEnter; |
| 159 | } |
| 160 | |
| 161 | return FileSpec::eEnumerateDirectoryResultNext; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | void |
| 166 | PluginManager::Initialize () |
| 167 | { |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 168 | #if 1 |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 169 | FileSpec dir_spec; |
| 170 | const bool find_directories = true; |
| 171 | const bool find_files = true; |
| 172 | const bool find_other = true; |
| 173 | char dir_path[PATH_MAX]; |
| 174 | if (Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec)) |
| 175 | { |
| 176 | if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) |
| 177 | { |
| 178 | FileSpec::EnumerateDirectory (dir_path, |
| 179 | find_directories, |
| 180 | find_files, |
| 181 | find_other, |
| 182 | LoadPluginCallback, |
| 183 | NULL); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec)) |
| 188 | { |
| 189 | if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) |
| 190 | { |
| 191 | FileSpec::EnumerateDirectory (dir_path, |
| 192 | find_directories, |
| 193 | find_files, |
| 194 | find_other, |
| 195 | LoadPluginCallback, |
| 196 | NULL); |
| 197 | } |
| 198 | } |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 199 | #endif |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void |
| 203 | PluginManager::Terminate () |
| 204 | { |
| 205 | Mutex::Locker locker (GetPluginMapMutex ()); |
| 206 | PluginTerminateMap &plugin_map = GetPluginMap (); |
| 207 | |
| 208 | PluginTerminateMap::const_iterator pos, end = plugin_map.end(); |
| 209 | for (pos = plugin_map.begin(); pos != end; ++pos) |
| 210 | { |
| 211 | // Call the plug-in "void LLDBPluginTerminate (void)" function if there |
| 212 | // is one (if the symbol was not NULL). |
| 213 | if (pos->second.plugin_handle) |
| 214 | { |
| 215 | if (pos->second.plugin_term_callback) |
Greg Clayton | 03da4cc | 2013-04-19 21:31:16 +0000 | [diff] [blame^] | 216 | pos->second.plugin_term_callback(); |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 217 | Host::DynamicLibraryClose (pos->second.plugin_handle); |
| 218 | } |
| 219 | } |
| 220 | plugin_map.clear(); |
| 221 | } |
| 222 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 223 | |
| 224 | #pragma mark ABI |
| 225 | |
| 226 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 227 | struct ABIInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 228 | { |
| 229 | ABIInstance() : |
| 230 | name(), |
| 231 | description(), |
| 232 | create_callback(NULL) |
| 233 | { |
| 234 | } |
| 235 | |
| 236 | std::string name; |
| 237 | std::string description; |
| 238 | ABICreateInstance create_callback; |
| 239 | }; |
| 240 | |
| 241 | typedef std::vector<ABIInstance> ABIInstances; |
| 242 | |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 243 | static Mutex & |
| 244 | GetABIInstancesMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 245 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 246 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 247 | return g_instances_mutex; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 248 | } |
| 249 | |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 250 | static ABIInstances & |
| 251 | GetABIInstances () |
| 252 | { |
| 253 | static ABIInstances g_instances; |
| 254 | return g_instances; |
| 255 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 256 | |
| 257 | bool |
| 258 | PluginManager::RegisterPlugin |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 259 | ( |
| 260 | const char *name, |
| 261 | const char *description, |
| 262 | ABICreateInstance create_callback |
| 263 | ) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 264 | { |
| 265 | if (create_callback) |
| 266 | { |
| 267 | ABIInstance instance; |
| 268 | assert (name && name[0]); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 269 | instance.name.assign (name); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 270 | if (description && description[0]) |
| 271 | instance.description = description; |
| 272 | instance.create_callback = create_callback; |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 273 | Mutex::Locker locker (GetABIInstancesMutex ()); |
| 274 | GetABIInstances ().push_back (instance); |
| 275 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 276 | } |
| 277 | return false; |
| 278 | } |
| 279 | |
| 280 | bool |
| 281 | PluginManager::UnregisterPlugin (ABICreateInstance create_callback) |
| 282 | { |
| 283 | if (create_callback) |
| 284 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 285 | Mutex::Locker locker (GetABIInstancesMutex ()); |
| 286 | ABIInstances &instances = GetABIInstances (); |
| 287 | |
| 288 | ABIInstances::iterator pos, end = instances.end(); |
| 289 | for (pos = instances.begin(); pos != end; ++ pos) |
| 290 | { |
| 291 | if (pos->create_callback == create_callback) |
| 292 | { |
| 293 | instances.erase(pos); |
| 294 | return true; |
| 295 | } |
| 296 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 297 | } |
| 298 | return false; |
| 299 | } |
| 300 | |
| 301 | ABICreateInstance |
| 302 | PluginManager::GetABICreateCallbackAtIndex (uint32_t idx) |
| 303 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 304 | Mutex::Locker locker (GetABIInstancesMutex ()); |
| 305 | ABIInstances &instances = GetABIInstances (); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 306 | if (idx < instances.size()) |
| 307 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 308 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | ABICreateInstance |
| 312 | PluginManager::GetABICreateCallbackForPluginName (const char *name) |
| 313 | { |
| 314 | if (name && name[0]) |
| 315 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 316 | Mutex::Locker locker (GetABIInstancesMutex ()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 317 | llvm::StringRef name_sref(name); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 318 | ABIInstances &instances = GetABIInstances (); |
| 319 | |
| 320 | ABIInstances::iterator pos, end = instances.end(); |
| 321 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 322 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 323 | if (name_sref.equals (pos->name)) |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 324 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | return NULL; |
| 328 | } |
| 329 | |
| 330 | |
| 331 | #pragma mark Disassembler |
| 332 | |
| 333 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 334 | struct DisassemblerInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 335 | { |
| 336 | DisassemblerInstance() : |
| 337 | name(), |
| 338 | description(), |
| 339 | create_callback(NULL) |
| 340 | { |
| 341 | } |
| 342 | |
| 343 | std::string name; |
| 344 | std::string description; |
| 345 | DisassemblerCreateInstance create_callback; |
| 346 | }; |
| 347 | |
| 348 | typedef std::vector<DisassemblerInstance> DisassemblerInstances; |
| 349 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 350 | static Mutex & |
| 351 | GetDisassemblerMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 352 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 353 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 354 | return g_instances_mutex; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 355 | } |
| 356 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 357 | static DisassemblerInstances & |
| 358 | GetDisassemblerInstances () |
| 359 | { |
| 360 | static DisassemblerInstances g_instances; |
| 361 | return g_instances; |
| 362 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 363 | |
| 364 | bool |
| 365 | PluginManager::RegisterPlugin |
| 366 | ( |
| 367 | const char *name, |
| 368 | const char *description, |
| 369 | DisassemblerCreateInstance create_callback |
| 370 | ) |
| 371 | { |
| 372 | if (create_callback) |
| 373 | { |
| 374 | DisassemblerInstance instance; |
| 375 | assert (name && name[0]); |
| 376 | instance.name = name; |
| 377 | if (description && description[0]) |
| 378 | instance.description = description; |
| 379 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 380 | Mutex::Locker locker (GetDisassemblerMutex ()); |
| 381 | GetDisassemblerInstances ().push_back (instance); |
| 382 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 383 | } |
| 384 | return false; |
| 385 | } |
| 386 | |
| 387 | bool |
| 388 | PluginManager::UnregisterPlugin (DisassemblerCreateInstance create_callback) |
| 389 | { |
| 390 | if (create_callback) |
| 391 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 392 | Mutex::Locker locker (GetDisassemblerMutex ()); |
| 393 | DisassemblerInstances &instances = GetDisassemblerInstances (); |
| 394 | |
| 395 | DisassemblerInstances::iterator pos, end = instances.end(); |
| 396 | for (pos = instances.begin(); pos != end; ++ pos) |
| 397 | { |
| 398 | if (pos->create_callback == create_callback) |
| 399 | { |
| 400 | instances.erase(pos); |
| 401 | return true; |
| 402 | } |
| 403 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 404 | } |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | DisassemblerCreateInstance |
| 409 | PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx) |
| 410 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 411 | Mutex::Locker locker (GetDisassemblerMutex ()); |
| 412 | DisassemblerInstances &instances = GetDisassemblerInstances (); |
| 413 | if (idx < instances.size()) |
| 414 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 415 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | DisassemblerCreateInstance |
| 419 | PluginManager::GetDisassemblerCreateCallbackForPluginName (const char *name) |
| 420 | { |
| 421 | if (name && name[0]) |
| 422 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 423 | llvm::StringRef name_sref(name); |
| 424 | Mutex::Locker locker (GetDisassemblerMutex ()); |
| 425 | DisassemblerInstances &instances = GetDisassemblerInstances (); |
| 426 | |
| 427 | DisassemblerInstances::iterator pos, end = instances.end(); |
| 428 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 429 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 430 | if (name_sref.equals (pos->name)) |
| 431 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 432 | } |
| 433 | } |
| 434 | return NULL; |
| 435 | } |
| 436 | |
| 437 | |
| 438 | |
| 439 | #pragma mark DynamicLoader |
| 440 | |
| 441 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 442 | struct DynamicLoaderInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 443 | { |
| 444 | DynamicLoaderInstance() : |
| 445 | name(), |
| 446 | description(), |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 447 | create_callback(NULL), |
| 448 | debugger_init_callback (NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 449 | { |
| 450 | } |
| 451 | |
| 452 | std::string name; |
| 453 | std::string description; |
| 454 | DynamicLoaderCreateInstance create_callback; |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 455 | DebuggerInitializeCallback debugger_init_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 456 | }; |
| 457 | |
| 458 | typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances; |
| 459 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 460 | |
| 461 | static Mutex & |
| 462 | GetDynamicLoaderMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 463 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 464 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 465 | return g_instances_mutex; |
| 466 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 467 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 468 | static DynamicLoaderInstances & |
| 469 | GetDynamicLoaderInstances () |
| 470 | { |
| 471 | static DynamicLoaderInstances g_instances; |
| 472 | return g_instances; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | |
| 476 | bool |
| 477 | PluginManager::RegisterPlugin |
| 478 | ( |
| 479 | const char *name, |
| 480 | const char *description, |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 481 | DynamicLoaderCreateInstance create_callback, |
| 482 | DebuggerInitializeCallback debugger_init_callback |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 483 | ) |
| 484 | { |
| 485 | if (create_callback) |
| 486 | { |
| 487 | DynamicLoaderInstance instance; |
| 488 | assert (name && name[0]); |
| 489 | instance.name = name; |
| 490 | if (description && description[0]) |
| 491 | instance.description = description; |
| 492 | instance.create_callback = create_callback; |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 493 | instance.debugger_init_callback = debugger_init_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 494 | Mutex::Locker locker (GetDynamicLoaderMutex ()); |
| 495 | GetDynamicLoaderInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 496 | } |
| 497 | return false; |
| 498 | } |
| 499 | |
| 500 | bool |
| 501 | PluginManager::UnregisterPlugin (DynamicLoaderCreateInstance create_callback) |
| 502 | { |
| 503 | if (create_callback) |
| 504 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 505 | Mutex::Locker locker (GetDynamicLoaderMutex ()); |
| 506 | DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); |
| 507 | |
| 508 | DynamicLoaderInstances::iterator pos, end = instances.end(); |
| 509 | for (pos = instances.begin(); pos != end; ++ pos) |
| 510 | { |
| 511 | if (pos->create_callback == create_callback) |
| 512 | { |
| 513 | instances.erase(pos); |
| 514 | return true; |
| 515 | } |
| 516 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 517 | } |
| 518 | return false; |
| 519 | } |
| 520 | |
| 521 | DynamicLoaderCreateInstance |
| 522 | PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx) |
| 523 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 524 | Mutex::Locker locker (GetDynamicLoaderMutex ()); |
| 525 | DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); |
| 526 | if (idx < instances.size()) |
| 527 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 528 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | DynamicLoaderCreateInstance |
| 532 | PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const char *name) |
| 533 | { |
| 534 | if (name && name[0]) |
| 535 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 536 | llvm::StringRef name_sref(name); |
| 537 | Mutex::Locker locker (GetDynamicLoaderMutex ()); |
| 538 | DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); |
| 539 | |
| 540 | DynamicLoaderInstances::iterator pos, end = instances.end(); |
| 541 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 542 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 543 | if (name_sref.equals (pos->name)) |
| 544 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 545 | } |
| 546 | } |
| 547 | return NULL; |
| 548 | } |
| 549 | |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 550 | #pragma mark EmulateInstruction |
| 551 | |
| 552 | |
| 553 | struct EmulateInstructionInstance |
| 554 | { |
| 555 | EmulateInstructionInstance() : |
| 556 | name(), |
| 557 | description(), |
| 558 | create_callback(NULL) |
| 559 | { |
| 560 | } |
| 561 | |
| 562 | std::string name; |
| 563 | std::string description; |
| 564 | EmulateInstructionCreateInstance create_callback; |
| 565 | }; |
| 566 | |
| 567 | typedef std::vector<EmulateInstructionInstance> EmulateInstructionInstances; |
| 568 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 569 | static Mutex & |
| 570 | GetEmulateInstructionMutex () |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 571 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 572 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 573 | return g_instances_mutex; |
| 574 | } |
| 575 | |
| 576 | static EmulateInstructionInstances & |
| 577 | GetEmulateInstructionInstances () |
| 578 | { |
| 579 | static EmulateInstructionInstances g_instances; |
| 580 | return g_instances; |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | |
| 584 | bool |
| 585 | PluginManager::RegisterPlugin |
| 586 | ( |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 587 | const char *name, |
| 588 | const char *description, |
| 589 | EmulateInstructionCreateInstance create_callback |
| 590 | ) |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 591 | { |
| 592 | if (create_callback) |
| 593 | { |
| 594 | EmulateInstructionInstance instance; |
| 595 | assert (name && name[0]); |
| 596 | instance.name = name; |
| 597 | if (description && description[0]) |
| 598 | instance.description = description; |
| 599 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 600 | Mutex::Locker locker (GetEmulateInstructionMutex ()); |
| 601 | GetEmulateInstructionInstances ().push_back (instance); |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 602 | } |
| 603 | return false; |
| 604 | } |
| 605 | |
| 606 | bool |
| 607 | PluginManager::UnregisterPlugin (EmulateInstructionCreateInstance create_callback) |
| 608 | { |
| 609 | if (create_callback) |
| 610 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 611 | Mutex::Locker locker (GetEmulateInstructionMutex ()); |
| 612 | EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); |
| 613 | |
| 614 | EmulateInstructionInstances::iterator pos, end = instances.end(); |
| 615 | for (pos = instances.begin(); pos != end; ++ pos) |
| 616 | { |
| 617 | if (pos->create_callback == create_callback) |
| 618 | { |
| 619 | instances.erase(pos); |
| 620 | return true; |
| 621 | } |
| 622 | } |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 623 | } |
| 624 | return false; |
| 625 | } |
| 626 | |
| 627 | EmulateInstructionCreateInstance |
| 628 | PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx) |
| 629 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 630 | Mutex::Locker locker (GetEmulateInstructionMutex ()); |
| 631 | EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); |
| 632 | if (idx < instances.size()) |
| 633 | return instances[idx].create_callback; |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 634 | return NULL; |
| 635 | } |
| 636 | |
| 637 | EmulateInstructionCreateInstance |
| 638 | PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const char *name) |
| 639 | { |
| 640 | if (name && name[0]) |
| 641 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 642 | llvm::StringRef name_sref(name); |
| 643 | Mutex::Locker locker (GetEmulateInstructionMutex ()); |
| 644 | EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); |
| 645 | |
| 646 | EmulateInstructionInstances::iterator pos, end = instances.end(); |
| 647 | for (pos = instances.begin(); pos != end; ++ pos) |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 648 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 649 | if (name_sref.equals (pos->name)) |
| 650 | return pos->create_callback; |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 651 | } |
| 652 | } |
| 653 | return NULL; |
| 654 | } |
Greg Clayton | 56d9a1b | 2011-08-22 02:49:39 +0000 | [diff] [blame] | 655 | #pragma mark OperatingSystem |
| 656 | |
| 657 | |
| 658 | struct OperatingSystemInstance |
| 659 | { |
| 660 | OperatingSystemInstance() : |
| 661 | name(), |
| 662 | description(), |
| 663 | create_callback(NULL) |
| 664 | { |
| 665 | } |
| 666 | |
| 667 | std::string name; |
| 668 | std::string description; |
| 669 | OperatingSystemCreateInstance create_callback; |
| 670 | }; |
| 671 | |
| 672 | typedef std::vector<OperatingSystemInstance> OperatingSystemInstances; |
| 673 | |
| 674 | static Mutex & |
| 675 | GetOperatingSystemMutex () |
| 676 | { |
| 677 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 678 | return g_instances_mutex; |
| 679 | } |
| 680 | |
| 681 | static OperatingSystemInstances & |
| 682 | GetOperatingSystemInstances () |
| 683 | { |
| 684 | static OperatingSystemInstances g_instances; |
| 685 | return g_instances; |
| 686 | } |
| 687 | |
| 688 | bool |
| 689 | PluginManager::RegisterPlugin |
| 690 | ( |
| 691 | const char *name, |
| 692 | const char *description, |
| 693 | OperatingSystemCreateInstance create_callback |
| 694 | ) |
| 695 | { |
| 696 | if (create_callback) |
| 697 | { |
| 698 | OperatingSystemInstance instance; |
| 699 | assert (name && name[0]); |
| 700 | instance.name = name; |
| 701 | if (description && description[0]) |
| 702 | instance.description = description; |
| 703 | instance.create_callback = create_callback; |
| 704 | Mutex::Locker locker (GetOperatingSystemMutex ()); |
| 705 | GetOperatingSystemInstances ().push_back (instance); |
| 706 | } |
| 707 | return false; |
| 708 | } |
| 709 | |
| 710 | bool |
| 711 | PluginManager::UnregisterPlugin (OperatingSystemCreateInstance create_callback) |
| 712 | { |
| 713 | if (create_callback) |
| 714 | { |
| 715 | Mutex::Locker locker (GetOperatingSystemMutex ()); |
| 716 | OperatingSystemInstances &instances = GetOperatingSystemInstances (); |
| 717 | |
| 718 | OperatingSystemInstances::iterator pos, end = instances.end(); |
| 719 | for (pos = instances.begin(); pos != end; ++ pos) |
| 720 | { |
| 721 | if (pos->create_callback == create_callback) |
| 722 | { |
| 723 | instances.erase(pos); |
| 724 | return true; |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | return false; |
| 729 | } |
| 730 | |
| 731 | OperatingSystemCreateInstance |
| 732 | PluginManager::GetOperatingSystemCreateCallbackAtIndex (uint32_t idx) |
| 733 | { |
| 734 | Mutex::Locker locker (GetOperatingSystemMutex ()); |
| 735 | OperatingSystemInstances &instances = GetOperatingSystemInstances (); |
| 736 | if (idx < instances.size()) |
| 737 | return instances[idx].create_callback; |
| 738 | return NULL; |
| 739 | } |
| 740 | |
| 741 | OperatingSystemCreateInstance |
| 742 | PluginManager::GetOperatingSystemCreateCallbackForPluginName (const char *name) |
| 743 | { |
| 744 | if (name && name[0]) |
| 745 | { |
| 746 | llvm::StringRef name_sref(name); |
| 747 | Mutex::Locker locker (GetOperatingSystemMutex ()); |
| 748 | OperatingSystemInstances &instances = GetOperatingSystemInstances (); |
| 749 | |
| 750 | OperatingSystemInstances::iterator pos, end = instances.end(); |
| 751 | for (pos = instances.begin(); pos != end; ++ pos) |
| 752 | { |
| 753 | if (name_sref.equals (pos->name)) |
| 754 | return pos->create_callback; |
| 755 | } |
| 756 | } |
| 757 | return NULL; |
| 758 | } |
Greg Clayton | f03bbe2 | 2011-02-01 01:37:45 +0000 | [diff] [blame] | 759 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 760 | |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 761 | #pragma mark LanguageRuntime |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 762 | |
| 763 | |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 764 | struct LanguageRuntimeInstance |
| 765 | { |
| 766 | LanguageRuntimeInstance() : |
| 767 | name(), |
| 768 | description(), |
| 769 | create_callback(NULL) |
| 770 | { |
| 771 | } |
| 772 | |
| 773 | std::string name; |
| 774 | std::string description; |
| 775 | LanguageRuntimeCreateInstance create_callback; |
| 776 | }; |
| 777 | |
| 778 | typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances; |
| 779 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 780 | static Mutex & |
| 781 | GetLanguageRuntimeMutex () |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 782 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 783 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 784 | return g_instances_mutex; |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 785 | } |
| 786 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 787 | static LanguageRuntimeInstances & |
| 788 | GetLanguageRuntimeInstances () |
| 789 | { |
| 790 | static LanguageRuntimeInstances g_instances; |
| 791 | return g_instances; |
| 792 | } |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 793 | |
| 794 | bool |
| 795 | PluginManager::RegisterPlugin |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 796 | ( |
| 797 | const char *name, |
| 798 | const char *description, |
| 799 | LanguageRuntimeCreateInstance create_callback |
| 800 | ) |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 801 | { |
| 802 | if (create_callback) |
| 803 | { |
| 804 | LanguageRuntimeInstance instance; |
| 805 | assert (name && name[0]); |
| 806 | instance.name = name; |
| 807 | if (description && description[0]) |
| 808 | instance.description = description; |
| 809 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 810 | Mutex::Locker locker (GetLanguageRuntimeMutex ()); |
| 811 | GetLanguageRuntimeInstances ().push_back (instance); |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 812 | } |
| 813 | return false; |
| 814 | } |
| 815 | |
| 816 | bool |
| 817 | PluginManager::UnregisterPlugin (LanguageRuntimeCreateInstance create_callback) |
| 818 | { |
| 819 | if (create_callback) |
| 820 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 821 | Mutex::Locker locker (GetLanguageRuntimeMutex ()); |
| 822 | LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); |
| 823 | |
| 824 | LanguageRuntimeInstances::iterator pos, end = instances.end(); |
| 825 | for (pos = instances.begin(); pos != end; ++ pos) |
| 826 | { |
| 827 | if (pos->create_callback == create_callback) |
| 828 | { |
| 829 | instances.erase(pos); |
| 830 | return true; |
| 831 | } |
| 832 | } |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 833 | } |
| 834 | return false; |
| 835 | } |
| 836 | |
| 837 | LanguageRuntimeCreateInstance |
| 838 | PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx) |
| 839 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 840 | Mutex::Locker locker (GetLanguageRuntimeMutex ()); |
| 841 | LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); |
| 842 | if (idx < instances.size()) |
| 843 | return instances[idx].create_callback; |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 844 | return NULL; |
| 845 | } |
| 846 | |
| 847 | LanguageRuntimeCreateInstance |
| 848 | PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const char *name) |
| 849 | { |
| 850 | if (name && name[0]) |
| 851 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 852 | llvm::StringRef name_sref(name); |
| 853 | Mutex::Locker locker (GetLanguageRuntimeMutex ()); |
| 854 | LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); |
| 855 | |
| 856 | LanguageRuntimeInstances::iterator pos, end = instances.end(); |
| 857 | for (pos = instances.begin(); pos != end; ++ pos) |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 858 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 859 | if (name_sref.equals (pos->name)) |
| 860 | return pos->create_callback; |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 861 | } |
| 862 | } |
| 863 | return NULL; |
| 864 | } |
| 865 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 866 | #pragma mark ObjectFile |
| 867 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 868 | struct ObjectFileInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 869 | { |
| 870 | ObjectFileInstance() : |
| 871 | name(), |
| 872 | description(), |
| 873 | create_callback(NULL) |
| 874 | { |
| 875 | } |
| 876 | |
| 877 | std::string name; |
| 878 | std::string description; |
| 879 | ObjectFileCreateInstance create_callback; |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 880 | ObjectFileCreateMemoryInstance create_memory_callback; |
| 881 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 882 | }; |
| 883 | |
| 884 | typedef std::vector<ObjectFileInstance> ObjectFileInstances; |
| 885 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 886 | static Mutex & |
| 887 | GetObjectFileMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 888 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 889 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 890 | return g_instances_mutex; |
| 891 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 892 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 893 | static ObjectFileInstances & |
| 894 | GetObjectFileInstances () |
| 895 | { |
| 896 | static ObjectFileInstances g_instances; |
| 897 | return g_instances; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | |
| 901 | bool |
| 902 | PluginManager::RegisterPlugin |
| 903 | ( |
| 904 | const char *name, |
| 905 | const char *description, |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 906 | ObjectFileCreateInstance create_callback, |
| 907 | ObjectFileCreateMemoryInstance create_memory_callback |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 908 | ) |
| 909 | { |
| 910 | if (create_callback) |
| 911 | { |
| 912 | ObjectFileInstance instance; |
| 913 | assert (name && name[0]); |
| 914 | instance.name = name; |
| 915 | if (description && description[0]) |
| 916 | instance.description = description; |
| 917 | instance.create_callback = create_callback; |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 918 | instance.create_memory_callback = create_memory_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 919 | Mutex::Locker locker (GetObjectFileMutex ()); |
| 920 | GetObjectFileInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 921 | } |
| 922 | return false; |
| 923 | } |
| 924 | |
| 925 | bool |
| 926 | PluginManager::UnregisterPlugin (ObjectFileCreateInstance create_callback) |
| 927 | { |
| 928 | if (create_callback) |
| 929 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 930 | Mutex::Locker locker (GetObjectFileMutex ()); |
| 931 | ObjectFileInstances &instances = GetObjectFileInstances (); |
| 932 | |
| 933 | ObjectFileInstances::iterator pos, end = instances.end(); |
| 934 | for (pos = instances.begin(); pos != end; ++ pos) |
| 935 | { |
| 936 | if (pos->create_callback == create_callback) |
| 937 | { |
| 938 | instances.erase(pos); |
| 939 | return true; |
| 940 | } |
| 941 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 942 | } |
| 943 | return false; |
| 944 | } |
| 945 | |
| 946 | ObjectFileCreateInstance |
| 947 | PluginManager::GetObjectFileCreateCallbackAtIndex (uint32_t idx) |
| 948 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 949 | Mutex::Locker locker (GetObjectFileMutex ()); |
| 950 | ObjectFileInstances &instances = GetObjectFileInstances (); |
| 951 | if (idx < instances.size()) |
| 952 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 953 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 954 | } |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 955 | |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 956 | |
| 957 | ObjectFileCreateMemoryInstance |
| 958 | PluginManager::GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx) |
| 959 | { |
| 960 | Mutex::Locker locker (GetObjectFileMutex ()); |
| 961 | ObjectFileInstances &instances = GetObjectFileInstances (); |
| 962 | if (idx < instances.size()) |
| 963 | return instances[idx].create_memory_callback; |
| 964 | return NULL; |
| 965 | } |
| 966 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 967 | ObjectFileCreateInstance |
| 968 | PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name) |
| 969 | { |
| 970 | if (name && name[0]) |
| 971 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 972 | llvm::StringRef name_sref(name); |
| 973 | Mutex::Locker locker (GetObjectFileMutex ()); |
| 974 | ObjectFileInstances &instances = GetObjectFileInstances (); |
| 975 | |
| 976 | ObjectFileInstances::iterator pos, end = instances.end(); |
| 977 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 978 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 979 | if (name_sref.equals (pos->name)) |
| 980 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 981 | } |
| 982 | } |
| 983 | return NULL; |
| 984 | } |
| 985 | |
| 986 | |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 987 | ObjectFileCreateMemoryInstance |
| 988 | PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const char *name) |
| 989 | { |
| 990 | if (name && name[0]) |
| 991 | { |
| 992 | llvm::StringRef name_sref(name); |
| 993 | Mutex::Locker locker (GetObjectFileMutex ()); |
| 994 | ObjectFileInstances &instances = GetObjectFileInstances (); |
| 995 | |
| 996 | ObjectFileInstances::iterator pos, end = instances.end(); |
| 997 | for (pos = instances.begin(); pos != end; ++ pos) |
| 998 | { |
| 999 | if (name_sref.equals (pos->name)) |
| 1000 | return pos->create_memory_callback; |
| 1001 | } |
| 1002 | } |
| 1003 | return NULL; |
| 1004 | } |
| 1005 | |
| 1006 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1007 | |
| 1008 | #pragma mark ObjectContainer |
| 1009 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1010 | struct ObjectContainerInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1011 | { |
| 1012 | ObjectContainerInstance() : |
| 1013 | name(), |
| 1014 | description(), |
| 1015 | create_callback(NULL) |
| 1016 | { |
| 1017 | } |
| 1018 | |
| 1019 | std::string name; |
| 1020 | std::string description; |
| 1021 | ObjectContainerCreateInstance create_callback; |
| 1022 | }; |
| 1023 | |
| 1024 | typedef std::vector<ObjectContainerInstance> ObjectContainerInstances; |
| 1025 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1026 | static Mutex & |
| 1027 | GetObjectContainerMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1028 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1029 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1030 | return g_instances_mutex; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1033 | static ObjectContainerInstances & |
| 1034 | GetObjectContainerInstances () |
| 1035 | { |
| 1036 | static ObjectContainerInstances g_instances; |
| 1037 | return g_instances; |
| 1038 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1039 | |
| 1040 | bool |
| 1041 | PluginManager::RegisterPlugin |
| 1042 | ( |
| 1043 | const char *name, |
| 1044 | const char *description, |
| 1045 | ObjectContainerCreateInstance create_callback |
| 1046 | ) |
| 1047 | { |
| 1048 | if (create_callback) |
| 1049 | { |
| 1050 | ObjectContainerInstance instance; |
| 1051 | assert (name && name[0]); |
| 1052 | instance.name = name; |
| 1053 | if (description && description[0]) |
| 1054 | instance.description = description; |
| 1055 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1056 | Mutex::Locker locker (GetObjectContainerMutex ()); |
| 1057 | GetObjectContainerInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1058 | } |
| 1059 | return false; |
| 1060 | } |
| 1061 | |
| 1062 | bool |
| 1063 | PluginManager::UnregisterPlugin (ObjectContainerCreateInstance create_callback) |
| 1064 | { |
| 1065 | if (create_callback) |
| 1066 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1067 | Mutex::Locker locker (GetObjectContainerMutex ()); |
| 1068 | ObjectContainerInstances &instances = GetObjectContainerInstances (); |
| 1069 | |
| 1070 | ObjectContainerInstances::iterator pos, end = instances.end(); |
| 1071 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1072 | { |
| 1073 | if (pos->create_callback == create_callback) |
| 1074 | { |
| 1075 | instances.erase(pos); |
| 1076 | return true; |
| 1077 | } |
| 1078 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1079 | } |
| 1080 | return false; |
| 1081 | } |
| 1082 | |
| 1083 | ObjectContainerCreateInstance |
| 1084 | PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx) |
| 1085 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1086 | Mutex::Locker locker (GetObjectContainerMutex ()); |
| 1087 | ObjectContainerInstances &instances = GetObjectContainerInstances (); |
| 1088 | if (idx < instances.size()) |
| 1089 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1090 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1091 | } |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1092 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1093 | ObjectContainerCreateInstance |
| 1094 | PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name) |
| 1095 | { |
| 1096 | if (name && name[0]) |
| 1097 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1098 | llvm::StringRef name_sref(name); |
| 1099 | Mutex::Locker locker (GetObjectContainerMutex ()); |
| 1100 | ObjectContainerInstances &instances = GetObjectContainerInstances (); |
| 1101 | |
| 1102 | ObjectContainerInstances::iterator pos, end = instances.end(); |
| 1103 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1104 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1105 | if (name_sref.equals (pos->name)) |
| 1106 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1107 | } |
| 1108 | } |
| 1109 | return NULL; |
| 1110 | } |
| 1111 | |
| 1112 | #pragma mark LogChannel |
| 1113 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1114 | struct LogInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1115 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1116 | LogInstance() : |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1117 | name(), |
| 1118 | description(), |
| 1119 | create_callback(NULL) |
| 1120 | { |
| 1121 | } |
| 1122 | |
| 1123 | std::string name; |
| 1124 | std::string description; |
| 1125 | LogChannelCreateInstance create_callback; |
| 1126 | }; |
| 1127 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1128 | typedef std::vector<LogInstance> LogInstances; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1129 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1130 | static Mutex & |
| 1131 | GetLogMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1132 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1133 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1134 | return g_instances_mutex; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1135 | } |
| 1136 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1137 | static LogInstances & |
| 1138 | GetLogInstances () |
| 1139 | { |
| 1140 | static LogInstances g_instances; |
| 1141 | return g_instances; |
| 1142 | } |
| 1143 | |
| 1144 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1145 | |
| 1146 | bool |
| 1147 | PluginManager::RegisterPlugin |
| 1148 | ( |
| 1149 | const char *name, |
| 1150 | const char *description, |
| 1151 | LogChannelCreateInstance create_callback |
| 1152 | ) |
| 1153 | { |
| 1154 | if (create_callback) |
| 1155 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1156 | LogInstance instance; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1157 | assert (name && name[0]); |
| 1158 | instance.name = name; |
| 1159 | if (description && description[0]) |
| 1160 | instance.description = description; |
| 1161 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1162 | Mutex::Locker locker (GetLogMutex ()); |
| 1163 | GetLogInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1164 | } |
| 1165 | return false; |
| 1166 | } |
| 1167 | |
| 1168 | bool |
| 1169 | PluginManager::UnregisterPlugin (LogChannelCreateInstance create_callback) |
| 1170 | { |
| 1171 | if (create_callback) |
| 1172 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1173 | Mutex::Locker locker (GetLogMutex ()); |
| 1174 | LogInstances &instances = GetLogInstances (); |
| 1175 | |
| 1176 | LogInstances::iterator pos, end = instances.end(); |
| 1177 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1178 | { |
| 1179 | if (pos->create_callback == create_callback) |
| 1180 | { |
| 1181 | instances.erase(pos); |
| 1182 | return true; |
| 1183 | } |
| 1184 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1185 | } |
| 1186 | return false; |
| 1187 | } |
| 1188 | |
| 1189 | const char * |
| 1190 | PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx) |
| 1191 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1192 | Mutex::Locker locker (GetLogMutex ()); |
| 1193 | LogInstances &instances = GetLogInstances (); |
| 1194 | if (idx < instances.size()) |
| 1195 | return instances[idx].name.c_str(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1196 | return NULL; |
| 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | LogChannelCreateInstance |
| 1201 | PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx) |
| 1202 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1203 | Mutex::Locker locker (GetLogMutex ()); |
| 1204 | LogInstances &instances = GetLogInstances (); |
| 1205 | if (idx < instances.size()) |
| 1206 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1207 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | LogChannelCreateInstance |
| 1211 | PluginManager::GetLogChannelCreateCallbackForPluginName (const char *name) |
| 1212 | { |
| 1213 | if (name && name[0]) |
| 1214 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1215 | llvm::StringRef name_sref(name); |
| 1216 | Mutex::Locker locker (GetLogMutex ()); |
| 1217 | LogInstances &instances = GetLogInstances (); |
| 1218 | |
| 1219 | LogInstances::iterator pos, end = instances.end(); |
| 1220 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1221 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1222 | if (name_sref.equals (pos->name)) |
| 1223 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1224 | } |
| 1225 | } |
| 1226 | return NULL; |
| 1227 | } |
| 1228 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1229 | #pragma mark Platform |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1230 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1231 | struct PlatformInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1232 | { |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1233 | PlatformInstance() : |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1234 | name(), |
| 1235 | description(), |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1236 | create_callback(NULL), |
| 1237 | debugger_init_callback (NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1238 | { |
| 1239 | } |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1240 | |
| 1241 | std::string name; |
| 1242 | std::string description; |
| 1243 | PlatformCreateInstance create_callback; |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1244 | DebuggerInitializeCallback debugger_init_callback; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1245 | }; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1246 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1247 | typedef std::vector<PlatformInstance> PlatformInstances; |
| 1248 | |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1249 | static Mutex & |
| 1250 | GetPlatformInstancesMutex () |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1251 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1252 | static Mutex g_platform_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1253 | return g_platform_instances_mutex; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1254 | } |
| 1255 | |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1256 | static PlatformInstances & |
| 1257 | GetPlatformInstances () |
| 1258 | { |
| 1259 | static PlatformInstances g_platform_instances; |
| 1260 | return g_platform_instances; |
| 1261 | } |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1262 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1263 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1264 | bool |
| 1265 | PluginManager::RegisterPlugin (const char *name, |
| 1266 | const char *description, |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1267 | PlatformCreateInstance create_callback, |
| 1268 | DebuggerInitializeCallback debugger_init_callback) |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1269 | { |
| 1270 | if (create_callback) |
| 1271 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1272 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
| 1273 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1274 | PlatformInstance instance; |
| 1275 | assert (name && name[0]); |
| 1276 | instance.name = name; |
| 1277 | if (description && description[0]) |
| 1278 | instance.description = description; |
| 1279 | instance.create_callback = create_callback; |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1280 | instance.debugger_init_callback = debugger_init_callback; |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1281 | GetPlatformInstances ().push_back (instance); |
| 1282 | return true; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1283 | } |
| 1284 | return false; |
| 1285 | } |
| 1286 | |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1287 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1288 | const char * |
| 1289 | PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx) |
| 1290 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1291 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1292 | PlatformInstances &instances = GetPlatformInstances (); |
| 1293 | if (idx < instances.size()) |
| 1294 | return instances[idx].name.c_str(); |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1295 | return NULL; |
| 1296 | } |
| 1297 | |
| 1298 | const char * |
| 1299 | PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx) |
| 1300 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1301 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1302 | PlatformInstances &instances = GetPlatformInstances (); |
| 1303 | if (idx < instances.size()) |
| 1304 | return instances[idx].description.c_str(); |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1305 | return NULL; |
| 1306 | } |
| 1307 | |
| 1308 | bool |
| 1309 | PluginManager::UnregisterPlugin (PlatformCreateInstance create_callback) |
| 1310 | { |
| 1311 | if (create_callback) |
| 1312 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1313 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1314 | PlatformInstances &instances = GetPlatformInstances (); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1315 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1316 | PlatformInstances::iterator pos, end = instances.end(); |
| 1317 | for (pos = instances.begin(); pos != end; ++ pos) |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1318 | { |
| 1319 | if (pos->create_callback == create_callback) |
| 1320 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1321 | instances.erase(pos); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1322 | return true; |
| 1323 | } |
| 1324 | } |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1325 | } |
| 1326 | return false; |
| 1327 | } |
| 1328 | |
| 1329 | PlatformCreateInstance |
| 1330 | PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx) |
| 1331 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1332 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1333 | PlatformInstances &instances = GetPlatformInstances (); |
| 1334 | if (idx < instances.size()) |
| 1335 | return instances[idx].create_callback; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1336 | return NULL; |
| 1337 | } |
| 1338 | |
| 1339 | PlatformCreateInstance |
| 1340 | PluginManager::GetPlatformCreateCallbackForPluginName (const char *name) |
| 1341 | { |
| 1342 | if (name && name[0]) |
| 1343 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1344 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1345 | PlatformInstances &instances = GetPlatformInstances (); |
| 1346 | llvm::StringRef name_sref(name); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1347 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1348 | PlatformInstances::iterator pos, end = instances.end(); |
| 1349 | for (pos = instances.begin(); pos != end; ++ pos) |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1350 | { |
Greg Clayton | 7260f62 | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 1351 | if (name_sref.equals (pos->name)) |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 1352 | return pos->create_callback; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1353 | } |
| 1354 | } |
| 1355 | return NULL; |
| 1356 | } |
| 1357 | |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 1358 | size_t |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1359 | PluginManager::AutoCompletePlatformName (const char *name, StringList &matches) |
| 1360 | { |
| 1361 | if (name && name[0]) |
| 1362 | { |
| 1363 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
| 1364 | PlatformInstances &instances = GetPlatformInstances (); |
| 1365 | llvm::StringRef name_sref(name); |
| 1366 | |
| 1367 | PlatformInstances::iterator pos, end = instances.end(); |
| 1368 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1369 | { |
Greg Clayton | 7260f62 | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 1370 | llvm::StringRef plugin_name (pos->name); |
| 1371 | if (plugin_name.startswith(name_sref)) |
| 1372 | matches.AppendString (plugin_name.data()); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1373 | } |
| 1374 | } |
| 1375 | return matches.GetSize(); |
| 1376 | } |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1377 | #pragma mark Process |
| 1378 | |
| 1379 | struct ProcessInstance |
| 1380 | { |
| 1381 | ProcessInstance() : |
| 1382 | name(), |
| 1383 | description(), |
| 1384 | create_callback(NULL) |
| 1385 | { |
| 1386 | } |
| 1387 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1388 | std::string name; |
| 1389 | std::string description; |
| 1390 | ProcessCreateInstance create_callback; |
| 1391 | }; |
| 1392 | |
| 1393 | typedef std::vector<ProcessInstance> ProcessInstances; |
| 1394 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1395 | static Mutex & |
| 1396 | GetProcessMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1397 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1398 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1399 | return g_instances_mutex; |
| 1400 | } |
| 1401 | |
| 1402 | static ProcessInstances & |
| 1403 | GetProcessInstances () |
| 1404 | { |
| 1405 | static ProcessInstances g_instances; |
| 1406 | return g_instances; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
| 1409 | |
| 1410 | bool |
| 1411 | PluginManager::RegisterPlugin |
| 1412 | ( |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 1413 | const char *name, |
| 1414 | const char *description, |
| 1415 | ProcessCreateInstance create_callback |
| 1416 | ) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1417 | { |
| 1418 | if (create_callback) |
| 1419 | { |
| 1420 | ProcessInstance instance; |
| 1421 | assert (name && name[0]); |
| 1422 | instance.name = name; |
| 1423 | if (description && description[0]) |
| 1424 | instance.description = description; |
| 1425 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1426 | Mutex::Locker locker (GetProcessMutex ()); |
| 1427 | GetProcessInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1428 | } |
| 1429 | return false; |
| 1430 | } |
| 1431 | |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 1432 | const char * |
| 1433 | PluginManager::GetProcessPluginNameAtIndex (uint32_t idx) |
| 1434 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1435 | Mutex::Locker locker (GetProcessMutex ()); |
| 1436 | ProcessInstances &instances = GetProcessInstances (); |
| 1437 | if (idx < instances.size()) |
| 1438 | return instances[idx].name.c_str(); |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 1439 | return NULL; |
| 1440 | } |
| 1441 | |
| 1442 | const char * |
| 1443 | PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx) |
| 1444 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1445 | Mutex::Locker locker (GetProcessMutex ()); |
| 1446 | ProcessInstances &instances = GetProcessInstances (); |
| 1447 | if (idx < instances.size()) |
| 1448 | return instances[idx].description.c_str(); |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 1449 | return NULL; |
| 1450 | } |
| 1451 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1452 | bool |
| 1453 | PluginManager::UnregisterPlugin (ProcessCreateInstance create_callback) |
| 1454 | { |
| 1455 | if (create_callback) |
| 1456 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1457 | Mutex::Locker locker (GetProcessMutex ()); |
| 1458 | ProcessInstances &instances = GetProcessInstances (); |
| 1459 | |
| 1460 | ProcessInstances::iterator pos, end = instances.end(); |
| 1461 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1462 | { |
| 1463 | if (pos->create_callback == create_callback) |
| 1464 | { |
| 1465 | instances.erase(pos); |
| 1466 | return true; |
| 1467 | } |
| 1468 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1469 | } |
| 1470 | return false; |
| 1471 | } |
| 1472 | |
| 1473 | ProcessCreateInstance |
| 1474 | PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx) |
| 1475 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1476 | Mutex::Locker locker (GetProcessMutex ()); |
| 1477 | ProcessInstances &instances = GetProcessInstances (); |
| 1478 | if (idx < instances.size()) |
| 1479 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1480 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1481 | } |
| 1482 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1483 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1484 | ProcessCreateInstance |
| 1485 | PluginManager::GetProcessCreateCallbackForPluginName (const char *name) |
| 1486 | { |
| 1487 | if (name && name[0]) |
| 1488 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1489 | llvm::StringRef name_sref(name); |
| 1490 | Mutex::Locker locker (GetProcessMutex ()); |
| 1491 | ProcessInstances &instances = GetProcessInstances (); |
| 1492 | |
| 1493 | ProcessInstances::iterator pos, end = instances.end(); |
| 1494 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1495 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1496 | if (name_sref.equals (pos->name)) |
| 1497 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1498 | } |
| 1499 | } |
| 1500 | return NULL; |
| 1501 | } |
| 1502 | |
| 1503 | #pragma mark SymbolFile |
| 1504 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1505 | struct SymbolFileInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1506 | { |
| 1507 | SymbolFileInstance() : |
| 1508 | name(), |
| 1509 | description(), |
| 1510 | create_callback(NULL) |
| 1511 | { |
| 1512 | } |
| 1513 | |
| 1514 | std::string name; |
| 1515 | std::string description; |
| 1516 | SymbolFileCreateInstance create_callback; |
| 1517 | }; |
| 1518 | |
| 1519 | typedef std::vector<SymbolFileInstance> SymbolFileInstances; |
| 1520 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1521 | static Mutex & |
| 1522 | GetSymbolFileMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1523 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1524 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1525 | return g_instances_mutex; |
| 1526 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1527 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1528 | static SymbolFileInstances & |
| 1529 | GetSymbolFileInstances () |
| 1530 | { |
| 1531 | static SymbolFileInstances g_instances; |
| 1532 | return g_instances; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | |
| 1536 | bool |
| 1537 | PluginManager::RegisterPlugin |
| 1538 | ( |
| 1539 | const char *name, |
| 1540 | const char *description, |
| 1541 | SymbolFileCreateInstance create_callback |
| 1542 | ) |
| 1543 | { |
| 1544 | if (create_callback) |
| 1545 | { |
| 1546 | SymbolFileInstance instance; |
| 1547 | assert (name && name[0]); |
| 1548 | instance.name = name; |
| 1549 | if (description && description[0]) |
| 1550 | instance.description = description; |
| 1551 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1552 | Mutex::Locker locker (GetSymbolFileMutex ()); |
| 1553 | GetSymbolFileInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1554 | } |
| 1555 | return false; |
| 1556 | } |
| 1557 | |
| 1558 | bool |
| 1559 | PluginManager::UnregisterPlugin (SymbolFileCreateInstance create_callback) |
| 1560 | { |
| 1561 | if (create_callback) |
| 1562 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1563 | Mutex::Locker locker (GetSymbolFileMutex ()); |
| 1564 | SymbolFileInstances &instances = GetSymbolFileInstances (); |
| 1565 | |
| 1566 | SymbolFileInstances::iterator pos, end = instances.end(); |
| 1567 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1568 | { |
| 1569 | if (pos->create_callback == create_callback) |
| 1570 | { |
| 1571 | instances.erase(pos); |
| 1572 | return true; |
| 1573 | } |
| 1574 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1575 | } |
| 1576 | return false; |
| 1577 | } |
| 1578 | |
| 1579 | SymbolFileCreateInstance |
| 1580 | PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx) |
| 1581 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1582 | Mutex::Locker locker (GetSymbolFileMutex ()); |
| 1583 | SymbolFileInstances &instances = GetSymbolFileInstances (); |
| 1584 | if (idx < instances.size()) |
| 1585 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1586 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1587 | } |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1588 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1589 | SymbolFileCreateInstance |
| 1590 | PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name) |
| 1591 | { |
| 1592 | if (name && name[0]) |
| 1593 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1594 | llvm::StringRef name_sref(name); |
| 1595 | Mutex::Locker locker (GetSymbolFileMutex ()); |
| 1596 | SymbolFileInstances &instances = GetSymbolFileInstances (); |
| 1597 | |
| 1598 | SymbolFileInstances::iterator pos, end = instances.end(); |
| 1599 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1600 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1601 | if (name_sref.equals (pos->name)) |
| 1602 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1603 | } |
| 1604 | } |
| 1605 | return NULL; |
| 1606 | } |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | #pragma mark SymbolVendor |
| 1611 | |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1612 | struct SymbolVendorInstance |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1613 | { |
| 1614 | SymbolVendorInstance() : |
| 1615 | name(), |
| 1616 | description(), |
| 1617 | create_callback(NULL) |
| 1618 | { |
| 1619 | } |
| 1620 | |
| 1621 | std::string name; |
| 1622 | std::string description; |
| 1623 | SymbolVendorCreateInstance create_callback; |
| 1624 | }; |
| 1625 | |
| 1626 | typedef std::vector<SymbolVendorInstance> SymbolVendorInstances; |
| 1627 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1628 | static Mutex & |
| 1629 | GetSymbolVendorMutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1630 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1631 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1632 | return g_instances_mutex; |
| 1633 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1634 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1635 | static SymbolVendorInstances & |
| 1636 | GetSymbolVendorInstances () |
| 1637 | { |
| 1638 | static SymbolVendorInstances g_instances; |
| 1639 | return g_instances; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1640 | } |
| 1641 | |
| 1642 | bool |
| 1643 | PluginManager::RegisterPlugin |
| 1644 | ( |
| 1645 | const char *name, |
| 1646 | const char *description, |
| 1647 | SymbolVendorCreateInstance create_callback |
| 1648 | ) |
| 1649 | { |
| 1650 | if (create_callback) |
| 1651 | { |
| 1652 | SymbolVendorInstance instance; |
| 1653 | assert (name && name[0]); |
| 1654 | instance.name = name; |
| 1655 | if (description && description[0]) |
| 1656 | instance.description = description; |
| 1657 | instance.create_callback = create_callback; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1658 | Mutex::Locker locker (GetSymbolVendorMutex ()); |
| 1659 | GetSymbolVendorInstances ().push_back (instance); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1660 | } |
| 1661 | return false; |
| 1662 | } |
| 1663 | |
| 1664 | bool |
| 1665 | PluginManager::UnregisterPlugin (SymbolVendorCreateInstance create_callback) |
| 1666 | { |
| 1667 | if (create_callback) |
| 1668 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1669 | Mutex::Locker locker (GetSymbolVendorMutex ()); |
| 1670 | SymbolVendorInstances &instances = GetSymbolVendorInstances (); |
| 1671 | |
| 1672 | SymbolVendorInstances::iterator pos, end = instances.end(); |
| 1673 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1674 | { |
| 1675 | if (pos->create_callback == create_callback) |
| 1676 | { |
| 1677 | instances.erase(pos); |
| 1678 | return true; |
| 1679 | } |
| 1680 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1681 | } |
| 1682 | return false; |
| 1683 | } |
| 1684 | |
| 1685 | SymbolVendorCreateInstance |
| 1686 | PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx) |
| 1687 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1688 | Mutex::Locker locker (GetSymbolVendorMutex ()); |
| 1689 | SymbolVendorInstances &instances = GetSymbolVendorInstances (); |
| 1690 | if (idx < instances.size()) |
| 1691 | return instances[idx].create_callback; |
Jason Molenda | 743e86a | 2010-06-11 23:44:18 +0000 | [diff] [blame] | 1692 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1693 | } |
| 1694 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1695 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1696 | SymbolVendorCreateInstance |
| 1697 | PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name) |
| 1698 | { |
| 1699 | if (name && name[0]) |
| 1700 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1701 | llvm::StringRef name_sref(name); |
| 1702 | Mutex::Locker locker (GetSymbolVendorMutex ()); |
| 1703 | SymbolVendorInstances &instances = GetSymbolVendorInstances (); |
| 1704 | |
| 1705 | SymbolVendorInstances::iterator pos, end = instances.end(); |
| 1706 | for (pos = instances.begin(); pos != end; ++ pos) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1707 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1708 | if (name_sref.equals (pos->name)) |
| 1709 | return pos->create_callback; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1710 | } |
| 1711 | } |
| 1712 | return NULL; |
| 1713 | } |
| 1714 | |
| 1715 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1716 | #pragma mark UnwindAssembly |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1717 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1718 | struct UnwindAssemblyInstance |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1719 | { |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1720 | UnwindAssemblyInstance() : |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1721 | name(), |
| 1722 | description(), |
| 1723 | create_callback(NULL) |
| 1724 | { |
| 1725 | } |
| 1726 | |
| 1727 | std::string name; |
| 1728 | std::string description; |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1729 | UnwindAssemblyCreateInstance create_callback; |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1730 | }; |
| 1731 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1732 | typedef std::vector<UnwindAssemblyInstance> UnwindAssemblyInstances; |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1733 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1734 | static Mutex & |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1735 | GetUnwindAssemblyMutex () |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1736 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1737 | static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); |
| 1738 | return g_instances_mutex; |
| 1739 | } |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1740 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1741 | static UnwindAssemblyInstances & |
| 1742 | GetUnwindAssemblyInstances () |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1743 | { |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1744 | static UnwindAssemblyInstances g_instances; |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1745 | return g_instances; |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1746 | } |
| 1747 | |
| 1748 | bool |
| 1749 | PluginManager::RegisterPlugin |
| 1750 | ( |
| 1751 | const char *name, |
| 1752 | const char *description, |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1753 | UnwindAssemblyCreateInstance create_callback |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1754 | ) |
| 1755 | { |
| 1756 | if (create_callback) |
| 1757 | { |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1758 | UnwindAssemblyInstance instance; |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1759 | assert (name && name[0]); |
| 1760 | instance.name = name; |
| 1761 | if (description && description[0]) |
| 1762 | instance.description = description; |
| 1763 | instance.create_callback = create_callback; |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1764 | Mutex::Locker locker (GetUnwindAssemblyMutex ()); |
| 1765 | GetUnwindAssemblyInstances ().push_back (instance); |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1766 | } |
| 1767 | return false; |
| 1768 | } |
| 1769 | |
| 1770 | bool |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1771 | PluginManager::UnregisterPlugin (UnwindAssemblyCreateInstance create_callback) |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1772 | { |
| 1773 | if (create_callback) |
| 1774 | { |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1775 | Mutex::Locker locker (GetUnwindAssemblyMutex ()); |
| 1776 | UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1777 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1778 | UnwindAssemblyInstances::iterator pos, end = instances.end(); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1779 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1780 | { |
| 1781 | if (pos->create_callback == create_callback) |
| 1782 | { |
| 1783 | instances.erase(pos); |
| 1784 | return true; |
| 1785 | } |
| 1786 | } |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1787 | } |
| 1788 | return false; |
| 1789 | } |
| 1790 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1791 | UnwindAssemblyCreateInstance |
| 1792 | PluginManager::GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx) |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1793 | { |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1794 | Mutex::Locker locker (GetUnwindAssemblyMutex ()); |
| 1795 | UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1796 | if (idx < instances.size()) |
| 1797 | return instances[idx].create_callback; |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1798 | return NULL; |
| 1799 | } |
| 1800 | |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1801 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1802 | UnwindAssemblyCreateInstance |
| 1803 | PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name) |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1804 | { |
| 1805 | if (name && name[0]) |
| 1806 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1807 | llvm::StringRef name_sref(name); |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1808 | Mutex::Locker locker (GetUnwindAssemblyMutex ()); |
| 1809 | UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1810 | |
Greg Clayton | 7be2542 | 2011-04-25 21:14:26 +0000 | [diff] [blame] | 1811 | UnwindAssemblyInstances::iterator pos, end = instances.end(); |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1812 | for (pos = instances.begin(); pos != end; ++ pos) |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1813 | { |
Greg Clayton | ab65b34 | 2011-04-13 22:47:15 +0000 | [diff] [blame] | 1814 | if (name_sref.equals (pos->name)) |
| 1815 | return pos->create_callback; |
Jason Molenda | fbcb7f2 | 2010-09-10 07:49:16 +0000 | [diff] [blame] | 1816 | } |
| 1817 | } |
| 1818 | return NULL; |
| 1819 | } |
| 1820 | |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1821 | void |
| 1822 | PluginManager::DebuggerInitialize (Debugger &debugger) |
| 1823 | { |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1824 | // Initialize the DynamicLoader plugins |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1825 | { |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1826 | Mutex::Locker locker (GetDynamicLoaderMutex ()); |
| 1827 | DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); |
| 1828 | |
| 1829 | DynamicLoaderInstances::iterator pos, end = instances.end(); |
| 1830 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1831 | { |
| 1832 | if (pos->debugger_init_callback) |
| 1833 | pos->debugger_init_callback (debugger); |
| 1834 | } |
| 1835 | } |
| 1836 | |
| 1837 | // Initialize the Platform plugins |
| 1838 | { |
| 1839 | Mutex::Locker locker (GetPlatformInstancesMutex ()); |
| 1840 | PlatformInstances &instances = GetPlatformInstances (); |
| 1841 | |
| 1842 | PlatformInstances::iterator pos, end = instances.end(); |
| 1843 | for (pos = instances.begin(); pos != end; ++ pos) |
| 1844 | { |
| 1845 | if (pos->debugger_init_callback) |
| 1846 | pos->debugger_init_callback (debugger); |
| 1847 | } |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1848 | } |
| 1849 | } |
| 1850 | |
Jason Molenda | 3b59f5c | 2013-04-05 22:40:42 +0000 | [diff] [blame] | 1851 | // This will put a plugin's settings under e.g. "plugin.dynamic-loader.darwin-kernel.SETTINGNAME". |
| 1852 | // The new preferred ordering is to put plugins under "dynamic-loader.plugin.darwin-kernel.SETTINGNAME" |
| 1853 | // and if there were a generic dynamic-loader setting, it would be "dynamic-loader.SETTINGNAME". |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1854 | static lldb::OptionValuePropertiesSP |
Jason Molenda | 3b59f5c | 2013-04-05 22:40:42 +0000 | [diff] [blame] | 1855 | GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger, |
| 1856 | const ConstString &plugin_type_name, |
| 1857 | const ConstString &plugin_type_desc, |
| 1858 | bool can_create) |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1859 | { |
| 1860 | lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties()); |
| 1861 | if (parent_properties_sp) |
| 1862 | { |
| 1863 | static ConstString g_property_name("plugin"); |
| 1864 | |
| 1865 | OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, g_property_name); |
| 1866 | if (!plugin_properties_sp && can_create) |
| 1867 | { |
| 1868 | plugin_properties_sp.reset (new OptionValueProperties (g_property_name)); |
| 1869 | parent_properties_sp->AppendProperty (g_property_name, |
| 1870 | ConstString("Settings specify to plugins."), |
| 1871 | true, |
| 1872 | plugin_properties_sp); |
| 1873 | } |
| 1874 | |
| 1875 | if (plugin_properties_sp) |
| 1876 | { |
| 1877 | lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, plugin_type_name); |
| 1878 | if (!plugin_type_properties_sp && can_create) |
| 1879 | { |
| 1880 | plugin_type_properties_sp.reset (new OptionValueProperties (plugin_type_name)); |
| 1881 | plugin_properties_sp->AppendProperty (plugin_type_name, |
| 1882 | plugin_type_desc, |
| 1883 | true, |
| 1884 | plugin_type_properties_sp); |
| 1885 | } |
| 1886 | return plugin_type_properties_sp; |
| 1887 | } |
| 1888 | } |
| 1889 | return lldb::OptionValuePropertiesSP(); |
| 1890 | } |
| 1891 | |
Jason Molenda | 3b59f5c | 2013-04-05 22:40:42 +0000 | [diff] [blame] | 1892 | // This is the preferred new way to register plugin specific settings. e.g. |
| 1893 | // "platform.plugin.darwin-kernel.SETTINGNAME" |
| 1894 | // and Platform generic settings would be under "platform.SETTINGNAME". |
| 1895 | static lldb::OptionValuePropertiesSP |
| 1896 | GetDebuggerPropertyForPlugins (Debugger &debugger, |
| 1897 | const ConstString &plugin_type_name, |
| 1898 | const ConstString &plugin_type_desc, |
| 1899 | bool can_create) |
| 1900 | { |
| 1901 | static ConstString g_property_name("plugin"); |
| 1902 | lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties()); |
| 1903 | if (parent_properties_sp) |
| 1904 | { |
| 1905 | OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, plugin_type_name); |
| 1906 | if (!plugin_properties_sp && can_create) |
| 1907 | { |
| 1908 | plugin_properties_sp.reset (new OptionValueProperties (plugin_type_name)); |
| 1909 | parent_properties_sp->AppendProperty (plugin_type_name, |
| 1910 | plugin_type_desc, |
| 1911 | true, |
| 1912 | plugin_properties_sp); |
| 1913 | } |
| 1914 | |
| 1915 | if (plugin_properties_sp) |
| 1916 | { |
| 1917 | lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, g_property_name); |
| 1918 | if (!plugin_type_properties_sp && can_create) |
| 1919 | { |
| 1920 | plugin_type_properties_sp.reset (new OptionValueProperties (g_property_name)); |
| 1921 | plugin_properties_sp->AppendProperty (g_property_name, |
| 1922 | ConstString("Settings specific to plugins"), |
| 1923 | true, |
| 1924 | plugin_type_properties_sp); |
| 1925 | } |
| 1926 | return plugin_type_properties_sp; |
| 1927 | } |
| 1928 | } |
| 1929 | return lldb::OptionValuePropertiesSP(); |
| 1930 | } |
| 1931 | |
| 1932 | |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1933 | lldb::OptionValuePropertiesSP |
| 1934 | PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name) |
| 1935 | { |
| 1936 | lldb::OptionValuePropertiesSP properties_sp; |
Jason Molenda | 3b59f5c | 2013-04-05 22:40:42 +0000 | [diff] [blame] | 1937 | lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger, |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1938 | ConstString("dynamic-loader"), |
| 1939 | ConstString(), // not creating to so we don't need the description |
| 1940 | false)); |
| 1941 | if (plugin_type_properties_sp) |
| 1942 | properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name); |
| 1943 | return properties_sp; |
| 1944 | } |
| 1945 | |
| 1946 | bool |
| 1947 | PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger, |
| 1948 | const lldb::OptionValuePropertiesSP &properties_sp, |
| 1949 | const ConstString &description, |
| 1950 | bool is_global_property) |
| 1951 | { |
| 1952 | if (properties_sp) |
| 1953 | { |
Jason Molenda | 3b59f5c | 2013-04-05 22:40:42 +0000 | [diff] [blame] | 1954 | lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger, |
Greg Clayton | e8cd0c9 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 1955 | ConstString("dynamic-loader"), |
| 1956 | ConstString("Settings for dynamic loader plug-ins"), |
| 1957 | true)); |
| 1958 | if (plugin_type_properties_sp) |
| 1959 | { |
| 1960 | plugin_type_properties_sp->AppendProperty (properties_sp->GetName(), |
| 1961 | description, |
| 1962 | is_global_property, |
| 1963 | properties_sp); |
| 1964 | return true; |
| 1965 | } |
| 1966 | } |
| 1967 | return false; |
| 1968 | } |
| 1969 | |
Jason Molenda | 9b837a1 | 2013-04-05 05:06:39 +0000 | [diff] [blame] | 1970 | |
| 1971 | lldb::OptionValuePropertiesSP |
| 1972 | PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name) |
| 1973 | { |
| 1974 | lldb::OptionValuePropertiesSP properties_sp; |
| 1975 | lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger, |
| 1976 | ConstString("platform"), |
| 1977 | ConstString(), // not creating to so we don't need the description |
| 1978 | false)); |
| 1979 | if (plugin_type_properties_sp) |
| 1980 | properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name); |
| 1981 | return properties_sp; |
| 1982 | } |
| 1983 | |
| 1984 | bool |
| 1985 | PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger, |
| 1986 | const lldb::OptionValuePropertiesSP &properties_sp, |
| 1987 | const ConstString &description, |
| 1988 | bool is_global_property) |
| 1989 | { |
| 1990 | if (properties_sp) |
| 1991 | { |
| 1992 | lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger, |
| 1993 | ConstString("platform"), |
| 1994 | ConstString("Settings for platform plug-ins"), |
| 1995 | true)); |
| 1996 | if (plugin_type_properties_sp) |
| 1997 | { |
| 1998 | plugin_type_properties_sp->AppendProperty (properties_sp->GetName(), |
| 1999 | description, |
| 2000 | is_global_property, |
| 2001 | properties_sp); |
| 2002 | return true; |
| 2003 | } |
| 2004 | } |
| 2005 | return false; |
| 2006 | } |
| 2007 | |