blob: 3ca1e8c405fef801fae76226bc4dac9eaf0fc819 [file] [log] [blame]
Zachary Turnere6e2bb32015-03-31 21:03:22 +00001//===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Zachary Turnere6e2bb32015-03-31 21:03:22 +00006//
7//===----------------------------------------------------------------------===//
8
Zachary Turner2c1f46d2015-07-30 20:28:07 +00009#if !defined(LLDB_DISABLE_PYTHON)
10#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
11#endif
12
Alex Langfordd17cd902018-05-25 20:28:16 +000013#include "SystemInitializerFull.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000014
Zachary Turner2c1f46d2015-07-30 20:28:07 +000015#include "lldb/API/SBCommandInterpreter.h"
16
17#if !defined(LLDB_DISABLE_PYTHON)
18#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
19#endif
20
Zachary Turnere6e2bb32015-03-31 21:03:22 +000021#include "lldb/Core/Debugger.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000022#include "lldb/Host/Host.h"
23#include "lldb/Initialization/SystemInitializerCommon.h"
Zachary Turner2c1f46d2015-07-30 20:28:07 +000024#include "lldb/Interpreter/CommandInterpreter.h"
Greg Clayton56939cb2015-09-17 22:23:34 +000025#include "lldb/Symbol/ClangASTContext.h"
Pavel Labath38d06322017-06-29 14:32:17 +000026#include "lldb/Utility/Timer.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000027
Zachary Turnere6e2bb32015-03-31 21:03:22 +000028#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
29#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
Zachary Turner74e08ca2016-03-02 22:05:52 +000030#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
Omair Javaid52f825b2015-04-29 10:49:45 +000031#include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
Omair Javaidb78e05f2015-04-29 11:52:35 +000032#include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
Ted Woodwardbff0a212015-12-10 17:53:07 +000033#include "Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h"
Greg Claytonb289cba2015-06-25 17:50:15 +000034#include "Plugins/ABI/SysV-i386/ABISysV_i386.h"
Bhushan D. Attardea8219f22015-06-18 07:02:10 +000035#include "Plugins/ABI/SysV-mips/ABISysV_mips.h"
Bhushan D. Attarde13f54252015-06-19 04:25:07 +000036#include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h"
Zachary Turner74e08ca2016-03-02 22:05:52 +000037#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
38#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
Ulrich Weigandbb00d0b2016-04-14 14:28:34 +000039#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
Zachary Turner74e08ca2016-03-02 22:05:52 +000040#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
Pavel Labath13e37d42017-10-25 21:05:31 +000041#include "Plugins/Architecture/Arm/ArchitectureArm.h"
Tatyana Krasnukha98fc5482018-12-13 14:28:25 +000042#include "Plugins/Architecture/Mips/ArchitectureMips.h"
Jim Ingham08581262018-03-12 21:17:04 +000043#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000044#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
Jason Molenda9ab5dc22016-07-21 08:30:55 +000045#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000046#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
Pavel Labath773c3b02016-03-29 15:00:26 +000047#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
Pavel Labathf1763532016-06-29 13:58:27 +000048#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
Pavel Labath773c3b02016-03-29 15:00:26 +000049#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000050#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
Pavel Labatha535a7a2018-02-27 18:42:46 +000051#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
Pavel Labath2a1c09f2017-06-26 08:13:22 +000052#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
Pavel Labath13e37d42017-10-25 21:05:31 +000053#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
Pavel Labath2a1c09f2017-06-26 08:13:22 +000054#include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h"
55#include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000056#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
Enrico Granata980c0482015-09-01 18:22:39 +000057#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
58#include "Plugins/Language/ObjC/ObjCLanguage.h"
59#include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000060#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
Zachary Turner74e08ca2016-03-02 22:05:52 +000061#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
62#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
Colin Riley5ec532a2015-04-09 16:49:25 +000063#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000064#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
Pavel Labath1f6b2472018-12-10 17:16:38 +000065#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
Pavel Labathfa3fa5b2018-05-24 12:44:18 +000066#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
67#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
68#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
Pavel Labathf1763532016-06-29 13:58:27 +000069#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
70#include "Plugins/Platform/Android/PlatformAndroid.h"
71#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
72#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
73#include "Plugins/Platform/Linux/PlatformLinux.h"
74#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
75#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
76#include "Plugins/Platform/NetBSD/PlatformNetBSD.h"
Kamil Rytarowski12801f12017-03-26 15:34:57 +000077#include "Plugins/Platform/OpenBSD/PlatformOpenBSD.h"
Pavel Labathf1763532016-06-29 13:58:27 +000078#include "Plugins/Platform/Windows/PlatformWindows.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000079#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
80#include "Plugins/Process/elf-core/ProcessElfCore.h"
81#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
Pavel Labath4c7763e2018-05-22 16:33:43 +000082#include "Plugins/Process/mach-core/ProcessMachCore.h"
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000083#include "Plugins/Process/minidump/ProcessMinidump.h"
Zachary Turner2c1f46d2015-07-30 20:28:07 +000084#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
Pavel Labath1cf23e12019-01-11 11:17:51 +000085#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000086#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
87#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
Zachary Turner74e08ca2016-03-02 22:05:52 +000088#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000089#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
90#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
91#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000092#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
Zachary Turner74e08ca2016-03-02 22:05:52 +000093#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +000094
95#if defined(__APPLE__)
Pavel Labathf1763532016-06-29 13:58:27 +000096#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
Jason Molenda5e88be92015-11-06 00:22:53 +000097#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
98#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
Pavel Labathf1763532016-06-29 13:58:27 +000099#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
Jason Molenda5e88be92015-11-06 00:22:53 +0000100#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
101#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
Jason Molenda32762fd2018-10-11 00:28:35 +0000102#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
Pavel Labathf1763532016-06-29 13:58:27 +0000103#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
104#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
Pavel Labathf1763532016-06-29 13:58:27 +0000105#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000106#endif
Todd Fiala75930012016-08-19 04:21:48 +0000107#include "Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000108
109#if defined(__FreeBSD__)
110#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
111#endif
112
Hafiz Abid Qadeerf6ee79c2016-12-15 15:00:41 +0000113#if defined(_WIN32)
Adrian McCarthy4ad5def2016-11-23 16:26:37 +0000114#include "Plugins/Process/Windows/Common/ProcessWindows.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +0000115#include "lldb/Host/windows/windows.h"
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000116#endif
117
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000118#include "llvm/Support/TargetSelect.h"
119
120#include <string>
121
122using namespace lldb_private;
123
124#ifndef LLDB_DISABLE_PYTHON
125
126// Defined in the SWIG source file
Zachary Turnerc5b41d62015-10-16 17:52:03 +0000127#if PY_MAJOR_VERSION >= 3
Kate Stoneb9c1b512016-09-06 20:57:50 +0000128extern "C" PyObject *PyInit__lldb(void);
Zachary Turnerc5b41d62015-10-16 17:52:03 +0000129
130#define LLDBSwigPyInit PyInit__lldb
131
132#else
Kate Stoneb9c1b512016-09-06 20:57:50 +0000133extern "C" void init_lldb(void);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000134
Zachary Turnerc5b41d62015-10-16 17:52:03 +0000135#define LLDBSwigPyInit init_lldb
136#endif
137
Adrian Prantl05097242018-04-30 16:49:04 +0000138// these are the Pythonic implementations of the required callbacks these are
139// scripting-language specific, which is why they belong here we still need to
140// use function pointers to them instead of relying on linkage-time resolution
141// because the SWIG stuff and this file get built at different times
Kate Stoneb9c1b512016-09-06 20:57:50 +0000142extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
143 const char *python_function_name, const char *session_dictionary_name,
144 const lldb::StackFrameSP &sb_frame,
145 const lldb::BreakpointLocationSP &sb_bp_loc);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000146
Kate Stoneb9c1b512016-09-06 20:57:50 +0000147extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
148 const char *python_function_name, const char *session_dictionary_name,
149 const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000150
Kate Stoneb9c1b512016-09-06 20:57:50 +0000151extern "C" bool LLDBSwigPythonCallTypeScript(
152 const char *python_function_name, void *session_dictionary,
153 const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
154 const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000155
156extern "C" void *
Kate Stoneb9c1b512016-09-06 20:57:50 +0000157LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
158 const char *session_dictionary_name,
159 const lldb::ValueObjectSP &valobj_sp);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000160
161extern "C" void *
Kate Stoneb9c1b512016-09-06 20:57:50 +0000162LLDBSwigPythonCreateCommandObject(const char *python_class_name,
163 const char *session_dictionary_name,
164 const lldb::DebuggerSP debugger_sp);
165
166extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
167 const char *python_class_name, const char *session_dictionary_name,
168 const lldb::ThreadPlanSP &thread_plan_sp);
169
170extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
171 const char *method_name,
172 Event *event_sp, bool &got_error);
Jonas Devlieghere77198bc2018-11-05 19:33:59 +0000173
Jim Ingham3815e702018-09-13 21:35:32 +0000174extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
175 const char *python_class_name,
176 const char *session_dictionary_name,
177 lldb_private::StructuredDataImpl *args,
178 lldb::BreakpointSP &bkpt_sp);
179
180extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver(
181 void *implementor,
182 const char *method_name,
183 lldb_private::SymbolContext *sym_ctx
184);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000185
186extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
187 uint32_t max);
188
189extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
190 uint32_t idx);
191
192extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
193 const char *child_name);
194
195extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000196
197extern lldb::ValueObjectSP
Kate Stoneb9c1b512016-09-06 20:57:50 +0000198LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
199
200extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000201
202extern "C" bool
Kate Stoneb9c1b512016-09-06 20:57:50 +0000203LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000204
205extern "C" void *
Kate Stoneb9c1b512016-09-06 20:57:50 +0000206LLDBSwigPython_GetValueSynthProviderInstance(void *implementor);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000207
208extern "C" bool
Kate Stoneb9c1b512016-09-06 20:57:50 +0000209LLDBSwigPythonCallCommand(const char *python_function_name,
210 const char *session_dictionary_name,
211 lldb::DebuggerSP &debugger, const char *args,
212 lldb_private::CommandReturnObject &cmd_retobj,
213 lldb::ExecutionContextRefSP exe_ctx_ref_sp);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000214
215extern "C" bool
Kate Stoneb9c1b512016-09-06 20:57:50 +0000216LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
217 const char *args,
218 lldb_private::CommandReturnObject &cmd_retobj,
219 lldb::ExecutionContextRefSP exe_ctx_ref_sp);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000220
221extern "C" bool
Kate Stoneb9c1b512016-09-06 20:57:50 +0000222LLDBSwigPythonCallModuleInit(const char *python_module_name,
223 const char *session_dictionary_name,
224 lldb::DebuggerSP &debugger);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000225
Kate Stoneb9c1b512016-09-06 20:57:50 +0000226extern "C" void *
227LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
228 const char *session_dictionary_name,
229 const lldb::ProcessSP &process_sp);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000230
Kuba Mracek41ae8e72018-10-31 04:00:22 +0000231extern "C" void *LLDBSWIGPython_CreateFrameRecognizer(
232 const char *python_class_name,
233 const char *session_dictionary_name);
234
235extern "C" void *LLDBSwigPython_GetRecognizedArguments(void *implementor,
236 const lldb::StackFrameSP& frame_sp);
237
Kate Stoneb9c1b512016-09-06 20:57:50 +0000238extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
239 const char *python_function_name, const char *session_dictionary_name,
240 lldb::ProcessSP &process, std::string &output);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000241
Kate Stoneb9c1b512016-09-06 20:57:50 +0000242extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
243 const char *python_function_name, const char *session_dictionary_name,
244 lldb::ThreadSP &thread, std::string &output);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000245
Kate Stoneb9c1b512016-09-06 20:57:50 +0000246extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
247 const char *python_function_name, const char *session_dictionary_name,
248 lldb::TargetSP &target, std::string &output);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000249
Kate Stoneb9c1b512016-09-06 20:57:50 +0000250extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
251 const char *python_function_name, const char *session_dictionary_name,
252 lldb::StackFrameSP &frame, std::string &output);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000253
Kate Stoneb9c1b512016-09-06 20:57:50 +0000254extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
255 const char *python_function_name, const char *session_dictionary_name,
256 lldb::ValueObjectSP &value, std::string &output);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000257
Kate Stoneb9c1b512016-09-06 20:57:50 +0000258extern "C" void *
259LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
260 const lldb::TargetSP &target_sp);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000261
262#endif
263
Kate Stoneb9c1b512016-09-06 20:57:50 +0000264SystemInitializerFull::SystemInitializerFull() {}
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000265
Kate Stoneb9c1b512016-09-06 20:57:50 +0000266SystemInitializerFull::~SystemInitializerFull() {}
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000267
Jonas Devlieghere15eacd72018-12-03 17:28:29 +0000268llvm::Error
269SystemInitializerFull::Initialize(const InitializerOptions &options) {
270 if (auto e = SystemInitializerCommon::Initialize(options))
271 return e;
Pavel Labathfa3fa5b2018-05-24 12:44:18 +0000272
Pavel Labath1f6b2472018-12-10 17:16:38 +0000273 breakpad::ObjectFileBreakpad::Initialize();
Pavel Labathfa3fa5b2018-05-24 12:44:18 +0000274 ObjectFileELF::Initialize();
275 ObjectFileMachO::Initialize();
276 ObjectFilePECOFF::Initialize();
277
Kate Stoneb9c1b512016-09-06 20:57:50 +0000278 ScriptInterpreterNone::Initialize();
Zachary Turner2c1f46d2015-07-30 20:28:07 +0000279
Pavel Labatha7760cb2016-03-16 08:48:56 +0000280#ifndef LLDB_DISABLE_PYTHON
Kate Stoneb9c1b512016-09-06 20:57:50 +0000281 OperatingSystemPython::Initialize();
Pavel Labatha7760cb2016-03-16 08:48:56 +0000282#endif
Pavel Labatha7760cb2016-03-16 08:48:56 +0000283
Zachary Turner2c1f46d2015-07-30 20:28:07 +0000284#if !defined(LLDB_DISABLE_PYTHON)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000285 InitializeSWIG();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000286
Adrian Prantl05097242018-04-30 16:49:04 +0000287 // ScriptInterpreterPython::Initialize() depends on things like HostInfo
288 // being initialized so it can compute the python directory etc, so we need
289 // to do this after SystemInitializerCommon::Initialize().
Kate Stoneb9c1b512016-09-06 20:57:50 +0000290 ScriptInterpreterPython::Initialize();
Zachary Turner2c1f46d2015-07-30 20:28:07 +0000291#endif
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000292
Kate Stoneb9c1b512016-09-06 20:57:50 +0000293 platform_freebsd::PlatformFreeBSD::Initialize();
294 platform_linux::PlatformLinux::Initialize();
295 platform_netbsd::PlatformNetBSD::Initialize();
Kamil Rytarowski12801f12017-03-26 15:34:57 +0000296 platform_openbsd::PlatformOpenBSD::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000297 PlatformWindows::Initialize();
298 PlatformKalimba::Initialize();
299 platform_android::PlatformAndroid::Initialize();
300 PlatformRemoteiOS::Initialize();
301 PlatformMacOSX::Initialize();
Pavel Labathf1763532016-06-29 13:58:27 +0000302#if defined(__APPLE__)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000303 PlatformiOSSimulator::Initialize();
304 PlatformDarwinKernel::Initialize();
Pavel Labathf1763532016-06-29 13:58:27 +0000305#endif
306
Kate Stoneb9c1b512016-09-06 20:57:50 +0000307 // Initialize LLVM and Clang
308 llvm::InitializeAllTargets();
309 llvm::InitializeAllAsmPrinters();
310 llvm::InitializeAllTargetMCs();
311 llvm::InitializeAllDisassemblers();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000312
Kate Stoneb9c1b512016-09-06 20:57:50 +0000313 ClangASTContext::Initialize();
Greg Clayton56939cb2015-09-17 22:23:34 +0000314
Kate Stoneb9c1b512016-09-06 20:57:50 +0000315 ABIMacOSX_i386::Initialize();
316 ABIMacOSX_arm::Initialize();
317 ABIMacOSX_arm64::Initialize();
318 ABISysV_arm::Initialize();
319 ABISysV_arm64::Initialize();
320 ABISysV_hexagon::Initialize();
321 ABISysV_i386::Initialize();
322 ABISysV_x86_64::Initialize();
323 ABISysV_ppc::Initialize();
324 ABISysV_ppc64::Initialize();
325 ABISysV_mips::Initialize();
326 ABISysV_mips64::Initialize();
327 ABISysV_s390x::Initialize();
Pavel Labath13e37d42017-10-25 21:05:31 +0000328
329 ArchitectureArm::Initialize();
Tatyana Krasnukha98fc5482018-12-13 14:28:25 +0000330 ArchitectureMips::Initialize();
Jim Ingham08581262018-03-12 21:17:04 +0000331 ArchitecturePPC64::Initialize();
Pavel Labath13e37d42017-10-25 21:05:31 +0000332
Kate Stoneb9c1b512016-09-06 20:57:50 +0000333 DisassemblerLLVMC::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000334
Kate Stoneb9c1b512016-09-06 20:57:50 +0000335 JITLoaderGDB::Initialize();
336 ProcessElfCore::Initialize();
Pavel Labath4c7763e2018-05-22 16:33:43 +0000337 ProcessMachCore::Initialize();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000338 minidump::ProcessMinidump::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000339 MemoryHistoryASan::Initialize();
340 AddressSanitizerRuntime::Initialize();
341 ThreadSanitizerRuntime::Initialize();
Kuba Mracekef45d8b2017-06-16 20:59:08 +0000342 UndefinedBehaviorSanitizerRuntime::Initialize();
343 MainThreadCheckerRuntime::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000344
Kate Stoneb9c1b512016-09-06 20:57:50 +0000345 SymbolVendorELF::Initialize();
Pavel Labath1cf23e12019-01-11 11:17:51 +0000346 breakpad::SymbolFileBreakpad::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000347 SymbolFileDWARF::Initialize();
348 SymbolFilePDB::Initialize();
349 SymbolFileSymtab::Initialize();
350 UnwindAssemblyInstEmulation::Initialize();
351 UnwindAssembly_x86::Initialize();
352 EmulateInstructionARM64::Initialize();
Pavel Labatha535a7a2018-02-27 18:42:46 +0000353 EmulateInstructionPPC64::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000354 SymbolFileDWARFDebugMap::Initialize();
355 ItaniumABILanguageRuntime::Initialize();
356 AppleObjCRuntimeV2::Initialize();
357 AppleObjCRuntimeV1::Initialize();
358 SystemRuntimeMacOSX::Initialize();
359 RenderScriptRuntime::Initialize();
Ed Maste81b4c5f2016-01-04 01:43:47 +0000360
Kate Stoneb9c1b512016-09-06 20:57:50 +0000361 CPlusPlusLanguage::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000362 ObjCLanguage::Initialize();
363 ObjCPlusPlusLanguage::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000364
Hafiz Abid Qadeerf6ee79c2016-12-15 15:00:41 +0000365#if defined(_WIN32)
Adrian McCarthy4ad5def2016-11-23 16:26:37 +0000366 ProcessWindows::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000367#endif
368#if defined(__FreeBSD__)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000369 ProcessFreeBSD::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000370#endif
371#if defined(__APPLE__)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000372 SymbolVendorMacOSX::Initialize();
373 ProcessKDP::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000374 PlatformAppleTVSimulator::Initialize();
375 PlatformAppleWatchSimulator::Initialize();
376 PlatformRemoteAppleTV::Initialize();
377 PlatformRemoteAppleWatch::Initialize();
Jason Molenda32762fd2018-10-11 00:28:35 +0000378 PlatformRemoteAppleBridge::Initialize();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000379 DynamicLoaderDarwinKernel::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000380#endif
Todd Fiala75930012016-08-19 04:21:48 +0000381
Adrian Prantl05097242018-04-30 16:49:04 +0000382 // This plugin is valid on any host that talks to a Darwin remote. It
383 // shouldn't be limited to __APPLE__.
Kate Stoneb9c1b512016-09-06 20:57:50 +0000384 StructuredDataDarwinLog::Initialize();
Todd Fiala75930012016-08-19 04:21:48 +0000385
Kate Stoneb9c1b512016-09-06 20:57:50 +0000386 //----------------------------------------------------------------------
387 // Platform agnostic plugins
388 //----------------------------------------------------------------------
389 platform_gdb_server::PlatformRemoteGDBServer::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000390
Kate Stoneb9c1b512016-09-06 20:57:50 +0000391 process_gdb_remote::ProcessGDBRemote::Initialize();
392 DynamicLoaderMacOSXDYLD::Initialize();
393 DynamicLoaderMacOS::Initialize();
394 DynamicLoaderPOSIXDYLD::Initialize();
395 DynamicLoaderStatic::Initialize();
396 DynamicLoaderWindowsDYLD::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000397
Kate Stoneb9c1b512016-09-06 20:57:50 +0000398 // Scan for any system or user LLDB plug-ins
399 PluginManager::Initialize();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000400
Adrian Prantl05097242018-04-30 16:49:04 +0000401 // The process settings need to know about installed plug-ins, so the
402 // Settings must be initialized
Kate Stoneb9c1b512016-09-06 20:57:50 +0000403 // AFTER PluginManager::Initialize is called.
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000404
Kate Stoneb9c1b512016-09-06 20:57:50 +0000405 Debugger::SettingsInitialize();
Jonas Devlieghere15eacd72018-12-03 17:28:29 +0000406
407 return llvm::Error::success();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000408}
409
Kate Stoneb9c1b512016-09-06 20:57:50 +0000410void SystemInitializerFull::InitializeSWIG() {
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000411#if !defined(LLDB_DISABLE_PYTHON)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000412 ScriptInterpreterPython::InitializeInterpreter(
413 LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction,
414 LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript,
415 LLDBSwigPythonCreateSyntheticProvider, LLDBSwigPythonCreateCommandObject,
416 LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex,
417 LLDBSwigPython_GetIndexOfChildWithName,
418 LLDBSWIGPython_CastPyObjectToSBValue,
419 LLDBSWIGPython_GetValueObjectSPFromSBValue,
420 LLDBSwigPython_UpdateSynthProviderInstance,
421 LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
422 LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand,
423 LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit,
Kuba Mracek41ae8e72018-10-31 04:00:22 +0000424 LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPython_CreateFrameRecognizer,
425 LLDBSwigPython_GetRecognizedArguments,
426 LLDBSWIGPythonRunScriptKeywordProcess,
Kate Stoneb9c1b512016-09-06 20:57:50 +0000427 LLDBSWIGPythonRunScriptKeywordThread,
428 LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame,
429 LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting,
Jim Ingham3815e702018-09-13 21:35:32 +0000430 LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan,
431 LLDBSwigPythonCreateScriptedBreakpointResolver, LLDBSwigPythonCallBreakpointResolver);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000432#endif
433}
434
Kate Stoneb9c1b512016-09-06 20:57:50 +0000435void SystemInitializerFull::Terminate() {
Pavel Labathf9d16472017-05-15 13:02:37 +0000436 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
437 Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000438
Kate Stoneb9c1b512016-09-06 20:57:50 +0000439 Debugger::SettingsTerminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000440
Kate Stoneb9c1b512016-09-06 20:57:50 +0000441 // Terminate and unload and loaded system or user LLDB plug-ins
442 PluginManager::Terminate();
Greg Clayton56939cb2015-09-17 22:23:34 +0000443
Kate Stoneb9c1b512016-09-06 20:57:50 +0000444 ClangASTContext::Terminate();
Greg Clayton56939cb2015-09-17 22:23:34 +0000445
Tatyana Krasnukha98fc5482018-12-13 14:28:25 +0000446 ArchitectureArm::Terminate();
447 ArchitectureMips::Terminate();
448 ArchitecturePPC64::Terminate();
449
Kate Stoneb9c1b512016-09-06 20:57:50 +0000450 ABIMacOSX_i386::Terminate();
451 ABIMacOSX_arm::Terminate();
452 ABIMacOSX_arm64::Terminate();
453 ABISysV_arm::Terminate();
454 ABISysV_arm64::Terminate();
455 ABISysV_hexagon::Terminate();
456 ABISysV_i386::Terminate();
457 ABISysV_x86_64::Terminate();
458 ABISysV_ppc::Terminate();
459 ABISysV_ppc64::Terminate();
460 ABISysV_mips::Terminate();
461 ABISysV_mips64::Terminate();
462 ABISysV_s390x::Terminate();
463 DisassemblerLLVMC::Terminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000464
Kate Stoneb9c1b512016-09-06 20:57:50 +0000465 JITLoaderGDB::Terminate();
466 ProcessElfCore::Terminate();
Pavel Labath4c7763e2018-05-22 16:33:43 +0000467 ProcessMachCore::Terminate();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000468 minidump::ProcessMinidump::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000469 MemoryHistoryASan::Terminate();
470 AddressSanitizerRuntime::Terminate();
471 ThreadSanitizerRuntime::Terminate();
Kuba Mracekef45d8b2017-06-16 20:59:08 +0000472 UndefinedBehaviorSanitizerRuntime::Terminate();
473 MainThreadCheckerRuntime::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000474 SymbolVendorELF::Terminate();
Pavel Labath1cf23e12019-01-11 11:17:51 +0000475 breakpad::SymbolFileBreakpad::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000476 SymbolFileDWARF::Terminate();
477 SymbolFilePDB::Terminate();
478 SymbolFileSymtab::Terminate();
479 UnwindAssembly_x86::Terminate();
480 UnwindAssemblyInstEmulation::Terminate();
481 EmulateInstructionARM64::Terminate();
Pavel Labatha535a7a2018-02-27 18:42:46 +0000482 EmulateInstructionPPC64::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000483 SymbolFileDWARFDebugMap::Terminate();
484 ItaniumABILanguageRuntime::Terminate();
485 AppleObjCRuntimeV2::Terminate();
486 AppleObjCRuntimeV1::Terminate();
487 SystemRuntimeMacOSX::Terminate();
488 RenderScriptRuntime::Terminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000489
Kate Stoneb9c1b512016-09-06 20:57:50 +0000490 CPlusPlusLanguage::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000491 ObjCLanguage::Terminate();
492 ObjCPlusPlusLanguage::Terminate();
Ed Maste81b4c5f2016-01-04 01:43:47 +0000493
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000494#if defined(__APPLE__)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000495 DynamicLoaderDarwinKernel::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000496 ProcessKDP::Terminate();
497 SymbolVendorMacOSX::Terminate();
498 PlatformAppleTVSimulator::Terminate();
499 PlatformAppleWatchSimulator::Terminate();
500 PlatformRemoteAppleTV::Terminate();
501 PlatformRemoteAppleWatch::Terminate();
Jason Molenda32762fd2018-10-11 00:28:35 +0000502 PlatformRemoteAppleBridge::Terminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000503#endif
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000504
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000505#if defined(__FreeBSD__)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000506 ProcessFreeBSD::Terminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000507#endif
Kate Stoneb9c1b512016-09-06 20:57:50 +0000508 Debugger::SettingsTerminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000509
Kate Stoneb9c1b512016-09-06 20:57:50 +0000510 platform_gdb_server::PlatformRemoteGDBServer::Terminate();
511 process_gdb_remote::ProcessGDBRemote::Terminate();
512 StructuredDataDarwinLog::Terminate();
Todd Fiala75930012016-08-19 04:21:48 +0000513
Kate Stoneb9c1b512016-09-06 20:57:50 +0000514 DynamicLoaderMacOSXDYLD::Terminate();
515 DynamicLoaderMacOS::Terminate();
516 DynamicLoaderPOSIXDYLD::Terminate();
517 DynamicLoaderStatic::Terminate();
518 DynamicLoaderWindowsDYLD::Terminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000519
Pavel Labatha7760cb2016-03-16 08:48:56 +0000520#ifndef LLDB_DISABLE_PYTHON
Kate Stoneb9c1b512016-09-06 20:57:50 +0000521 OperatingSystemPython::Terminate();
Pavel Labatha7760cb2016-03-16 08:48:56 +0000522#endif
Pavel Labatha7760cb2016-03-16 08:48:56 +0000523
Kate Stoneb9c1b512016-09-06 20:57:50 +0000524 platform_freebsd::PlatformFreeBSD::Terminate();
525 platform_linux::PlatformLinux::Terminate();
526 platform_netbsd::PlatformNetBSD::Terminate();
Kamil Rytarowski12801f12017-03-26 15:34:57 +0000527 platform_openbsd::PlatformOpenBSD::Terminate();
Kate Stoneb9c1b512016-09-06 20:57:50 +0000528 PlatformWindows::Terminate();
529 PlatformKalimba::Terminate();
530 platform_android::PlatformAndroid::Terminate();
531 PlatformMacOSX::Terminate();
532 PlatformRemoteiOS::Terminate();
Pavel Labathf1763532016-06-29 13:58:27 +0000533#if defined(__APPLE__)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000534 PlatformiOSSimulator::Terminate();
535 PlatformDarwinKernel::Terminate();
Pavel Labathf1763532016-06-29 13:58:27 +0000536#endif
537
Pavel Labath1f6b2472018-12-10 17:16:38 +0000538 breakpad::ObjectFileBreakpad::Terminate();
Pavel Labathfa3fa5b2018-05-24 12:44:18 +0000539 ObjectFileELF::Terminate();
540 ObjectFileMachO::Terminate();
541 ObjectFilePECOFF::Terminate();
542
Kate Stoneb9c1b512016-09-06 20:57:50 +0000543 // Now shutdown the common parts, in reverse order.
544 SystemInitializerCommon::Terminate();
Zachary Turnere6e2bb32015-03-31 21:03:22 +0000545}