Coverage Report

Created: 2023-11-11 10:31

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/API/SystemInitializerFull.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- SystemInitializerFull.cpp -----------------------------------------===//
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 "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"
21
22
#pragma clang diagnostic push
23
#pragma clang diagnostic ignored "-Wglobal-constructors"
24
#include "llvm/ExecutionEngine/MCJIT.h"
25
#pragma clang diagnostic pop
26
27
#include <string>
28
29
#define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
30
#include "Plugins/Plugins.def"
31
32
#if LLDB_ENABLE_PYTHON
33
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
34
35
constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper
36
    *g_shlib_dir_helper =
37
        lldb_private::ScriptInterpreterPython::SharedLibraryDirectoryHelper;
38
39
#else
40
constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper
41
    *g_shlib_dir_helper = nullptr;
42
#endif
43
44
using namespace lldb_private;
45
46
SystemInitializerFull::SystemInitializerFull()
47
7.69k
    : SystemInitializerCommon(g_shlib_dir_helper) {}
48
7.68k
SystemInitializerFull::~SystemInitializerFull() = default;
49
50
3.84k
llvm::Error SystemInitializerFull::Initialize() {
51
3.84k
  llvm::Error error = SystemInitializerCommon::Initialize();
52
3.84k
  if (error)
53
0
    return error;
54
55
  // Initialize LLVM and Clang
56
3.84k
  llvm::InitializeAllTargets();
57
3.84k
  llvm::InitializeAllAsmPrinters();
58
3.84k
  llvm::InitializeAllTargetMCs();
59
3.84k
  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
64
  // thread-safe).
65
3.84k
  const char *arg0 = "lldb";
66
3.84k
  llvm::cl::ParseCommandLineOptions(1, &arg0);
67
68
334k
#define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p);
69
3.84k
#include "Plugins/Plugins.def"
70
71
  // Scan for any system or user LLDB plug-ins
72
3.84k
  PluginManager::Initialize();
73
74
  // The process settings need to know about installed plug-ins, so the
75
  // Settings must be initialized AFTER PluginManager::Initialize is called.
76
3.84k
  Debugger::SettingsInitialize();
77
78
  // Use the Debugger's LLDBAssert callback.
79
3.84k
  SetLLDBAssertCallback(Debugger::AssertCallback);
80
81
3.84k
  return llvm::Error::success();
82
3.84k
}
83
84
3.83k
void SystemInitializerFull::Terminate() {
85
3.83k
  Debugger::SettingsTerminate();
86
87
  // Terminate plug-ins in core LLDB
88
3.83k
  ProcessTrace::Terminate();
89
90
  // Terminate and unload and loaded system or user LLDB plug-ins
91
3.83k
  PluginManager::Terminate();
92
93
333k
#define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p);
94
3.83k
#include "Plugins/Plugins.def"
95
96
  // Now shutdown the common parts, in reverse order.
97
3.83k
  SystemInitializerCommon::Terminate();
98
3.83k
}