1 //===-- SystemInitializerFull.cpp -----------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "SystemInitializerFull.h"
10 #include "lldb/API/SBCommandInterpreter.h"
11 #include "lldb/Core/Debugger.h"
12 #include "lldb/Core/PluginManager.h"
13 #include "lldb/Host/Config.h"
14 #include "lldb/Host/Host.h"
15 #include "lldb/Initialization/SystemInitializerCommon.h"
16 #include "lldb/Interpreter/CommandInterpreter.h"
17 #include "lldb/Target/ProcessTrace.h"
18 #include "lldb/Utility/Timer.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Support/TargetSelect.h"
22 #pragma clang diagnostic push
23 #pragma clang diagnostic ignored "-Wglobal-constructors"
24 #include "llvm/ExecutionEngine/MCJIT.h"
25 #pragma clang diagnostic pop
29 #define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
30 #include "Plugins/Plugins.def"
32 #if LLDB_ENABLE_PYTHON
33 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
35 constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper
37 lldb_private::ScriptInterpreterPython::SharedLibraryDirectoryHelper
;
40 constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper
41 *g_shlib_dir_helper
= nullptr;
44 using namespace lldb_private
;
46 SystemInitializerFull::SystemInitializerFull()
47 : SystemInitializerCommon(g_shlib_dir_helper
) {}
48 SystemInitializerFull::~SystemInitializerFull() = default;
50 llvm::Error
SystemInitializerFull::Initialize() {
51 llvm::Error error
= SystemInitializerCommon::Initialize();
55 // Initialize LLVM and Clang
56 llvm::InitializeAllTargets();
57 llvm::InitializeAllAsmPrinters();
58 llvm::InitializeAllTargetMCs();
59 llvm::InitializeAllDisassemblers();
60 // Initialize the command line parser in LLVM. This usually isn't necessary
61 // as we aren't dealing with command line options here, but otherwise some
62 // other code in Clang/LLVM might be tempted to call this function from a
63 // different thread later on which won't work (as the function isn't
65 const char *arg0
= "lldb";
66 llvm::cl::ParseCommandLineOptions(1, &arg0
);
68 #define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p);
69 #include "Plugins/Plugins.def"
71 // Initialize plug-ins in core LLDB
72 ProcessTrace::Initialize();
74 // Scan for any system or user LLDB plug-ins
75 PluginManager::Initialize();
77 // The process settings need to know about installed plug-ins, so the
78 // Settings must be initialized AFTER PluginManager::Initialize is called.
79 Debugger::SettingsInitialize();
81 // Use the Debugger's LLDBAssert callback.
82 SetLLDBAssertCallback(Debugger::AssertCallback
);
84 return llvm::Error::success();
87 void SystemInitializerFull::Terminate() {
88 Debugger::SettingsTerminate();
90 // Terminate plug-ins in core LLDB
91 ProcessTrace::Terminate();
93 // Terminate and unload and loaded system or user LLDB plug-ins
94 PluginManager::Terminate();
96 #define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p);
97 #include "Plugins/Plugins.def"
99 // Now shutdown the common parts, in reverse order.
100 SystemInitializerCommon::Terminate();