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
23using namespace lldb_private;
24
25SystemInitializerTest::SystemInitializerTest()
26 : SystemInitializerCommon(nullptr) {}
27SystemInitializerTest::~SystemInitializerTest() = default;
28
29llvm::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 return llvm::Error::success();
55}
56
57void SystemInitializerTest::Terminate() {
58 Debugger::SettingsTerminate();
59
60 // Terminate and unload and loaded system or user LLDB plug-ins
61 PluginManager::Terminate();
62
63#define LLDB_SCRIPT_PLUGIN(p)
64#define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p);
65#include "Plugins/Plugins.def"
66
67 // We ignored all the script interpreter earlier, so terminate
68 // ScriptInterpreterNone explicitly.
69 LLDB_PLUGIN_INITIALIZE(ScriptInterpreterNone);
70
71 // Now shutdown the common parts, in reverse order.
72 SystemInitializerCommon::Terminate();
73}
74

source code of lldb/tools/lldb-test/SystemInitializerTest.cpp