LLDB mainline
SystemLifetimeManager.cpp
Go to the documentation of this file.
1//===-- SystemLifetimeManager.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
10
11#include "lldb/Core/Debugger.h"
13
14#include <utility>
15
16using namespace lldb_private;
17
19
21 assert(!m_initialized &&
22 "SystemLifetimeManager destroyed without calling Terminate!");
23}
24
26 std::unique_ptr<SystemInitializer> initializer,
27 LoadPluginCallbackType plugin_callback) {
28 std::lock_guard<std::recursive_mutex> guard(m_mutex);
29 if (!m_initialized) {
30 assert(!m_initializer && "Attempting to call "
31 "SystemLifetimeManager::Initialize() when it is "
32 "already initialized");
33 m_initialized = true;
34 m_initializer = std::move(initializer);
35
36 if (auto e = m_initializer->Initialize())
37 return e;
38
39 Debugger::Initialize(plugin_callback);
40 }
41
42 return llvm::Error::success();
43}
44
46 std::lock_guard<std::recursive_mutex> guard(m_mutex);
47
48 if (m_initialized) {
50 m_initializer->Terminate();
51
52 m_initializer.reset();
53 m_initialized = false;
54 }
55}
static void Terminate()
Definition: Debugger.cpp:616
static void Initialize(LoadPluginCallbackType load_plugin_callback)
Definition: Debugger.cpp:607
llvm::Error Initialize(std::unique_ptr< SystemInitializer > initializer, LoadPluginCallbackType plugin_callback)
std::unique_ptr< SystemInitializer > m_initializer
A class that represents a running process on the host machine.
llvm::sys::DynamicLibrary(* LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error)