Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 1 | //===-- SystemInitializerFull.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 | |
| 10 | #include "lldb/API/SystemInitializerFull.h" |
| 11 | |
| 12 | #include "lldb/Core/Debugger.h" |
| 13 | #include "lldb/Core/Timer.h" |
| 14 | #include "lldb/Host/Host.h" |
| 15 | #include "lldb/Initialization/SystemInitializerCommon.h" |
| 16 | |
| 17 | #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" |
| 18 | #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" |
| 19 | #include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h" |
Omair Javaid | 52f825b | 2015-04-29 10:49:45 +0000 | [diff] [blame] | 20 | #include "Plugins/ABI/SysV-arm/ABISysV_arm.h" |
Omair Javaid | b78e05f | 2015-04-29 11:52:35 +0000 | [diff] [blame] | 21 | #include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h" |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 22 | #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" |
| 23 | #include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h" |
| 24 | #include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h" |
Bhushan D. Attarde | a8219f2 | 2015-06-18 07:02:10 +0000 | [diff] [blame] | 25 | #include "Plugins/ABI/SysV-mips/ABISysV_mips.h" |
Bhushan D. Attarde | 13f5425 | 2015-06-19 04:25:07 +0000 | [diff] [blame] | 26 | #include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h" |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 27 | #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" |
| 28 | #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 29 | #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 30 | #include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h" |
| 31 | #include "Plugins/JITLoader/GDB/JITLoaderGDB.h" |
| 32 | #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" |
| 33 | #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" |
| 34 | #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" |
Colin Riley | 5ec532a | 2015-04-09 16:49:25 +0000 | [diff] [blame] | 35 | #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 36 | #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" |
| 37 | #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" |
| 38 | #include "Plugins/Process/elf-core/ProcessElfCore.h" |
| 39 | #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" |
| 40 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" |
| 41 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" |
| 42 | #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" |
| 43 | #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" |
| 44 | #include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h" |
| 45 | #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" |
| 46 | #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" |
| 47 | |
| 48 | #if defined(__APPLE__) |
| 49 | #include "Plugins/Process/mach-core/ProcessMachCore.h" |
| 50 | #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" |
| 51 | #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" |
| 52 | #endif |
| 53 | |
| 54 | #if defined(__FreeBSD__) |
| 55 | #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" |
| 56 | #endif |
| 57 | |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 58 | #if defined(_MSC_VER) |
| 59 | #include "lldb/Host/windows/windows.h" |
| 60 | #include "Plugins/Process/Windows/DynamicLoaderWindows.h" |
| 61 | #include "Plugins/Process/Windows/ProcessWindows.h" |
| 62 | #endif |
| 63 | |
| 64 | #if !defined(LLDB_DISABLE_PYTHON) |
| 65 | #include "lldb/Interpreter/ScriptInterpreterPython.h" |
| 66 | #endif |
| 67 | |
| 68 | #include "llvm/Support/TargetSelect.h" |
| 69 | |
| 70 | #include <string> |
| 71 | |
| 72 | using namespace lldb_private; |
| 73 | |
| 74 | #ifndef LLDB_DISABLE_PYTHON |
| 75 | |
| 76 | // Defined in the SWIG source file |
| 77 | extern "C" void |
| 78 | init_lldb(void); |
| 79 | |
| 80 | // these are the Pythonic implementations of the required callbacks |
| 81 | // these are scripting-language specific, which is why they belong here |
| 82 | // we still need to use function pointers to them instead of relying |
| 83 | // on linkage-time resolution because the SWIG stuff and this file |
| 84 | // get built at different times |
| 85 | extern "C" bool |
| 86 | LLDBSwigPythonBreakpointCallbackFunction (const char *python_function_name, |
| 87 | const char *session_dictionary_name, |
| 88 | const lldb::StackFrameSP& sb_frame, |
| 89 | const lldb::BreakpointLocationSP& sb_bp_loc); |
| 90 | |
| 91 | extern "C" bool |
| 92 | LLDBSwigPythonWatchpointCallbackFunction (const char *python_function_name, |
| 93 | const char *session_dictionary_name, |
| 94 | const lldb::StackFrameSP& sb_frame, |
| 95 | const lldb::WatchpointSP& sb_wp); |
| 96 | |
| 97 | extern "C" bool |
| 98 | LLDBSwigPythonCallTypeScript (const char *python_function_name, |
| 99 | void *session_dictionary, |
| 100 | const lldb::ValueObjectSP& valobj_sp, |
| 101 | void** pyfunct_wrapper, |
| 102 | const lldb::TypeSummaryOptionsSP& options_sp, |
| 103 | std::string& retval); |
| 104 | |
| 105 | extern "C" void* |
| 106 | LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name, |
| 107 | const char *session_dictionary_name, |
| 108 | const lldb::ValueObjectSP& valobj_sp); |
| 109 | |
| 110 | extern "C" void* |
| 111 | LLDBSwigPythonCreateCommandObject (const char *python_class_name, |
| 112 | const char *session_dictionary_name, |
| 113 | const lldb::DebuggerSP debugger_sp); |
| 114 | |
| 115 | extern "C" void* |
| 116 | LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name, |
| 117 | const char *session_dictionary_name, |
| 118 | const lldb::ThreadPlanSP& thread_plan_sp); |
| 119 | |
| 120 | extern "C" bool |
| 121 | LLDBSWIGPythonCallThreadPlan (void *implementor, |
| 122 | const char *method_name, |
| 123 | Event *event_sp, |
| 124 | bool &got_error); |
| 125 | |
| 126 | extern "C" size_t |
| 127 | LLDBSwigPython_CalculateNumChildren (void *implementor); |
| 128 | |
| 129 | extern "C" void * |
| 130 | LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx); |
| 131 | |
| 132 | extern "C" int |
| 133 | LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name); |
| 134 | |
| 135 | extern "C" void * |
| 136 | LLDBSWIGPython_CastPyObjectToSBValue (void* data); |
| 137 | |
| 138 | extern lldb::ValueObjectSP |
| 139 | LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data); |
| 140 | |
| 141 | extern "C" bool |
| 142 | LLDBSwigPython_UpdateSynthProviderInstance (void* implementor); |
| 143 | |
| 144 | extern "C" bool |
| 145 | LLDBSwigPython_MightHaveChildrenSynthProviderInstance (void* implementor); |
| 146 | |
| 147 | extern "C" void * |
| 148 | LLDBSwigPython_GetValueSynthProviderInstance (void* implementor); |
| 149 | |
| 150 | extern "C" bool |
| 151 | LLDBSwigPythonCallCommand (const char *python_function_name, |
| 152 | const char *session_dictionary_name, |
| 153 | lldb::DebuggerSP& debugger, |
| 154 | const char* args, |
| 155 | lldb_private::CommandReturnObject &cmd_retobj, |
| 156 | lldb::ExecutionContextRefSP exe_ctx_ref_sp); |
| 157 | |
| 158 | extern "C" bool |
| 159 | LLDBSwigPythonCallCommandObject (void *implementor, |
| 160 | lldb::DebuggerSP& debugger, |
| 161 | const char* args, |
| 162 | lldb_private::CommandReturnObject& cmd_retobj, |
| 163 | lldb::ExecutionContextRefSP exe_ctx_ref_sp); |
| 164 | |
| 165 | extern "C" bool |
| 166 | LLDBSwigPythonCallModuleInit (const char *python_module_name, |
| 167 | const char *session_dictionary_name, |
| 168 | lldb::DebuggerSP& debugger); |
| 169 | |
| 170 | extern "C" void* |
| 171 | LLDBSWIGPythonCreateOSPlugin (const char *python_class_name, |
| 172 | const char *session_dictionary_name, |
| 173 | const lldb::ProcessSP& process_sp); |
| 174 | |
| 175 | extern "C" bool |
| 176 | LLDBSWIGPythonRunScriptKeywordProcess (const char* python_function_name, |
| 177 | const char* session_dictionary_name, |
| 178 | lldb::ProcessSP& process, |
| 179 | std::string& output); |
| 180 | |
| 181 | extern "C" bool |
| 182 | LLDBSWIGPythonRunScriptKeywordThread (const char* python_function_name, |
| 183 | const char* session_dictionary_name, |
| 184 | lldb::ThreadSP& thread, |
| 185 | std::string& output); |
| 186 | |
| 187 | extern "C" bool |
| 188 | LLDBSWIGPythonRunScriptKeywordTarget (const char* python_function_name, |
| 189 | const char* session_dictionary_name, |
| 190 | lldb::TargetSP& target, |
| 191 | std::string& output); |
| 192 | |
| 193 | extern "C" bool |
| 194 | LLDBSWIGPythonRunScriptKeywordFrame (const char* python_function_name, |
| 195 | const char* session_dictionary_name, |
| 196 | lldb::StackFrameSP& frame, |
| 197 | std::string& output); |
| 198 | |
| 199 | extern "C" bool |
| 200 | LLDBSWIGPythonRunScriptKeywordValue (const char* python_function_name, |
| 201 | const char* session_dictionary_name, |
| 202 | lldb::ValueObjectSP& value, |
| 203 | std::string& output); |
| 204 | |
| 205 | extern "C" void* |
| 206 | LLDBSWIGPython_GetDynamicSetting (void* module, |
| 207 | const char* setting, |
| 208 | const lldb::TargetSP& target_sp); |
| 209 | |
| 210 | |
| 211 | #endif |
| 212 | |
| 213 | SystemInitializerFull::SystemInitializerFull() |
| 214 | { |
| 215 | } |
| 216 | |
| 217 | SystemInitializerFull::~SystemInitializerFull() |
| 218 | { |
| 219 | } |
| 220 | |
| 221 | void |
| 222 | SystemInitializerFull::Initialize() |
| 223 | { |
| 224 | InitializeSWIG(); |
| 225 | |
| 226 | SystemInitializerCommon::Initialize(); |
| 227 | |
| 228 | // Initialize LLVM and Clang |
| 229 | llvm::InitializeAllTargets(); |
| 230 | llvm::InitializeAllAsmPrinters(); |
| 231 | llvm::InitializeAllTargetMCs(); |
| 232 | llvm::InitializeAllDisassemblers(); |
| 233 | |
| 234 | ABIMacOSX_i386::Initialize(); |
| 235 | ABIMacOSX_arm::Initialize(); |
| 236 | ABIMacOSX_arm64::Initialize(); |
Omair Javaid | 52f825b | 2015-04-29 10:49:45 +0000 | [diff] [blame] | 237 | ABISysV_arm::Initialize(); |
Omair Javaid | b78e05f | 2015-04-29 11:52:35 +0000 | [diff] [blame] | 238 | ABISysV_arm64::Initialize(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 239 | ABISysV_x86_64::Initialize(); |
| 240 | ABISysV_ppc::Initialize(); |
| 241 | ABISysV_ppc64::Initialize(); |
Bhushan D. Attarde | a8219f2 | 2015-06-18 07:02:10 +0000 | [diff] [blame] | 242 | ABISysV_mips::Initialize(); |
Bhushan D. Attarde | 13f5425 | 2015-06-19 04:25:07 +0000 | [diff] [blame] | 243 | ABISysV_mips64::Initialize(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 244 | DisassemblerLLVMC::Initialize(); |
| 245 | |
| 246 | JITLoaderGDB::Initialize(); |
| 247 | ProcessElfCore::Initialize(); |
| 248 | MemoryHistoryASan::Initialize(); |
| 249 | AddressSanitizerRuntime::Initialize(); |
| 250 | |
| 251 | SymbolVendorELF::Initialize(); |
| 252 | SymbolFileDWARF::Initialize(); |
| 253 | SymbolFileSymtab::Initialize(); |
| 254 | UnwindAssemblyInstEmulation::Initialize(); |
| 255 | UnwindAssembly_x86::Initialize(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 256 | EmulateInstructionARM64::Initialize(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 257 | SymbolFileDWARFDebugMap::Initialize(); |
| 258 | ItaniumABILanguageRuntime::Initialize(); |
| 259 | AppleObjCRuntimeV2::Initialize(); |
| 260 | AppleObjCRuntimeV1::Initialize(); |
| 261 | SystemRuntimeMacOSX::Initialize(); |
Colin Riley | 5ec532a | 2015-04-09 16:49:25 +0000 | [diff] [blame] | 262 | RenderScriptRuntime::Initialize(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 263 | |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 264 | #if defined(_MSC_VER) |
| 265 | DynamicLoaderWindows::Initialize(); |
| 266 | ProcessWindows::Initialize(); |
| 267 | #endif |
| 268 | #if defined(__FreeBSD__) |
| 269 | ProcessFreeBSD::Initialize(); |
| 270 | #endif |
| 271 | #if defined(__APPLE__) |
| 272 | SymbolVendorMacOSX::Initialize(); |
| 273 | ProcessKDP::Initialize(); |
| 274 | ProcessMachCore::Initialize(); |
| 275 | #endif |
| 276 | //---------------------------------------------------------------------- |
| 277 | // Platform agnostic plugins |
| 278 | //---------------------------------------------------------------------- |
| 279 | platform_gdb_server::PlatformRemoteGDBServer::Initialize(); |
| 280 | |
| 281 | process_gdb_remote::ProcessGDBRemote::Initialize(); |
| 282 | DynamicLoaderStatic::Initialize(); |
| 283 | |
| 284 | // Scan for any system or user LLDB plug-ins |
| 285 | PluginManager::Initialize(); |
| 286 | |
| 287 | // The process settings need to know about installed plug-ins, so the Settings must be initialized |
| 288 | // AFTER PluginManager::Initialize is called. |
| 289 | |
| 290 | Debugger::SettingsInitialize(); |
| 291 | } |
| 292 | |
| 293 | void SystemInitializerFull::InitializeSWIG() |
| 294 | { |
| 295 | #if !defined(LLDB_DISABLE_PYTHON) |
| 296 | ScriptInterpreterPython::InitializeInterpreter( |
| 297 | init_lldb, |
| 298 | LLDBSwigPythonBreakpointCallbackFunction, |
| 299 | LLDBSwigPythonWatchpointCallbackFunction, |
| 300 | LLDBSwigPythonCallTypeScript, |
| 301 | LLDBSwigPythonCreateSyntheticProvider, |
| 302 | LLDBSwigPythonCreateCommandObject, |
| 303 | LLDBSwigPython_CalculateNumChildren, |
| 304 | LLDBSwigPython_GetChildAtIndex, |
| 305 | LLDBSwigPython_GetIndexOfChildWithName, |
| 306 | LLDBSWIGPython_CastPyObjectToSBValue, |
| 307 | LLDBSWIGPython_GetValueObjectSPFromSBValue, |
| 308 | LLDBSwigPython_UpdateSynthProviderInstance, |
| 309 | LLDBSwigPython_MightHaveChildrenSynthProviderInstance, |
| 310 | LLDBSwigPython_GetValueSynthProviderInstance, |
| 311 | LLDBSwigPythonCallCommand, |
| 312 | LLDBSwigPythonCallCommandObject, |
| 313 | LLDBSwigPythonCallModuleInit, |
| 314 | LLDBSWIGPythonCreateOSPlugin, |
| 315 | LLDBSWIGPythonRunScriptKeywordProcess, |
| 316 | LLDBSWIGPythonRunScriptKeywordThread, |
| 317 | LLDBSWIGPythonRunScriptKeywordTarget, |
| 318 | LLDBSWIGPythonRunScriptKeywordFrame, |
| 319 | LLDBSWIGPythonRunScriptKeywordValue, |
| 320 | LLDBSWIGPython_GetDynamicSetting, |
| 321 | LLDBSwigPythonCreateScriptedThreadPlan, |
| 322 | LLDBSWIGPythonCallThreadPlan); |
| 323 | #endif |
| 324 | } |
| 325 | |
| 326 | void |
| 327 | SystemInitializerFull::Terminate() |
| 328 | { |
| 329 | Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
| 330 | |
| 331 | Debugger::SettingsTerminate(); |
| 332 | |
| 333 | // Terminate and unload and loaded system or user LLDB plug-ins |
| 334 | PluginManager::Terminate(); |
| 335 | ABIMacOSX_i386::Terminate(); |
| 336 | ABIMacOSX_arm::Terminate(); |
| 337 | ABIMacOSX_arm64::Terminate(); |
Omair Javaid | 52f825b | 2015-04-29 10:49:45 +0000 | [diff] [blame] | 338 | ABISysV_arm::Terminate(); |
Omair Javaid | b78e05f | 2015-04-29 11:52:35 +0000 | [diff] [blame] | 339 | ABISysV_arm64::Terminate(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 340 | ABISysV_x86_64::Terminate(); |
| 341 | ABISysV_ppc::Terminate(); |
| 342 | ABISysV_ppc64::Terminate(); |
Bhushan D. Attarde | a8219f2 | 2015-06-18 07:02:10 +0000 | [diff] [blame] | 343 | ABISysV_mips::Terminate(); |
Bhushan D. Attarde | 13f5425 | 2015-06-19 04:25:07 +0000 | [diff] [blame] | 344 | ABISysV_mips64::Terminate(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 345 | DisassemblerLLVMC::Terminate(); |
| 346 | |
| 347 | JITLoaderGDB::Terminate(); |
| 348 | ProcessElfCore::Terminate(); |
| 349 | MemoryHistoryASan::Terminate(); |
| 350 | AddressSanitizerRuntime::Terminate(); |
| 351 | SymbolVendorELF::Terminate(); |
| 352 | SymbolFileDWARF::Terminate(); |
| 353 | SymbolFileSymtab::Terminate(); |
| 354 | UnwindAssembly_x86::Terminate(); |
| 355 | UnwindAssemblyInstEmulation::Terminate(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 356 | EmulateInstructionARM64::Terminate(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 357 | SymbolFileDWARFDebugMap::Terminate(); |
| 358 | ItaniumABILanguageRuntime::Terminate(); |
| 359 | AppleObjCRuntimeV2::Terminate(); |
| 360 | AppleObjCRuntimeV1::Terminate(); |
| 361 | SystemRuntimeMacOSX::Terminate(); |
Colin Riley | 5ec532a | 2015-04-09 16:49:25 +0000 | [diff] [blame] | 362 | RenderScriptRuntime::Terminate(); |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 363 | |
| 364 | #if defined(__APPLE__) |
| 365 | ProcessMachCore::Terminate(); |
| 366 | ProcessKDP::Terminate(); |
| 367 | SymbolVendorMacOSX::Terminate(); |
| 368 | #endif |
| 369 | #if defined(_MSC_VER) |
| 370 | DynamicLoaderWindows::Terminate(); |
| 371 | #endif |
| 372 | |
Zachary Turner | e6e2bb3 | 2015-03-31 21:03:22 +0000 | [diff] [blame] | 373 | #if defined(__FreeBSD__) |
| 374 | ProcessFreeBSD::Terminate(); |
| 375 | #endif |
| 376 | Debugger::SettingsTerminate(); |
| 377 | |
| 378 | platform_gdb_server::PlatformRemoteGDBServer::Terminate(); |
| 379 | process_gdb_remote::ProcessGDBRemote::Terminate(); |
| 380 | DynamicLoaderStatic::Terminate(); |
| 381 | |
| 382 | // Now shutdown the common parts, in reverse order. |
| 383 | SystemInitializerCommon::Terminate(); |
| 384 | } |
| 385 | |
| 386 | void SystemInitializerFull::TerminateSWIG() |
| 387 | { |
| 388 | |
| 389 | } |