[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SystemInitializerFull.cpp
blob28c3b3b46a4b1c280808fcfb36b777022340ae10
1 //===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "SystemInitializerFull.h"
10 #include "lldb/API/SBCommandInterpreter.h"
11 #include "lldb/Host/Config.h"
13 #if LLDB_ENABLE_PYTHON
14 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
15 #endif
17 #if LLDB_ENABLE_LUA
18 #include "Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h"
19 #endif
21 #include "lldb/Core/Debugger.h"
22 #include "lldb/Host/Host.h"
23 #include "lldb/Initialization/SystemInitializerCommon.h"
24 #include "lldb/Interpreter/CommandInterpreter.h"
25 #include "lldb/Symbol/ClangASTContext.h"
26 #include "lldb/Utility/Timer.h"
28 #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
29 #include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
30 #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
31 #include "Plugins/ABI/SysV-arc/ABISysV_arc.h"
32 #include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
33 #include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
34 #include "Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h"
35 #include "Plugins/ABI/SysV-i386/ABISysV_i386.h"
36 #include "Plugins/ABI/SysV-mips/ABISysV_mips.h"
37 #include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h"
38 #include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
39 #include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
40 #include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
41 #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
42 #include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h"
43 #include "Plugins/Architecture/Arm/ArchitectureArm.h"
44 #include "Plugins/Architecture/Mips/ArchitectureMips.h"
45 #include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
46 #include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
47 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
48 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
49 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
50 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
51 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
52 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
53 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
54 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
55 #include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
56 #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
57 #include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
58 #include "Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h"
59 #include "Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h"
60 #include "Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h"
61 #include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
62 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
63 #include "Plugins/Language/ObjC/ObjCLanguage.h"
64 #include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
65 #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
66 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
67 #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
68 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
69 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
70 #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
71 #include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
72 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
73 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
74 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
75 #include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
76 #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
77 #include "Plugins/Platform/Android/PlatformAndroid.h"
78 #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
79 #include "Plugins/Platform/Linux/PlatformLinux.h"
80 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
81 #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
82 #include "Plugins/Platform/NetBSD/PlatformNetBSD.h"
83 #include "Plugins/Platform/OpenBSD/PlatformOpenBSD.h"
84 #include "Plugins/Platform/Windows/PlatformWindows.h"
85 #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
86 #include "Plugins/Process/elf-core/ProcessElfCore.h"
87 #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
88 #include "Plugins/Process/mach-core/ProcessMachCore.h"
89 #include "Plugins/Process/minidump/ProcessMinidump.h"
90 #include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
91 #include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h"
92 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
93 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
94 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
95 #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
96 #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
97 #include "Plugins/SymbolVendor/wasm/SymbolVendorWasm.h"
98 #include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
99 #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
100 #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
102 #if defined(__APPLE__)
103 #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
104 #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
105 #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
106 #endif
107 #include "Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h"
109 #if defined(__FreeBSD__)
110 #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
111 #endif
113 #if defined(_WIN32)
114 #include "Plugins/Process/Windows/Common/ProcessWindows.h"
115 #include "lldb/Host/windows/windows.h"
116 #endif
118 #include "llvm/Support/TargetSelect.h"
120 #pragma clang diagnostic push
121 #pragma clang diagnostic ignored "-Wglobal-constructors"
122 #include "llvm/ExecutionEngine/MCJIT.h"
123 #pragma clang diagnostic pop
125 #include <string>
127 using namespace lldb_private;
129 SystemInitializerFull::SystemInitializerFull() {}
131 SystemInitializerFull::~SystemInitializerFull() {}
133 #define LLDB_PROCESS_AArch64(op) \
134 ABIMacOSX_arm64::op(); \
135 ABISysV_arm64::op();
136 #define LLDB_PROCESS_ARM(op) \
137 ABIMacOSX_arm::op(); \
138 ABISysV_arm::op();
139 #define LLDB_PROCESS_ARC(op) \
140 ABISysV_arc::op();
141 #define LLDB_PROCESS_Hexagon(op) ABISysV_hexagon::op();
142 #define LLDB_PROCESS_Mips(op) \
143 ABISysV_mips::op(); \
144 ABISysV_mips64::op();
145 #define LLDB_PROCESS_PowerPC(op) \
146 ABISysV_ppc::op(); \
147 ABISysV_ppc64::op();
148 #define LLDB_PROCESS_SystemZ(op) ABISysV_s390x::op();
149 #define LLDB_PROCESS_X86(op) \
150 ABIMacOSX_i386::op(); \
151 ABISysV_i386::op(); \
152 ABISysV_x86_64::op(); \
153 ABIWindows_x86_64::op();
155 #define LLDB_PROCESS_AMDGPU(op)
156 #define LLDB_PROCESS_AVR(op)
157 #define LLDB_PROCESS_BPF(op)
158 #define LLDB_PROCESS_Lanai(op)
159 #define LLDB_PROCESS_MSP430(op)
160 #define LLDB_PROCESS_NVPTX(op)
161 #define LLDB_PROCESS_RISCV(op)
162 #define LLDB_PROCESS_Sparc(op)
163 #define LLDB_PROCESS_WebAssembly(op)
164 #define LLDB_PROCESS_XCore(op)
166 llvm::Error SystemInitializerFull::Initialize() {
167 if (auto e = SystemInitializerCommon::Initialize())
168 return e;
170 breakpad::ObjectFileBreakpad::Initialize();
171 ObjectFileELF::Initialize();
172 ObjectFileMachO::Initialize();
173 ObjectFilePECOFF::Initialize();
174 wasm::ObjectFileWasm::Initialize();
176 ObjectContainerBSDArchive::Initialize();
177 ObjectContainerUniversalMachO::Initialize();
179 ScriptInterpreterNone::Initialize();
181 #if LLDB_ENABLE_PYTHON
182 OperatingSystemPython::Initialize();
183 #endif
185 #if LLDB_ENABLE_PYTHON
186 ScriptInterpreterPython::Initialize();
187 #endif
189 #if LLDB_ENABLE_LUA
190 ScriptInterpreterLua::Initialize();
191 #endif
193 platform_freebsd::PlatformFreeBSD::Initialize();
194 platform_linux::PlatformLinux::Initialize();
195 platform_netbsd::PlatformNetBSD::Initialize();
196 platform_openbsd::PlatformOpenBSD::Initialize();
197 PlatformWindows::Initialize();
198 platform_android::PlatformAndroid::Initialize();
199 PlatformRemoteiOS::Initialize();
200 PlatformMacOSX::Initialize();
202 // Initialize LLVM and Clang
203 llvm::InitializeAllTargets();
204 llvm::InitializeAllAsmPrinters();
205 llvm::InitializeAllTargetMCs();
206 llvm::InitializeAllDisassemblers();
208 ClangASTContext::Initialize();
210 #define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize)
211 #include "llvm/Config/Targets.def"
213 ArchitectureArm::Initialize();
214 ArchitectureMips::Initialize();
215 ArchitecturePPC64::Initialize();
217 DisassemblerLLVMC::Initialize();
219 JITLoaderGDB::Initialize();
220 ProcessElfCore::Initialize();
221 ProcessMachCore::Initialize();
222 minidump::ProcessMinidump::Initialize();
223 MemoryHistoryASan::Initialize();
224 InstrumentationRuntimeASan::Initialize();
225 InstrumentationRuntimeTSan::Initialize();
226 InstrumentationRuntimeUBSan::Initialize();
227 InstrumentationRuntimeMainThreadChecker::Initialize();
229 SymbolVendorELF::Initialize();
230 breakpad::SymbolFileBreakpad::Initialize();
231 SymbolFileDWARF::Initialize();
232 SymbolFilePDB::Initialize();
233 SymbolFileSymtab::Initialize();
234 wasm::SymbolVendorWasm::Initialize();
235 UnwindAssemblyInstEmulation::Initialize();
236 UnwindAssembly_x86::Initialize();
238 EmulateInstructionARM::Initialize();
239 EmulateInstructionARM64::Initialize();
240 EmulateInstructionMIPS::Initialize();
241 EmulateInstructionMIPS64::Initialize();
242 EmulateInstructionPPC64::Initialize();
244 SymbolFileDWARFDebugMap::Initialize();
245 ItaniumABILanguageRuntime::Initialize();
246 AppleObjCRuntime::Initialize();
247 SystemRuntimeMacOSX::Initialize();
248 RenderScriptRuntime::Initialize();
250 CPlusPlusLanguage::Initialize();
251 ObjCLanguage::Initialize();
252 ObjCPlusPlusLanguage::Initialize();
254 #if defined(_WIN32)
255 ProcessWindows::Initialize();
256 #endif
257 #if defined(__FreeBSD__)
258 ProcessFreeBSD::Initialize();
259 #endif
260 #if defined(__APPLE__)
261 SymbolVendorMacOSX::Initialize();
262 ProcessKDP::Initialize();
263 DynamicLoaderDarwinKernel::Initialize();
264 #endif
266 // This plugin is valid on any host that talks to a Darwin remote. It
267 // shouldn't be limited to __APPLE__.
268 StructuredDataDarwinLog::Initialize();
270 // Platform agnostic plugins
271 platform_gdb_server::PlatformRemoteGDBServer::Initialize();
273 process_gdb_remote::ProcessGDBRemote::Initialize();
274 DynamicLoaderMacOSXDYLD::Initialize();
275 DynamicLoaderMacOS::Initialize();
276 DynamicLoaderPOSIXDYLD::Initialize();
277 DynamicLoaderStatic::Initialize();
278 DynamicLoaderWindowsDYLD::Initialize();
280 // Scan for any system or user LLDB plug-ins
281 PluginManager::Initialize();
283 // The process settings need to know about installed plug-ins, so the
284 // Settings must be initialized
285 // AFTER PluginManager::Initialize is called.
287 Debugger::SettingsInitialize();
289 return llvm::Error::success();
292 void SystemInitializerFull::Terminate() {
293 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
294 Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
296 Debugger::SettingsTerminate();
298 // Terminate and unload and loaded system or user LLDB plug-ins
299 PluginManager::Terminate();
301 ClangASTContext::Terminate();
303 ArchitectureArm::Terminate();
304 ArchitectureMips::Terminate();
305 ArchitecturePPC64::Terminate();
307 #define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Terminate)
308 #include "llvm/Config/Targets.def"
310 DisassemblerLLVMC::Terminate();
312 JITLoaderGDB::Terminate();
313 ProcessElfCore::Terminate();
314 ProcessMachCore::Terminate();
315 minidump::ProcessMinidump::Terminate();
316 MemoryHistoryASan::Terminate();
317 InstrumentationRuntimeASan::Terminate();
318 InstrumentationRuntimeTSan::Terminate();
319 InstrumentationRuntimeUBSan::Terminate();
320 InstrumentationRuntimeMainThreadChecker::Terminate();
322 wasm::SymbolVendorWasm::Terminate();
323 SymbolVendorELF::Terminate();
324 breakpad::SymbolFileBreakpad::Terminate();
325 SymbolFileDWARF::Terminate();
326 SymbolFilePDB::Terminate();
327 SymbolFileSymtab::Terminate();
328 UnwindAssembly_x86::Terminate();
329 UnwindAssemblyInstEmulation::Terminate();
331 EmulateInstructionARM::Terminate();
332 EmulateInstructionARM64::Terminate();
333 EmulateInstructionMIPS::Terminate();
334 EmulateInstructionMIPS64::Terminate();
335 EmulateInstructionPPC64::Terminate();
337 SymbolFileDWARFDebugMap::Terminate();
338 ItaniumABILanguageRuntime::Terminate();
339 AppleObjCRuntime::Terminate();
340 SystemRuntimeMacOSX::Terminate();
341 RenderScriptRuntime::Terminate();
343 CPlusPlusLanguage::Terminate();
344 ObjCLanguage::Terminate();
345 ObjCPlusPlusLanguage::Terminate();
347 #if defined(__APPLE__)
348 DynamicLoaderDarwinKernel::Terminate();
349 ProcessKDP::Terminate();
350 SymbolVendorMacOSX::Terminate();
351 #endif
353 #if defined(__FreeBSD__)
354 ProcessFreeBSD::Terminate();
355 #endif
356 Debugger::SettingsTerminate();
358 platform_gdb_server::PlatformRemoteGDBServer::Terminate();
359 process_gdb_remote::ProcessGDBRemote::Terminate();
360 StructuredDataDarwinLog::Terminate();
362 DynamicLoaderMacOSXDYLD::Terminate();
363 DynamicLoaderMacOS::Terminate();
364 DynamicLoaderPOSIXDYLD::Terminate();
365 DynamicLoaderStatic::Terminate();
366 DynamicLoaderWindowsDYLD::Terminate();
368 platform_freebsd::PlatformFreeBSD::Terminate();
369 platform_linux::PlatformLinux::Terminate();
370 platform_netbsd::PlatformNetBSD::Terminate();
371 platform_openbsd::PlatformOpenBSD::Terminate();
372 PlatformWindows::Terminate();
373 platform_android::PlatformAndroid::Terminate();
374 PlatformMacOSX::Terminate();
375 PlatformRemoteiOS::Terminate();
377 breakpad::ObjectFileBreakpad::Terminate();
378 ObjectFileELF::Terminate();
379 ObjectFileMachO::Terminate();
380 ObjectFilePECOFF::Terminate();
381 wasm::ObjectFileWasm::Terminate();
383 ObjectContainerBSDArchive::Terminate();
384 ObjectContainerUniversalMachO::Terminate();
386 #if LLDB_ENABLE_PYTHON
387 OperatingSystemPython::Terminate();
388 #endif
390 #if LLDB_ENABLE_PYTHON
391 ScriptInterpreterPython::Terminate();
392 #endif
394 #if LLDB_ENABLE_LUA
395 ScriptInterpreterLua::Terminate();
396 #endif
398 // Now shutdown the common parts, in reverse order.
399 SystemInitializerCommon::Terminate();