[Lldb-commits] [lldb] 404b756 - [lldb][Target] Move Debugger::GetSafeAutoLoadPaths into Target (#192703)
via lldb-commits
lldb-commits at lists.llvm.org
Sat Apr 18 22:54:50 PDT 2026
Author: Michael Buch
Date: 2026-04-19T06:54:45+01:00
New Revision: 404b75651f7220e9de1801fa987ccf92c1fc95bb
URL: https://github.com/llvm/llvm-project/commit/404b75651f7220e9de1801fa987ccf92c1fc95bb
DIFF: https://github.com/llvm/llvm-project/commit/404b75651f7220e9de1801fa987ccf92c1fc95bb.diff
LOG: [lldb][Target] Move Debugger::GetSafeAutoLoadPaths into Target (#192703)
Required for https://github.com/llvm/llvm-project/pull/191454
We want to make the `Target`/`Platform` define commonly used default
paths (without configuring them in CMake). This is easiest if this logic
lived in `Target` (since then we have access to the associated
`Platform`).
Added:
Modified:
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/Target/Target.h
lldb/source/Core/Debugger.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Target.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h
index 421f8b04bc13d..e53e916d78cc1 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -69,7 +69,6 @@ class Process;
class Stream;
class SymbolContext;
class Target;
-class Debugger;
#ifndef NDEBUG
/// Global properties used in the LLDB testsuite.
@@ -85,7 +84,7 @@ struct TestingProperties : public Properties {
void AppendSafeAutoLoadPaths(FileSpec path);
private:
- friend Debugger;
+ friend Target;
/// Callers should use Debugger::GetSafeAutoLoadPaths since it
/// accounts for default paths configured via CMake.
@@ -145,12 +144,6 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace,
llvm::StringRef prompt);
- /// Get the list of paths that LLDB will consider automatically loading
- /// scripting resources from. Currently whether to load scripts
- /// unconditionally is controlled via the
- /// `target.load-script-from-symbol-file` setting.
- static FileSpecList GetSafeAutoLoadPaths();
-
void Clear();
void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
@@ -659,6 +652,8 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
};
std::optional<ProgressReport> GetCurrentProgressReport() const;
+ static const FileSpecList &GetDefaultSafeAutoLoadPaths();
+
protected:
friend class CommandInterpreter;
friend class REPL;
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 67f373aa5a325..f8ca5197a385a 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1721,6 +1721,12 @@ class Target : public std::enable_shared_from_this<Target>,
void SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info);
+ /// Get the list of paths that LLDB will consider automatically loading
+ /// scripting resources from. Currently whether to load scripts
+ /// unconditionally is controlled via the
+ /// `target.load-script-from-symbol-file` setting.
+ FileSpecList GetSafeAutoLoadPaths() const;
+
/// Add a signal for the target. This will get copied over to the process
/// if the signal exists on that target. Only the values with Yes and No are
/// set, Calculate values will be ignored.
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 1701f063fc061..48e03881fa3b5 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -213,7 +213,7 @@ enum {
};
#endif
-static const FileSpecList &GetDefaultSafeAutoLoadPaths() {
+const FileSpecList &Debugger::GetDefaultSafeAutoLoadPaths() {
static const FileSpecList sSafePaths = [] {
// FIXME: in c++20 this could be a std::array (with CTAD deduced size)
// and we could statically assert that all members are non-empty.
@@ -2618,15 +2618,3 @@ StructuredData::DictionarySP Debugger::GetBuildConfiguration() {
AddLLVMTargets(*config_up);
return config_up;
}
-
-FileSpecList Debugger::GetSafeAutoLoadPaths() {
- FileSpecList fspecs = GetDefaultSafeAutoLoadPaths();
-
-#ifndef NDEBUG
- for (const auto &fspec :
- TestingProperties::GetGlobalTestingProperties().GetSafeAutoLoadPaths())
- fspecs.Append(fspec);
-#endif
-
- return fspecs;
-}
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index eaf461392d669..4786674c6ec36 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -190,7 +190,7 @@ Platform::LocateExecutableScriptingResourcesFromSafePaths(
->GetSanitizedScriptingModuleName(
module_spec.GetFileNameStrippingExtension().GetStringRef());
- FileSpecList paths = Debugger::GetSafeAutoLoadPaths();
+ FileSpecList paths = target.GetSafeAutoLoadPaths();
// Iterate in reverse so we consider the latest appended path first.
for (FileSpec path : llvm::reverse(paths)) {
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 75f19e9157992..721e000a0fd99 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -5432,6 +5432,18 @@ void Target::NotifyBreakpointChanged(
BroadcastEvent(Target::eBroadcastBitBreakpointChanged, breakpoint_data_sp);
}
+FileSpecList Target::GetSafeAutoLoadPaths() const {
+ FileSpecList fspecs = Debugger::GetDefaultSafeAutoLoadPaths();
+
+#ifndef NDEBUG
+ for (const auto &fspec :
+ TestingProperties::GetGlobalTestingProperties().GetSafeAutoLoadPaths())
+ fspecs.Append(fspec);
+#endif
+
+ return fspecs;
+}
+
// FIXME: the language plugin should expression options dynamically and
// we should validate here (by asking the language plugin) that the options
// being set/retrieved are actually valid options.
More information about the lldb-commits
mailing list