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/Reproducer.h"
19 #include "lldb/Utility/Timer.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 using namespace lldb_private;
34 SystemInitializerFull::SystemInitializerFull() = default;
35 SystemInitializerFull::~SystemInitializerFull() = default;
37 llvm::Error SystemInitializerFull::Initialize() {
38 llvm::Error error = SystemInitializerCommon::Initialize();
40 // During active replay, the ::Initialize call is replayed like any other
41 // SB API call and the return value is ignored. Since we can't intercept
42 // this, we terminate here before the uninitialized debugger inevitably
44 if (repro::Reproducer::Instance().IsReplaying())
45 llvm::report_fatal_error(std::move(error));
49 // Initialize LLVM and Clang
50 llvm::InitializeAllTargets();
51 llvm::InitializeAllAsmPrinters();
52 llvm::InitializeAllTargetMCs();
53 llvm::InitializeAllDisassemblers();
55 #define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p);
56 #include "Plugins/Plugins.def"
58 // Initialize plug-ins in core LLDB
59 ProcessTrace::Initialize();
61 // Scan for any system or user LLDB plug-ins
62 PluginManager::Initialize();
64 // The process settings need to know about installed plug-ins, so the
65 // Settings must be initialized AFTER PluginManager::Initialize is called.
66 Debugger::SettingsInitialize();
68 return llvm::Error::success();
71 void SystemInitializerFull::Terminate() {
72 Debugger::SettingsTerminate();
74 // Terminate plug-ins in core LLDB
75 ProcessTrace::Terminate();
77 // Terminate and unload and loaded system or user LLDB plug-ins
78 PluginManager::Terminate();
80 #define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p);
81 #include "Plugins/Plugins.def"
83 // Now shutdown the common parts, in reverse order.
84 SystemInitializerCommon::Terminate();