1 //===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SystemInitializerFull.h"
12 #include "lldb/Core/Debugger.h"
13 #include "lldb/Core/Timer.h"
14 #include "lldb/Host/Host.h"
15 #include "lldb/Initialization/SystemInitializerCommon.h"
17 #include "Plugins/ABI/SysV-arm/ABISysV_arm.h"
18 #include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h"
19 #include "Plugins/ABI/SysV-i386/ABISysV_i386.h"
20 #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
21 #include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
22 #include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
23 #include "Plugins/ABI/SysV-mips/ABISysV_mips.h"
24 #include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h"
25 #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
26 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
27 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
28 #include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
29 #include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
30 #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
31 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
32 #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
33 #include "Plugins/Process/elf-core/ProcessElfCore.h"
34 #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
35 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
36 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
37 #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
38 #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
39 #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
40 #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
42 #if defined(__APPLE__)
43 #include "Plugins/Process/mach-core/ProcessMachCore.h"
44 #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
47 #if defined(__FreeBSD__)
48 #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
52 #include "lldb/Host/windows/windows.h"
53 #include "Plugins/Process/Windows/ProcessWindows.h"
56 #if !defined(LLDB_DISABLE_PYTHON)
57 #include "lldb/Interpreter/ScriptInterpreterPython.h"
60 #include "llvm/Support/TargetSelect.h"
64 using namespace lldb_private;
66 #ifndef LLDB_DISABLE_PYTHON
68 // Defined in the SWIG source file
72 // these are the Pythonic implementations of the required callbacks
73 // these are scripting-language specific, which is why they belong here
74 // we still need to use function pointers to them instead of relying
75 // on linkage-time resolution because the SWIG stuff and this file
76 // get built at different times
78 LLDBSwigPythonBreakpointCallbackFunction (const char *python_function_name,
79 const char *session_dictionary_name,
80 const lldb::StackFrameSP& sb_frame,
81 const lldb::BreakpointLocationSP& sb_bp_loc);
84 LLDBSwigPythonWatchpointCallbackFunction (const char *python_function_name,
85 const char *session_dictionary_name,
86 const lldb::StackFrameSP& sb_frame,
87 const lldb::WatchpointSP& sb_wp);
90 LLDBSwigPythonCallTypeScript (const char *python_function_name,
91 void *session_dictionary,
92 const lldb::ValueObjectSP& valobj_sp,
93 void** pyfunct_wrapper,
94 const lldb::TypeSummaryOptionsSP& options_sp,
98 LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name,
99 const char *session_dictionary_name,
100 const lldb::ValueObjectSP& valobj_sp);
103 LLDBSwigPythonCreateCommandObject (const char *python_class_name,
104 const char *session_dictionary_name,
105 const lldb::DebuggerSP debugger_sp);
108 LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name,
109 const char *session_dictionary_name,
110 const lldb::ThreadPlanSP& thread_plan_sp);
113 LLDBSWIGPythonCallThreadPlan (void *implementor,
114 const char *method_name,
119 LLDBSwigPython_CalculateNumChildren (void *implementor);
122 LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
125 LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name);
128 LLDBSWIGPython_CastPyObjectToSBValue (void* data);
130 extern lldb::ValueObjectSP
131 LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data);
134 LLDBSwigPython_UpdateSynthProviderInstance (void* implementor);
137 LLDBSwigPython_MightHaveChildrenSynthProviderInstance (void* implementor);
140 LLDBSwigPython_GetValueSynthProviderInstance (void* implementor);
143 LLDBSwigPythonCallCommand (const char *python_function_name,
144 const char *session_dictionary_name,
145 lldb::DebuggerSP& debugger,
147 lldb_private::CommandReturnObject &cmd_retobj,
148 lldb::ExecutionContextRefSP exe_ctx_ref_sp);
151 LLDBSwigPythonCallCommandObject (void *implementor,
152 lldb::DebuggerSP& debugger,
154 lldb_private::CommandReturnObject& cmd_retobj,
155 lldb::ExecutionContextRefSP exe_ctx_ref_sp);
158 LLDBSwigPythonCallModuleInit (const char *python_module_name,
159 const char *session_dictionary_name,
160 lldb::DebuggerSP& debugger);
163 LLDBSWIGPythonCreateOSPlugin (const char *python_class_name,
164 const char *session_dictionary_name,
165 const lldb::ProcessSP& process_sp);
168 LLDBSWIGPythonRunScriptKeywordProcess (const char* python_function_name,
169 const char* session_dictionary_name,
170 lldb::ProcessSP& process,
171 std::string& output);
174 LLDBSWIGPythonRunScriptKeywordThread (const char* python_function_name,
175 const char* session_dictionary_name,
176 lldb::ThreadSP& thread,
177 std::string& output);
180 LLDBSWIGPythonRunScriptKeywordTarget (const char* python_function_name,
181 const char* session_dictionary_name,
182 lldb::TargetSP& target,
183 std::string& output);
186 LLDBSWIGPythonRunScriptKeywordFrame (const char* python_function_name,
187 const char* session_dictionary_name,
188 lldb::StackFrameSP& frame,
189 std::string& output);
192 LLDBSWIGPythonRunScriptKeywordValue (const char* python_function_name,
193 const char* session_dictionary_name,
194 lldb::ValueObjectSP& value,
195 std::string& output);
198 LLDBSWIGPython_GetDynamicSetting (void* module,
200 const lldb::TargetSP& target_sp);
205 SystemInitializerFull::SystemInitializerFull()
209 SystemInitializerFull::~SystemInitializerFull()
214 SystemInitializerFull::Initialize()
218 SystemInitializerCommon::Initialize();
220 // Initialize LLVM and Clang
221 llvm::InitializeAllTargets();
222 llvm::InitializeAllAsmPrinters();
223 llvm::InitializeAllTargetMCs();
224 llvm::InitializeAllDisassemblers();
226 ABISysV_arm::Initialize();
227 ABISysV_arm64::Initialize();
228 ABISysV_i386::Initialize();
229 ABISysV_x86_64::Initialize();
230 ABISysV_ppc::Initialize();
231 ABISysV_ppc64::Initialize();
232 ABISysV_mips::Initialize();
233 ABISysV_mips64::Initialize();
234 DisassemblerLLVMC::Initialize();
236 JITLoaderGDB::Initialize();
237 ProcessElfCore::Initialize();
238 MemoryHistoryASan::Initialize();
239 AddressSanitizerRuntime::Initialize();
241 SymbolVendorELF::Initialize();
242 SymbolFileDWARF::Initialize();
243 SymbolFileSymtab::Initialize();
244 UnwindAssemblyInstEmulation::Initialize();
245 UnwindAssembly_x86::Initialize();
246 EmulateInstructionARM64::Initialize();
247 SymbolFileDWARFDebugMap::Initialize();
248 ItaniumABILanguageRuntime::Initialize();
250 #if defined(_MSC_VER)
251 ProcessWindows::Initialize();
253 #if defined(__FreeBSD__)
254 ProcessFreeBSD::Initialize();
256 #if defined(__APPLE__)
257 SymbolVendorMacOSX::Initialize();
258 ProcessKDP::Initialize();
259 ProcessMachCore::Initialize();
261 //----------------------------------------------------------------------
262 // Platform agnostic plugins
263 //----------------------------------------------------------------------
264 platform_gdb_server::PlatformRemoteGDBServer::Initialize();
266 process_gdb_remote::ProcessGDBRemote::Initialize();
267 DynamicLoaderStatic::Initialize();
269 // Scan for any system or user LLDB plug-ins
270 PluginManager::Initialize();
272 // The process settings need to know about installed plug-ins, so the Settings must be initialized
273 // AFTER PluginManager::Initialize is called.
275 Debugger::SettingsInitialize();
278 void SystemInitializerFull::InitializeSWIG()
280 #if !defined(LLDB_DISABLE_PYTHON)
281 ScriptInterpreterPython::InitializeInterpreter(
283 LLDBSwigPythonBreakpointCallbackFunction,
284 LLDBSwigPythonWatchpointCallbackFunction,
285 LLDBSwigPythonCallTypeScript,
286 LLDBSwigPythonCreateSyntheticProvider,
287 LLDBSwigPythonCreateCommandObject,
288 LLDBSwigPython_CalculateNumChildren,
289 LLDBSwigPython_GetChildAtIndex,
290 LLDBSwigPython_GetIndexOfChildWithName,
291 LLDBSWIGPython_CastPyObjectToSBValue,
292 LLDBSWIGPython_GetValueObjectSPFromSBValue,
293 LLDBSwigPython_UpdateSynthProviderInstance,
294 LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
295 LLDBSwigPython_GetValueSynthProviderInstance,
296 LLDBSwigPythonCallCommand,
297 LLDBSwigPythonCallCommandObject,
298 LLDBSwigPythonCallModuleInit,
299 LLDBSWIGPythonCreateOSPlugin,
300 LLDBSWIGPythonRunScriptKeywordProcess,
301 LLDBSWIGPythonRunScriptKeywordThread,
302 LLDBSWIGPythonRunScriptKeywordTarget,
303 LLDBSWIGPythonRunScriptKeywordFrame,
304 LLDBSWIGPythonRunScriptKeywordValue,
305 LLDBSWIGPython_GetDynamicSetting,
306 LLDBSwigPythonCreateScriptedThreadPlan,
307 LLDBSWIGPythonCallThreadPlan);
312 SystemInitializerFull::Terminate()
314 Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
316 Debugger::SettingsTerminate();
318 // Terminate and unload and loaded system or user LLDB plug-ins
319 PluginManager::Terminate();
320 ABISysV_arm::Terminate();
321 ABISysV_arm64::Terminate();
322 ABISysV_i386::Terminate();
323 ABISysV_x86_64::Terminate();
324 ABISysV_ppc::Terminate();
325 ABISysV_ppc64::Terminate();
326 ABISysV_mips::Terminate();
327 ABISysV_mips64::Terminate();
328 DisassemblerLLVMC::Terminate();
330 JITLoaderGDB::Terminate();
331 ProcessElfCore::Terminate();
332 MemoryHistoryASan::Terminate();
333 AddressSanitizerRuntime::Terminate();
334 SymbolVendorELF::Terminate();
335 SymbolFileDWARF::Terminate();
336 SymbolFileSymtab::Terminate();
337 UnwindAssembly_x86::Terminate();
338 UnwindAssemblyInstEmulation::Terminate();
339 EmulateInstructionARM64::Terminate();
340 SymbolFileDWARFDebugMap::Terminate();
341 ItaniumABILanguageRuntime::Terminate();
343 #if defined(__APPLE__)
344 ProcessMachCore::Terminate();
345 ProcessKDP::Terminate();
346 SymbolVendorMacOSX::Terminate();
349 #if defined(__FreeBSD__)
350 ProcessFreeBSD::Terminate();
352 Debugger::SettingsTerminate();
354 platform_gdb_server::PlatformRemoteGDBServer::Terminate();
355 process_gdb_remote::ProcessGDBRemote::Terminate();
356 DynamicLoaderStatic::Terminate();
358 // Now shutdown the common parts, in reverse order.
359 SystemInitializerCommon::Terminate();
362 void SystemInitializerFull::TerminateSWIG()