Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lldb/include/lldb/Initialization/SystemLifetimeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace lldb_private {
class SystemLifetimeManager {
public:
SystemLifetimeManager();
~SystemLifetimeManager();
virtual ~SystemLifetimeManager();

llvm::Error Initialize(std::unique_ptr<SystemInitializer> initializer,
LoadPluginCallbackType plugin_callback);
Expand All @@ -32,6 +32,9 @@ class SystemLifetimeManager {
std::unique_ptr<SystemInitializer> m_initializer;
bool m_initialized = false;

virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) {};
virtual void TerminateDebugger() {};

// Noncopyable.
SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = delete;
Expand Down
36 changes: 36 additions & 0 deletions lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===-- SystemLifetimeManagerDbg.h ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H

#include "SystemLifetimeManager.h"
#include "lldb/Core/Debugger.h"

namespace lldb_private {

class SystemLifetimeManagerDbg : public SystemLifetimeManager {
public:
SystemLifetimeManagerDbg() : SystemLifetimeManager() {};

private:
virtual void
InitializeDebugger(LoadPluginCallbackType plugin_callback) override {
Debugger::Initialize(plugin_callback);
};

virtual void TerminateDebugger() override { Debugger::Terminate(); };

// Noncopyable.
SystemLifetimeManagerDbg(const SystemLifetimeManagerDbg &other) = delete;
SystemLifetimeManagerDbg &
operator=(const SystemLifetimeManagerDbg &other) = delete;
};
} // namespace lldb_private

#endif
4 changes: 2 additions & 2 deletions lldb/source/API/SBDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "lldb/Host/Config.h"
#include "lldb/Host/StreamFile.h"
#include "lldb/Host/XML.h"
#include "lldb/Initialization/SystemLifetimeManager.h"
#include "lldb/Initialization/SystemLifetimeManagerDbg.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
Expand All @@ -66,7 +66,7 @@
using namespace lldb;
using namespace lldb_private;

static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
static llvm::ManagedStatic<SystemLifetimeManagerDbg> g_debugger_lifetime;

SBError SBInputReader::Initialize(
lldb::SBDebugger &sb_debugger,
Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Initialization/SystemLifetimeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "lldb/Initialization/SystemLifetimeManager.h"

#include "lldb/Core/Debugger.h"
#include "lldb/Initialization/SystemInitializer.h"

#include <utility>
Expand Down Expand Up @@ -36,7 +35,7 @@ llvm::Error SystemLifetimeManager::Initialize(
if (auto e = m_initializer->Initialize())
return e;

Debugger::Initialize(plugin_callback);
InitializeDebugger(plugin_callback);
}

return llvm::Error::success();
Expand All @@ -46,7 +45,7 @@ void SystemLifetimeManager::Terminate() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);

if (m_initialized) {
Debugger::Terminate();
TerminateDebugger();
m_initializer->Terminate();

m_initializer.reset();
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-test/lldb-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Initialization/SystemLifetimeManager.h"
#include "lldb/Initialization/SystemLifetimeManagerDbg.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Symbol/CompileUnit.h"
Expand Down Expand Up @@ -1245,7 +1245,7 @@ int main(int argc, const char *argv[]) {

cl::ParseCommandLineOptions(argc, argv, "LLDB Testing Utility\n");

SystemLifetimeManager DebuggerLifetime;
SystemLifetimeManagerDbg DebuggerLifetime;
if (auto e = DebuggerLifetime.Initialize(
std::make_unique<SystemInitializerTest>(), nullptr)) {
WithColor::error() << "initialization failed: " << toString(std::move(e))
Expand Down