LLDB  mainline
SystemInitializerFull.cpp
Go to the documentation of this file.
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 
11 #include "lldb/Core/Debugger.h"
13 #include "lldb/Host/Config.h"
14 #include "lldb/Host/Host.h"
19 #include "lldb/Utility/Timer.h"
20 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Support/TargetSelect.h"
22 
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wglobal-constructors"
25 #include "llvm/ExecutionEngine/MCJIT.h"
26 #pragma clang diagnostic pop
27 
28 #include <string>
29 
30 #define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
31 #include "Plugins/Plugins.def"
32 
33 #if LLDB_ENABLE_PYTHON
35 
36 constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper
38  lldb_private::ScriptInterpreterPython::SharedLibraryDirectoryHelper;
39 
40 #else
41 constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper
43 #endif
44 
45 using namespace lldb_private;
46 
50 
53  if (error) {
54  // During active replay, the ::Initialize call is replayed like any other
55  // SB API call and the return value is ignored. Since we can't intercept
56  // this, we terminate here before the uninitialized debugger inevitably
57  // crashes.
58  if (repro::Reproducer::Instance().IsReplaying())
59  llvm::report_fatal_error(std::move(error));
60  return error;
61  }
62 
63  // Initialize LLVM and Clang
64  llvm::InitializeAllTargets();
65  llvm::InitializeAllAsmPrinters();
66  llvm::InitializeAllTargetMCs();
67  llvm::InitializeAllDisassemblers();
68  // Initialize the command line parser in LLVM. This usually isn't necessary
69  // as we aren't dealing with command line options here, but otherwise some
70  // other code in Clang/LLVM might be tempted to call this function from a
71  // different thread later on which won't work (as the function isn't
72  // thread-safe).
73  const char *arg0 = "lldb";
74  llvm::cl::ParseCommandLineOptions(1, &arg0);
75 
76 #define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p);
77 #include "Plugins/Plugins.def"
78 
79  // Initialize plug-ins in core LLDB
81 
82  // Scan for any system or user LLDB plug-ins
84 
85  // The process settings need to know about installed plug-ins, so the
86  // Settings must be initialized AFTER PluginManager::Initialize is called.
88 
89  return llvm::Error::success();
90 }
91 
94 
95  // Terminate plug-ins in core LLDB
97 
98  // Terminate and unload and loaded system or user LLDB plug-ins
100 
101 #define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p);
102 #include "Plugins/Plugins.def"
103 
104  // Now shutdown the common parts, in reverse order.
106 }
lldb_private::Debugger::SettingsTerminate
static void SettingsTerminate()
Definition: Debugger.cpp:503
lldb_private::ProcessTrace::Initialize
static void Initialize()
Definition: ProcessTrace.cpp:95
lldb_private::SystemInitializerFull::Initialize
llvm::Error Initialize() override
Definition: SystemInitializerFull.cpp:51
Host.h
lldb_private::ProcessTrace::Terminate
static void Terminate()
Definition: ProcessTrace.cpp:31
SystemInitializerCommon.h
Reproducer.h
Debugger.h
lldb_private::SystemInitializerCommon
Initializes common lldb functionality.
Definition: SystemInitializerCommon.h:24
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
SystemInitializerFull.h
lldb_private::SystemInitializerCommon::Initialize
llvm::Error Initialize() override
Definition: SystemInitializerCommon.cpp:95
lldb_private::Debugger::SettingsInitialize
static void SettingsInitialize()
Definition: Debugger.cpp:501
Timer.h
ScriptInterpreterPython.h
lldb_private::SystemInitializerFull::~SystemInitializerFull
~SystemInitializerFull() override
ProcessTrace.h
lldb_private::SystemInitializerFull::Terminate
void Terminate() override
Definition: SystemInitializerFull.cpp:92
PluginManager.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
CommandInterpreter.h
SBCommandInterpreter.h
g_shlib_dir_helper
constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper * g_shlib_dir_helper
Definition: SystemInitializerFull.cpp:42
lldb_private::SystemInitializerCommon::Terminate
void Terminate() override
Definition: SystemInitializerCommon.cpp:149
lldb_private::repro::Reproducer::Instance
static Reproducer & Instance()
Definition: Reproducer.cpp:23
lldb_private::SystemInitializerFull::SystemInitializerFull
SystemInitializerFull()
Definition: SystemInitializerFull.cpp:47
lldb_private::PluginManager::Terminate
static void Terminate()
Definition: PluginManager.cpp:168
lldb_private::PluginManager::Initialize
static void Initialize()
Definition: PluginManager.cpp:144