aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API/SystemInitializerFull.cpp
diff options
context:
space:
mode:
authorDmitry Vasilyev <dvassiliev@accesssoftek.com>2025-04-08 22:24:59 +0400
committerGitHub <noreply@github.com>2025-04-08 22:24:59 +0400
commit7e70d708a39470397a8df9aa5842d0875b471def (patch)
tree94d1fd9e461b402bda9191e5fc13f5214b8c0684 /lldb/source/API/SystemInitializerFull.cpp
parent3b84b1e1635cc6af9ff745d0542ebee151394c42 (diff)
downloadllvm-7e70d708a39470397a8df9aa5842d0875b471def.zip
llvm-7e70d708a39470397a8df9aa5842d0875b471def.tar.gz
llvm-7e70d708a39470397a8df9aa5842d0875b471def.tar.bz2
[LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (#134383)
It reduces the memory usage in lldb-server.
Diffstat (limited to 'lldb/source/API/SystemInitializerFull.cpp')
-rw-r--r--lldb/source/API/SystemInitializerFull.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index 9cc3779..4cf7dd1 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -8,6 +8,7 @@
#include "SystemInitializerFull.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBDebugger.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Progress.h"
@@ -86,10 +87,53 @@ llvm::Error SystemInitializerFull::Initialize() {
LLDB_LOG(GetLog(SystemLog::System), "{0}", GetVersion());
+ auto LoadPlugin = [](const lldb::DebuggerSP &debugger_sp,
+ const FileSpec &spec,
+ Status &error) -> llvm::sys::DynamicLibrary {
+ llvm::sys::DynamicLibrary dynlib =
+ llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str());
+ if (dynlib.isValid()) {
+ typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger debugger);
+
+ lldb::SBDebugger debugger_sb(debugger_sp);
+ // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger)
+ // function.
+ // TODO: mangle this differently for your system - on OSX, the first
+ // underscore needs to be removed and the second one stays
+ LLDBCommandPluginInit init_func =
+ (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol(
+ "_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
+ if (init_func) {
+ if (init_func(debugger_sb))
+ return dynlib;
+ else
+ error = Status::FromErrorString(
+ "plug-in refused to load "
+ "(lldb::PluginInitialize(lldb::SBDebugger) "
+ "returned false)");
+ } else {
+ error = Status::FromErrorString(
+ "plug-in is missing the required initialization: "
+ "lldb::PluginInitialize(lldb::SBDebugger)");
+ }
+ } else {
+ if (FileSystem::Instance().Exists(spec))
+ error = Status::FromErrorString(
+ "this file does not represent a loadable dylib");
+ else
+ error = Status::FromErrorString("no such file");
+ }
+ return llvm::sys::DynamicLibrary();
+ };
+
+ Debugger::Initialize(LoadPlugin);
+
return llvm::Error::success();
}
void SystemInitializerFull::Terminate() {
+ Debugger::Terminate();
+
Debugger::SettingsTerminate();
// Terminate plug-ins in core LLDB.