| 1 | //===-- SystemInitializerTest.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 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "SystemInitializerTest.h" |
| 10 | #include "lldb/Core/Debugger.h" |
| 11 | #include "lldb/Core/PluginManager.h" |
| 12 | #include "lldb/Host/Host.h" |
| 13 | #include "lldb/Initialization/SystemInitializerCommon.h" |
| 14 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 15 | #include "lldb/Utility/Timer.h" |
| 16 | #include "llvm/Support/TargetSelect.h" |
| 17 | |
| 18 | #include <string> |
| 19 | |
| 20 | #define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p) |
| 21 | #include "Plugins/Plugins.def" |
| 22 | |
| 23 | using namespace lldb_private; |
| 24 | |
| 25 | SystemInitializerTest::SystemInitializerTest() |
| 26 | : SystemInitializerCommon(nullptr) {} |
| 27 | SystemInitializerTest::~SystemInitializerTest() = default; |
| 28 | |
| 29 | llvm::Error SystemInitializerTest::Initialize() { |
| 30 | if (auto e = SystemInitializerCommon::Initialize()) |
| 31 | return e; |
| 32 | |
| 33 | // Initialize LLVM and Clang |
| 34 | llvm::InitializeAllTargets(); |
| 35 | llvm::InitializeAllAsmPrinters(); |
| 36 | llvm::InitializeAllTargetMCs(); |
| 37 | llvm::InitializeAllDisassemblers(); |
| 38 | |
| 39 | #define LLDB_SCRIPT_PLUGIN(p) |
| 40 | #define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p); |
| 41 | #include "Plugins/Plugins.def" |
| 42 | |
| 43 | // We ignored all the script interpreter earlier, so initialize |
| 44 | // ScriptInterpreterNone explicitly. |
| 45 | LLDB_PLUGIN_INITIALIZE(ScriptInterpreterNone); |
| 46 | |
| 47 | // Scan for any system or user LLDB plug-ins |
| 48 | PluginManager::Initialize(); |
| 49 | |
| 50 | // The process settings need to know about installed plug-ins, so the |
| 51 | // Settings must be initialized AFTER PluginManager::Initialize is called. |
| 52 | Debugger::SettingsInitialize(); |
| 53 | |
| 54 | Debugger::Initialize(load_plugin_callback: nullptr); |
| 55 | |
| 56 | return llvm::Error::success(); |
| 57 | } |
| 58 | |
| 59 | void SystemInitializerTest::Terminate() { |
| 60 | Debugger::Terminate(); |
| 61 | |
| 62 | Debugger::SettingsTerminate(); |
| 63 | |
| 64 | // Terminate and unload and loaded system or user LLDB plug-ins |
| 65 | PluginManager::Terminate(); |
| 66 | |
| 67 | #define LLDB_SCRIPT_PLUGIN(p) |
| 68 | #define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p); |
| 69 | #include "Plugins/Plugins.def" |
| 70 | |
| 71 | // We ignored all the script interpreter earlier, so terminate |
| 72 | // ScriptInterpreterNone explicitly. |
| 73 | LLDB_PLUGIN_INITIALIZE(ScriptInterpreterNone); |
| 74 | |
| 75 | // Now shutdown the common parts, in reverse order. |
| 76 | SystemInitializerCommon::Terminate(); |
| 77 | } |
| 78 |
