[Lldb-commits] [lldb] [lldb] Add setting to specify (by name) which module's scripting resources can be auto-loaded (PR #188722)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 27 04:01:12 PDT 2026
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/188722
>From 722718b69480069d411eb150090d8e1f8a683503 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 26 Mar 2026 09:13:03 +0000
Subject: [PATCH 1/4] [lldb] Add setting to specify (by name) which module's
scripting resources can be auto-loaded
This is part of [this RFC](https://discourse.llvm.org/t/rfc-lldb-moving-libc-data-formatters-out-of-lldb/89591) which is about turning the libc++ data-formatters into auto-loadable Python scripts.
Eventually we want the Python data-formatters for `libc++` to be automatically loaded without requiring user opt-in (since that's how the builtin formatters have always worked and, in my opinion, we can't transition to an opt-in model if users have always had the data-formatters available). To do so we need a way to distinguish which modules we can *always* auto-load from safe-paths, and which require `target.load-script-from-symbol-file` to be set to `true`.
This patch adds a setting (`target.auto-load-modules`) that is a dictionary from module-name to a boolean indicating whether the scripts for that module can be automatically loaded.
Making this a setting also means a user can disable any auto-loading by clearing it. By default the setting is currently empty. Eventually we'll want it to contain `libc++.1=true` (and possibly other names which the `libc++` dylib can commonly have).
**AI Usage**:
* Used Claude to generate the unit-test cases and shell tests. Reviewed and cleaned them up myself.
---
lldb/include/lldb/Target/Platform.h | 20 +-
lldb/include/lldb/Target/Target.h | 4 +
lldb/source/Core/Module.cpp | 27 ++-
lldb/source/Target/Platform.cpp | 51 ++++-
lldb/source/Target/Target.cpp | 14 ++
lldb/source/Target/TargetProperties.td | 5 +
.../UNIX/auto-load-modules-false.test | 25 +++
.../UNIX/auto-load-modules-multiple.test | 38 ++++
.../UNIX/auto-load-modules-not-in-dict.test | 29 +++
.../AutoLoad/UNIX/auto-load-modules-true.test | 26 +++
lldb/unittests/Platform/PlatformTest.cpp | 190 ++++++++++++++++--
11 files changed, 392 insertions(+), 37 deletions(-)
create mode 100644 lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test
create mode 100644 lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test
create mode 100644 lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test
create mode 100644 lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 3d0776d95b539..7a20008634b28 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -275,9 +275,13 @@ class Platform : public PluginInterface {
///
/// Locating the file should happen only on the local computer or using the
/// current computers global settings.
- FileSpecList LocateExecutableScriptingResources(Target *target,
- Module &module,
- Stream &feedback_stream);
+ ///
+ /// Returns a pair of \c FileSpecList. The first element contains
+ /// scripts that are eligible to be auto-loaded. The second element
+ /// contains the non-auto loadable scripts.
+ std::pair<FileSpecList, FileSpecList>
+ LocateExecutableScriptingResources(Target *target, Module &module,
+ Stream &feedback_stream);
/// Locate the platform-specific scripting resource given a module
/// specification.
@@ -289,10 +293,16 @@ class Platform : public PluginInterface {
/// which gathers FileSpecs for executable scripts from
/// pre-configured "safe" auto-load paths.
///
+ /// Returns a pair of \c FileSpecList. The first element contains
+ /// scripts that are eligible to be auto-loaded. The second element
+ /// contains the non-auto loadable scripts.
+ ///
/// E.g., for Python it will look for a script at:
/// \c <safe-path>/<module-name>/<module-name>.py
- static FileSpecList LocateExecutableScriptingResourcesFromSafePaths(
- Stream &feedback_stream, FileSpec module_spec, const Target &target);
+ static std::pair<FileSpecList, FileSpecList>
+ LocateExecutableScriptingResourcesFromSafePaths(Stream &feedback_stream,
+ FileSpec module_spec,
+ const Target &target);
/// \param[in] module_spec
/// The ModuleSpec of a binary to find.
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 7907ed2f1a5f6..a9f602bb7873f 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -278,6 +278,10 @@ class TargetProperties : public Properties {
bool GetDebugUtilityExpression() const;
+ OptionValueDictionary *GetAutoLoadModules() const;
+
+ void SetAutoLoadModule(llvm::StringRef module_name, bool should_load);
+
private:
std::optional<bool>
GetExperimentalPropertyValue(size_t prop_idx,
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 3d33a5011fb5e..7f8192a5bff42 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1442,9 +1442,6 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error) {
LoadScriptFromSymFile should_load =
target->TargetProperties::GetLoadScriptFromSymbolFile();
- if (should_load == eLoadScriptFromSymFileFalse)
- return false;
-
Debugger &debugger = target->GetDebugger();
const ScriptLanguage script_language = debugger.GetScriptLanguage();
if (script_language == eScriptLanguageNone)
@@ -1464,18 +1461,28 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error) {
}
StreamString feedback_stream;
- FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources(
- target, *this, feedback_stream);
+ const auto [auto_load_files, non_auto_load_files] =
+ platform_sp->LocateExecutableScriptingResources(target, *this,
+ feedback_stream);
if (!feedback_stream.Empty())
debugger.ReportWarning(feedback_stream.GetString().str(), debugger.GetID());
- const uint32_t num_specs = file_specs.GetSize();
- if (num_specs == 0)
- return true;
+ for (uint32_t i = 0; i < auto_load_files.GetSize(); ++i) {
+ FileSpec scripting_fspec(auto_load_files.GetFileSpecAtIndex(i));
+ if (!FileSystem::Instance().Exists(scripting_fspec))
+ continue;
+
+ if (!LoadScriptingModule(scripting_fspec, *script_interpreter, *target,
+ error))
+ return false;
+ }
+
+ if (should_load == eLoadScriptFromSymFileFalse)
+ return !auto_load_files.IsEmpty();
- for (uint32_t i = 0; i < num_specs; ++i) {
- FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i));
+ for (uint32_t i = 0; i < non_auto_load_files.GetSize(); ++i) {
+ FileSpec scripting_fspec(non_auto_load_files.GetFileSpecAtIndex(i));
if (!FileSystem::Instance().Exists(scripting_fspec))
continue;
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 51ef8d7259d9a..db560769c1e34 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -24,6 +24,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
@@ -157,7 +158,37 @@ Status Platform::GetFileWithUUID(const FileSpec &platform_file,
return Status();
}
-FileSpecList Platform::LocateExecutableScriptingResourcesFromSafePaths(
+// FIXME: move this into lldb-private-enumerations.h?
+enum class OptionalBool {
+ eYes,
+ eNo,
+ eDontKnow,
+};
+
+/// Returns \c OptionalBool::eYes if scripting resources associated with the
+/// specified module \c FileSpec can be automatically loaded. If a module is
+/// explicitly disallowed from being auto-loaded, returns \c OptionalBool::eNo.
+/// In all other cases, returns \c OptionalBool::eDontKnow.
+static OptionalBool CanAutoLoadModule(const FileSpec &module_fspec,
+ const Target &target) {
+ OptionValueDictionary *names = target.GetAutoLoadModules();
+ if (!names)
+ return OptionalBool::eDontKnow;
+
+ OptionValueSP value_sp =
+ names->GetValueForKey(module_fspec.GetFileNameStrippingExtension());
+ if (!value_sp)
+ return OptionalBool::eDontKnow;
+
+ auto maybe_can_load = value_sp->GetValueAs<bool>();
+ if (!maybe_can_load)
+ return OptionalBool::eDontKnow;
+
+ return *maybe_can_load ? OptionalBool::eYes : OptionalBool::eNo;
+}
+
+std::pair<FileSpecList, FileSpecList>
+Platform::LocateExecutableScriptingResourcesFromSafePaths(
Stream &feedback_stream, FileSpec module_spec, const Target &target) {
assert(module_spec);
assert(target.GetDebugger().GetScriptInterpreter());
@@ -172,7 +203,8 @@ FileSpecList Platform::LocateExecutableScriptingResourcesFromSafePaths(
->GetSanitizedScriptingModuleName(
module_spec.GetFileNameStrippingExtension().GetStringRef());
- FileSpecList file_list;
+ FileSpecList non_auto_load_files;
+ FileSpecList auto_load_files;
FileSpecList paths = Debugger::GetSafeAutoLoadPaths();
// Iterate in reverse so we consider the latest appended path first.
@@ -196,15 +228,20 @@ FileSpecList Platform::LocateExecutableScriptingResourcesFromSafePaths(
WarnIfInvalidUnsanitizedScriptExists(feedback_stream, sanitized_name,
orig_script_fspec, script_fspec);
- if (FileSystem::Instance().Exists(script_fspec))
- file_list.Append(script_fspec);
+ if (FileSystem::Instance().Exists(script_fspec)) {
+ OptionalBool can_auto_load = CanAutoLoadModule(module_spec, target);
+ if (can_auto_load == OptionalBool::eYes)
+ auto_load_files.Append(script_fspec);
+ else if (can_auto_load == OptionalBool::eDontKnow)
+ non_auto_load_files.Append(script_fspec);
+ }
// If we successfully found a directory in a safe auto-load path
// stop looking at any other paths.
break;
}
- return file_list;
+ return {auto_load_files, non_auto_load_files};
}
FileSpecList Platform::LocateExecutableScriptingResourcesForPlatform(
@@ -212,7 +249,7 @@ FileSpecList Platform::LocateExecutableScriptingResourcesForPlatform(
return {};
}
-FileSpecList
+std::pair<FileSpecList, FileSpecList>
Platform::LocateExecutableScriptingResources(Target *target, Module &module,
Stream &feedback_stream) {
if (!target)
@@ -222,7 +259,7 @@ Platform::LocateExecutableScriptingResources(Target *target, Module &module,
if (FileSpecList fspecs = LocateExecutableScriptingResourcesForPlatform(
target, module, feedback_stream);
!fspecs.IsEmpty())
- return fspecs;
+ return {{}, fspecs};
const FileSpec &module_spec = module.GetFileSpec();
if (!module_spec)
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 126a2b57ed4b4..cd0fe4e3eea58 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -5266,6 +5266,20 @@ void TargetProperties::SetDebugUtilityExpression(bool debug) {
SetPropertyAtIndex(idx, debug);
}
+OptionValueDictionary *TargetProperties::GetAutoLoadModules() const {
+ return m_collection_sp->GetPropertyAtIndexAsOptionValueDictionary(
+ ePropertyAutoLoadModules);
+}
+
+void TargetProperties::SetAutoLoadModule(llvm::StringRef module_name,
+ bool should_load) {
+ OptionValueDictionary *dict = GetAutoLoadModules();
+ if (!dict)
+ return;
+ dict->SetValueForKey(module_name,
+ std::make_shared<OptionValueBoolean>(should_load));
+}
+
// Target::TargetEventData
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td
index 2361314d506ac..d8ef0df70e7f8 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -220,6 +220,11 @@ let Definition = "target", Path = "target" in {
def ParallelModuleLoad: Property<"parallel-module-load", "Boolean">,
DefaultTrue,
Desc<"Enable loading of modules in parallel for the dynamic loader.">;
+ def AutoLoadModules
+ : Property<"auto-load-modules", "Dictionary">,
+ ElementType<"Boolean">,
+ Desc<"A list of module names and whether LLDB will auto-load scripting "
+ "resources for it from safe paths.">;
}
let Definition = "process_experimental", Path = "target.process.experimental" in {
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test
new file mode 100644
index 0000000000000..2902df479979c
--- /dev/null
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test
@@ -0,0 +1,25 @@
+# REQUIRES: python, asserts, !system-windows
+
+# Test that when a module is listed in target.auto-load-modules with 'false',
+# its scripting resources are NOT loaded even when target.load-script-from-symbol-file
+# is true.
+
+# RUN: split-file %s %t
+# RUN: %clang_host %t/main.c -o %t/TestModule.out
+# RUN: mkdir -p %t/safe-path/TestModule
+
+# RUN: cp %t/script.py %t/safe-path/TestModule/TestModule.py
+# RUN: %lldb -b \
+# RUN: -o 'settings set target.load-script-from-symbol-file true' \
+# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
+# RUN: -o 'settings set target.auto-load-modules TestModule=false' \
+# RUN: -o 'target create %t/TestModule.out' 2>&1 \
+# RUN: | FileCheck %s --implicit-check-not=AUTOLOAD_SUCCESS --implicit-check-not=warning
+
+#--- main.c
+int main() { return 0; }
+
+#--- script.py
+import sys
+def __lldb_init_module(debugger, internal_dict):
+ print("AUTOLOAD_SUCCESS", file=sys.stderr)
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test
new file mode 100644
index 0000000000000..a9de987017641
--- /dev/null
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test
@@ -0,0 +1,38 @@
+# REQUIRES: python, asserts, !system-windows
+
+# Test that multiple modules listed in target.auto-load-modules are all
+# auto-loaded.
+
+# RUN: split-file %s %t
+# RUN: %clang_host -shared %t/lib.c -o %t/libFoo.dylib
+# RUN: %clang_host %t/main.c -o %t/TestModule.out %t/libFoo.dylib
+# RUN: mkdir -p %t/safe-path/TestModule
+# RUN: mkdir -p %t/safe-path/libFoo
+
+# RUN: cp %t/main_script.py %t/safe-path/TestModule/TestModule.py
+# RUN: cp %t/lib_script.py %t/safe-path/libFoo/libFoo.py
+# RUN: %lldb -b \
+# RUN: -o 'settings set target.load-script-from-symbol-file false' \
+# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
+# RUN: -o 'settings set target.auto-load-modules TestModule=true libFoo=true' \
+# RUN: -o 'target create %t/TestModule.out' 2>&1 | FileCheck %s
+
+# CHECK-DAG: MAIN_AUTOLOAD_SUCCESS
+# CHECK-DAG: LIB_AUTOLOAD_SUCCESS
+
+#--- main.c
+extern int foo(void);
+int main() { return foo(); }
+
+#--- lib.c
+int foo(void) { return 0; }
+
+#--- main_script.py
+import sys
+def __lldb_init_module(debugger, internal_dict):
+ print("MAIN_AUTOLOAD_SUCCESS", file=sys.stderr)
+
+#--- lib_script.py
+import sys
+def __lldb_init_module(debugger, internal_dict):
+ print("LIB_AUTOLOAD_SUCCESS", file=sys.stderr)
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test
new file mode 100644
index 0000000000000..cf9a80121c17a
--- /dev/null
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test
@@ -0,0 +1,29 @@
+# REQUIRES: python, asserts, !system-windows
+
+# Test that when a module is NOT in target.auto-load-modules, the existing
+# target.load-script-from-symbol-file setting controls whether scripts load.
+# With load-script-from-symbol-file=true and no dictionary entry, scripts
+# should still load normally.
+
+# RUN: split-file %s %t
+# RUN: %clang_host %t/main.c -o %t/TestModule.out
+# RUN: mkdir -p %t/safe-path/TestModule
+
+# RUN: cp %t/script.py %t/safe-path/TestModule/TestModule.py
+
+## A different module is in the dictionary; TestModule is not.
+# RUN: %lldb -b \
+# RUN: -o 'settings set target.load-script-from-symbol-file warn' \
+# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
+# RUN: -o 'settings set target.auto-load-modules SomeOtherModule=true' \
+# RUN: -o 'target create %t/TestModule.out' 2>&1 | FileCheck %s --implicit-check-not=AUTOLOAD_SUCCESS
+
+# CHECK: warning: 'TestModule' contains a debug script. To run this script in this debug session
+
+#--- main.c
+int main() { return 0; }
+
+#--- script.py
+import sys
+def __lldb_init_module(debugger, internal_dict):
+ print("AUTOLOAD_SUCCESS", file=sys.stderr)
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test
new file mode 100644
index 0000000000000..87b09248b22f6
--- /dev/null
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test
@@ -0,0 +1,26 @@
+# REQUIRES: python, asserts, !system-windows
+
+# Test that when a module is listed in target.auto-load-modules with 'true',
+# its scripting resources are loaded even when target.load-script-from-symbol-file
+# is false.
+
+# RUN: split-file %s %t
+# RUN: %clang_host %t/main.c -o %t/TestModule.out
+# RUN: mkdir -p %t/safe-path/TestModule
+
+# RUN: cp %t/script.py %t/safe-path/TestModule/TestModule.py
+# RUN: %lldb -b \
+# RUN: -o 'settings set target.load-script-from-symbol-file false' \
+# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
+# RUN: -o 'settings set target.auto-load-modules TestModule=true' \
+# RUN: -o 'target create %t/TestModule.out' 2>&1 | FileCheck %s
+
+# CHECK: AUTOLOAD_SUCCESS
+
+#--- main.c
+int main() { return 0; }
+
+#--- script.py
+import sys
+def __lldb_init_module(debugger, internal_dict):
+ print("AUTOLOAD_SUCCESS", file=sys.stderr)
diff --git a/lldb/unittests/Platform/PlatformTest.cpp b/lldb/unittests/Platform/PlatformTest.cpp
index 3f46353e1bcb8..a703c8ed09f15 100644
--- a/lldb/unittests/Platform/PlatformTest.cpp
+++ b/lldb/unittests/Platform/PlatformTest.cpp
@@ -225,10 +225,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
ASSERT_EQ(file_specs.GetSize(), 0u);
}
@@ -252,10 +253,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule1.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
ASSERT_EQ(file_specs.GetSize(), 0u);
}
@@ -281,10 +283,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("not_a_script.txt", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_EQ(file_specs.GetFileSpecAtIndex(0).GetFilename(), "TestModule.py");
}
@@ -313,10 +316,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", nested_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 0u);
}
@@ -373,10 +377,12 @@ TEST_F(PlatformLocateSafePathTest,
FileSpec(path2));
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
+
// path1 was the last appended path with a matching directory.
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_TRUE(llvm::StringRef(file_specs.GetFileSpecAtIndex(0).GetPath())
@@ -391,7 +397,8 @@ TEST_F(PlatformLocateSafePathTest,
FileSpec(path3));
file_specs = Platform::LocateExecutableScriptingResourcesFromSafePaths(
- ss, module_fspec, *m_target_sp);
+ ss, module_fspec, *m_target_sp)
+ .second;
EXPECT_EQ(file_specs.GetSize(), 0u);
@@ -399,7 +406,8 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", path3_module_dir);
file_specs = Platform::LocateExecutableScriptingResourcesFromSafePaths(
- ss, module_fspec, *m_target_sp);
+ ss, module_fspec, *m_target_sp)
+ .second;
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_TRUE(llvm::StringRef(file_specs.GetFileSpecAtIndex(0).GetPath())
@@ -428,10 +436,11 @@ TEST_F(PlatformLocateSafePathTest,
ASSERT_TRUE(orig_fspec);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 0u);
std::string expected = llvm::formatv(
@@ -465,10 +474,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule_1_1_1.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_EQ(file_specs.GetFileSpecAtIndex(0).GetFilename(),
"TestModule_1_1_1.py");
@@ -500,10 +510,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule_1_1_1.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_EQ(file_specs.GetFileSpecAtIndex(0).GetFilename(),
"TestModule_1_1_1.py");
@@ -530,10 +541,11 @@ TEST_F(PlatformLocateSafePathTest,
ASSERT_TRUE(orig_fspec);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 0u);
std::string expected = llvm::formatv(
@@ -566,10 +578,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("_import.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_EQ(file_specs.GetFileSpecAtIndex(0).GetFilename(), "_import.py");
@@ -600,10 +613,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("_import.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_EQ(file_specs.GetFileSpecAtIndex(0).GetFilename(), "_import.py");
EXPECT_TRUE(ss.GetString().empty());
@@ -629,10 +643,11 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", inner_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 0u);
EXPECT_TRUE(ss.GetString().empty());
}
@@ -662,11 +677,156 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", module_dir);
StreamString ss;
- FileSpecList file_specs =
+ auto [auto_load_spces, file_specs] =
Platform::LocateExecutableScriptingResourcesFromSafePaths(
ss, module_fspec, *m_target_sp);
+ EXPECT_EQ(auto_load_spces.GetSize(), 0u);
EXPECT_EQ(file_specs.GetSize(), 1u);
EXPECT_TRUE(ss.GetString().empty());
}
+
+TEST_F(PlatformLocateSafePathTest,
+ LocateScriptingResourcesFromSafePaths_AutoLoadModule_True) {
+ // When a module is in target.auto-load-modules with value 'true',
+ // its script should be returned in the auto-load list.
+
+ TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
+ FileSpec(m_tmp_root_dir));
+
+ FileSpec module_fspec(CreateFile("TestModule.o", m_tmp_root_dir));
+ ASSERT_TRUE(module_fspec);
+
+ llvm::SmallString<128> module_dir(m_tmp_root_dir);
+ llvm::sys::path::append(module_dir, "TestModule");
+ ASSERT_FALSE(llvm::sys::fs::create_directory(module_dir));
+
+ CreateFile("TestModule.py", module_dir);
+
+ m_target_sp->SetAutoLoadModule("TestModule", true);
+
+ StreamString ss;
+ auto [auto_load_files, non_auto_load_files] =
+ Platform::LocateExecutableScriptingResourcesFromSafePaths(
+ ss, module_fspec, *m_target_sp);
+
+ EXPECT_EQ(auto_load_files.GetSize(), 1u);
+ EXPECT_EQ(auto_load_files.GetFileSpecAtIndex(0).GetFilename(),
+ "TestModule.py");
+ EXPECT_EQ(non_auto_load_files.GetSize(), 0u);
+}
+
+TEST_F(PlatformLocateSafePathTest,
+ LocateScriptingResourcesFromSafePaths_AutoLoadModule_False) {
+ // When a module is in target.auto-load-modules with value 'false',
+ // its script should not appear in either list.
+
+ TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
+ FileSpec(m_tmp_root_dir));
+
+ FileSpec module_fspec(CreateFile("TestModule.o", m_tmp_root_dir));
+ ASSERT_TRUE(module_fspec);
+
+ llvm::SmallString<128> module_dir(m_tmp_root_dir);
+ llvm::sys::path::append(module_dir, "TestModule");
+ ASSERT_FALSE(llvm::sys::fs::create_directory(module_dir));
+
+ CreateFile("TestModule.py", module_dir);
+
+ m_target_sp->SetAutoLoadModule("TestModule", false);
+
+ StreamString ss;
+ auto [auto_load_files, non_auto_load_files] =
+ Platform::LocateExecutableScriptingResourcesFromSafePaths(
+ ss, module_fspec, *m_target_sp);
+
+ EXPECT_EQ(auto_load_files.GetSize(), 0u);
+ EXPECT_EQ(non_auto_load_files.GetSize(), 0u);
+}
+
+TEST_F(PlatformLocateSafePathTest,
+ LocateScriptingResourcesFromSafePaths_AutoLoadModule_NotInDict) {
+ // When a module is NOT in the dictionary, its script should end up
+ // in the non-auto-load list (the existing behavior).
+
+ TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
+ FileSpec(m_tmp_root_dir));
+
+ FileSpec module_fspec(CreateFile("TestModule.o", m_tmp_root_dir));
+ ASSERT_TRUE(module_fspec);
+
+ llvm::SmallString<128> module_dir(m_tmp_root_dir);
+ llvm::sys::path::append(module_dir, "TestModule");
+ ASSERT_FALSE(llvm::sys::fs::create_directory(module_dir));
+
+ CreateFile("TestModule.py", module_dir);
+
+ // Set a different module in the dictionary; TestModule is not present.
+ m_target_sp->SetAutoLoadModule("SomeOtherModule", true);
+
+ StreamString ss;
+ auto [auto_load_files, non_auto_load_files] =
+ Platform::LocateExecutableScriptingResourcesFromSafePaths(
+ ss, module_fspec, *m_target_sp);
+
+ EXPECT_EQ(auto_load_files.GetSize(), 0u);
+ EXPECT_EQ(non_auto_load_files.GetSize(), 1u);
+ EXPECT_EQ(non_auto_load_files.GetFileSpecAtIndex(0).GetFilename(),
+ "TestModule.py");
+}
+
+TEST_F(PlatformLocateSafePathTest,
+ LocateScriptingResourcesFromSafePaths_AutoLoadModule_Multiple) {
+ // When multiple modules are in target.auto-load-modules with value 'true',
+ // each module's script should be returned in its respective auto-load list.
+
+ TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
+ FileSpec(m_tmp_root_dir));
+
+ // Set up ModuleA.
+ FileSpec module_a_fspec(CreateFile("ModuleA.o", m_tmp_root_dir));
+ ASSERT_TRUE(module_a_fspec);
+
+ llvm::SmallString<128> module_a_dir(m_tmp_root_dir);
+ llvm::sys::path::append(module_a_dir, "ModuleA");
+ ASSERT_FALSE(llvm::sys::fs::create_directory(module_a_dir));
+ CreateFile("ModuleA.py", module_a_dir);
+
+ // Set up ModuleB.
+ FileSpec module_b_fspec(CreateFile("ModuleB.o", m_tmp_root_dir));
+ ASSERT_TRUE(module_b_fspec);
+
+ llvm::SmallString<128> module_b_dir(m_tmp_root_dir);
+ llvm::sys::path::append(module_b_dir, "ModuleB");
+ ASSERT_FALSE(llvm::sys::fs::create_directory(module_b_dir));
+ CreateFile("ModuleB.py", module_b_dir);
+
+ m_target_sp->SetAutoLoadModule("ModuleA", true);
+ m_target_sp->SetAutoLoadModule("ModuleB", true);
+
+ {
+ StreamString ss;
+ auto [auto_load_files, non_auto_load_files] =
+ Platform::LocateExecutableScriptingResourcesFromSafePaths(
+ ss, module_a_fspec, *m_target_sp);
+
+ EXPECT_EQ(auto_load_files.GetSize(), 1u);
+ EXPECT_EQ(auto_load_files.GetFileSpecAtIndex(0).GetFilename(),
+ "ModuleA.py");
+ EXPECT_EQ(non_auto_load_files.GetSize(), 0u);
+ }
+
+ {
+ StreamString ss;
+ auto [auto_load_files, non_auto_load_files] =
+ Platform::LocateExecutableScriptingResourcesFromSafePaths(
+ ss, module_b_fspec, *m_target_sp);
+
+ EXPECT_EQ(auto_load_files.GetSize(), 1u);
+ EXPECT_EQ(auto_load_files.GetFileSpecAtIndex(0).GetFilename(),
+ "ModuleB.py");
+ EXPECT_EQ(non_auto_load_files.GetSize(), 0u);
+ }
+}
+
#endif // NDEBUG
>From e26a9ff302306f6f0b0e3db54748d5be08df6bae Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 27 Mar 2026 10:56:29 +0000
Subject: [PATCH 2/4] fixup! rename setting
---
lldb/include/lldb/Target/Target.h | 5 +++--
lldb/source/Target/Target.cpp | 10 +++++-----
lldb/source/Target/TargetProperties.td | 4 ++--
.../AutoLoad/UNIX/auto-load-modules-false.test | 4 ++--
.../AutoLoad/UNIX/auto-load-modules-multiple.test | 4 ++--
.../AutoLoad/UNIX/auto-load-modules-not-in-dict.test | 4 ++--
.../AutoLoad/UNIX/auto-load-modules-true.test | 4 ++--
lldb/unittests/Platform/PlatformTest.cpp | 11 ++++++-----
8 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index a9f602bb7873f..8edac8d4017af 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -278,9 +278,10 @@ class TargetProperties : public Properties {
bool GetDebugUtilityExpression() const;
- OptionValueDictionary *GetAutoLoadModules() const;
+ OptionValueDictionary *GetAutoLoadScriptsForModules() const;
- void SetAutoLoadModule(llvm::StringRef module_name, bool should_load);
+ void SetAutoLoadScriptsForModules(llvm::StringRef module_name,
+ bool should_load);
private:
std::optional<bool>
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index cd0fe4e3eea58..b6b647c62628d 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -5266,14 +5266,14 @@ void TargetProperties::SetDebugUtilityExpression(bool debug) {
SetPropertyAtIndex(idx, debug);
}
-OptionValueDictionary *TargetProperties::GetAutoLoadModules() const {
+OptionValueDictionary *TargetProperties::GetAutoLoadScriptsForModules() const {
return m_collection_sp->GetPropertyAtIndexAsOptionValueDictionary(
- ePropertyAutoLoadModules);
+ ePropertyAutoLoadScriptsForModules);
}
-void TargetProperties::SetAutoLoadModule(llvm::StringRef module_name,
- bool should_load) {
- OptionValueDictionary *dict = GetAutoLoadModules();
+void TargetProperties::SetAutoLoadScriptsForModules(llvm::StringRef module_name,
+ bool should_load) {
+ OptionValueDictionary *dict = GetAutoLoadScriptsForModules();
if (!dict)
return;
dict->SetValueForKey(module_name,
diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td
index d8ef0df70e7f8..a54c6090fa82a 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -220,8 +220,8 @@ let Definition = "target", Path = "target" in {
def ParallelModuleLoad: Property<"parallel-module-load", "Boolean">,
DefaultTrue,
Desc<"Enable loading of modules in parallel for the dynamic loader.">;
- def AutoLoadModules
- : Property<"auto-load-modules", "Dictionary">,
+ def AutoLoadScriptsForModules
+ : Property<"auto-load-scripts-for-modules", "Dictionary">,
ElementType<"Boolean">,
Desc<"A list of module names and whether LLDB will auto-load scripting "
"resources for it from safe paths.">;
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test
index 2902df479979c..7154d52e8f6a2 100644
--- a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-false.test
@@ -1,6 +1,6 @@
# REQUIRES: python, asserts, !system-windows
-# Test that when a module is listed in target.auto-load-modules with 'false',
+# Test that when a module is listed in target.auto-load-scripts-for-modules with 'false',
# its scripting resources are NOT loaded even when target.load-script-from-symbol-file
# is true.
@@ -12,7 +12,7 @@
# RUN: %lldb -b \
# RUN: -o 'settings set target.load-script-from-symbol-file true' \
# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
-# RUN: -o 'settings set target.auto-load-modules TestModule=false' \
+# RUN: -o 'settings set target.auto-load-scripts-for-modules TestModule=false' \
# RUN: -o 'target create %t/TestModule.out' 2>&1 \
# RUN: | FileCheck %s --implicit-check-not=AUTOLOAD_SUCCESS --implicit-check-not=warning
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test
index a9de987017641..d26c574ff2d5c 100644
--- a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-multiple.test
@@ -1,6 +1,6 @@
# REQUIRES: python, asserts, !system-windows
-# Test that multiple modules listed in target.auto-load-modules are all
+# Test that multiple modules listed in target.auto-load-scripts-for-modules are all
# auto-loaded.
# RUN: split-file %s %t
@@ -14,7 +14,7 @@
# RUN: %lldb -b \
# RUN: -o 'settings set target.load-script-from-symbol-file false' \
# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
-# RUN: -o 'settings set target.auto-load-modules TestModule=true libFoo=true' \
+# RUN: -o 'settings set target.auto-load-scripts-for-modules TestModule=true libFoo=true' \
# RUN: -o 'target create %t/TestModule.out' 2>&1 | FileCheck %s
# CHECK-DAG: MAIN_AUTOLOAD_SUCCESS
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test
index cf9a80121c17a..3213ae61558dd 100644
--- a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-not-in-dict.test
@@ -1,6 +1,6 @@
# REQUIRES: python, asserts, !system-windows
-# Test that when a module is NOT in target.auto-load-modules, the existing
+# Test that when a module is NOT in target.auto-load-scripts-for-modules, the existing
# target.load-script-from-symbol-file setting controls whether scripts load.
# With load-script-from-symbol-file=true and no dictionary entry, scripts
# should still load normally.
@@ -15,7 +15,7 @@
# RUN: %lldb -b \
# RUN: -o 'settings set target.load-script-from-symbol-file warn' \
# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
-# RUN: -o 'settings set target.auto-load-modules SomeOtherModule=true' \
+# RUN: -o 'settings set target.auto-load-scripts-for-modules SomeOtherModule=true' \
# RUN: -o 'target create %t/TestModule.out' 2>&1 | FileCheck %s --implicit-check-not=AUTOLOAD_SUCCESS
# CHECK: warning: 'TestModule' contains a debug script. To run this script in this debug session
diff --git a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test
index 87b09248b22f6..f1f2932cac55b 100644
--- a/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test
+++ b/lldb/test/Shell/Platform/AutoLoad/UNIX/auto-load-modules-true.test
@@ -1,6 +1,6 @@
# REQUIRES: python, asserts, !system-windows
-# Test that when a module is listed in target.auto-load-modules with 'true',
+# Test that when a module is listed in target.auto-load-scripts-for-modules with 'true',
# its scripting resources are loaded even when target.load-script-from-symbol-file
# is false.
@@ -12,7 +12,7 @@
# RUN: %lldb -b \
# RUN: -o 'settings set target.load-script-from-symbol-file false' \
# RUN: -o 'settings append testing.safe-auto-load-paths %t/safe-path' \
-# RUN: -o 'settings set target.auto-load-modules TestModule=true' \
+# RUN: -o 'settings set target.auto-load-scripts-for-modules TestModule=true' \
# RUN: -o 'target create %t/TestModule.out' 2>&1 | FileCheck %s
# CHECK: AUTOLOAD_SUCCESS
diff --git a/lldb/unittests/Platform/PlatformTest.cpp b/lldb/unittests/Platform/PlatformTest.cpp
index a703c8ed09f15..38d272f191b77 100644
--- a/lldb/unittests/Platform/PlatformTest.cpp
+++ b/lldb/unittests/Platform/PlatformTest.cpp
@@ -688,7 +688,7 @@ TEST_F(PlatformLocateSafePathTest,
TEST_F(PlatformLocateSafePathTest,
LocateScriptingResourcesFromSafePaths_AutoLoadModule_True) {
- // When a module is in target.auto-load-modules with value 'true',
+ // When a module is in target.auto-load-scripts-for-modules with value 'true',
// its script should be returned in the auto-load list.
TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
@@ -718,8 +718,8 @@ TEST_F(PlatformLocateSafePathTest,
TEST_F(PlatformLocateSafePathTest,
LocateScriptingResourcesFromSafePaths_AutoLoadModule_False) {
- // When a module is in target.auto-load-modules with value 'false',
- // its script should not appear in either list.
+ // When a module is in target.auto-load-scripts-for-modules with value
+ // 'false', its script should not appear in either list.
TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
FileSpec(m_tmp_root_dir));
@@ -777,8 +777,9 @@ TEST_F(PlatformLocateSafePathTest,
TEST_F(PlatformLocateSafePathTest,
LocateScriptingResourcesFromSafePaths_AutoLoadModule_Multiple) {
- // When multiple modules are in target.auto-load-modules with value 'true',
- // each module's script should be returned in its respective auto-load list.
+ // When multiple modules are in target.auto-load-scripts-for-modules with
+ // value 'true', each module's script should be returned in its respective
+ // auto-load list.
TestingProperties::GetGlobalTestingProperties().AppendSafeAutoLoadPaths(
FileSpec(m_tmp_root_dir));
>From 6a4e2ca161a2406b15e94f006f7c6b44ca7da4fb Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 27 Mar 2026 10:59:05 +0000
Subject: [PATCH 3/4] fixup
---
lldb/source/Target/Platform.cpp | 2 +-
lldb/unittests/Platform/PlatformTest.cpp | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index db560769c1e34..db09beb9e7137 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -171,7 +171,7 @@ enum class OptionalBool {
/// In all other cases, returns \c OptionalBool::eDontKnow.
static OptionalBool CanAutoLoadModule(const FileSpec &module_fspec,
const Target &target) {
- OptionValueDictionary *names = target.GetAutoLoadModules();
+ OptionValueDictionary *names = target.GetAutoLoadScriptsForModules();
if (!names)
return OptionalBool::eDontKnow;
diff --git a/lldb/unittests/Platform/PlatformTest.cpp b/lldb/unittests/Platform/PlatformTest.cpp
index 38d272f191b77..f00eb746d55a5 100644
--- a/lldb/unittests/Platform/PlatformTest.cpp
+++ b/lldb/unittests/Platform/PlatformTest.cpp
@@ -703,7 +703,7 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", module_dir);
- m_target_sp->SetAutoLoadModule("TestModule", true);
+ m_target_sp->SetAutoLoadScriptsForModules("TestModule", true);
StreamString ss;
auto [auto_load_files, non_auto_load_files] =
@@ -733,7 +733,7 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", module_dir);
- m_target_sp->SetAutoLoadModule("TestModule", false);
+ m_target_sp->SetAutoLoadScriptsForModules("TestModule", false);
StreamString ss;
auto [auto_load_files, non_auto_load_files] =
@@ -762,7 +762,7 @@ TEST_F(PlatformLocateSafePathTest,
CreateFile("TestModule.py", module_dir);
// Set a different module in the dictionary; TestModule is not present.
- m_target_sp->SetAutoLoadModule("SomeOtherModule", true);
+ m_target_sp->SetAutoLoadScriptsForModules("SomeOtherModule", true);
StreamString ss;
auto [auto_load_files, non_auto_load_files] =
@@ -802,8 +802,8 @@ TEST_F(PlatformLocateSafePathTest,
ASSERT_FALSE(llvm::sys::fs::create_directory(module_b_dir));
CreateFile("ModuleB.py", module_b_dir);
- m_target_sp->SetAutoLoadModule("ModuleA", true);
- m_target_sp->SetAutoLoadModule("ModuleB", true);
+ m_target_sp->SetAutoLoadScriptsForModules("ModuleA", true);
+ m_target_sp->SetAutoLoadScriptsForModules("ModuleB", true);
{
StreamString ss;
>From e13688ecac912e3d554dc5587463e96c055e2501 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 27 Mar 2026 11:00:47 +0000
Subject: [PATCH 4/4] fixup! fixup OptionalBool -> LazyBool
---
lldb/source/Target/Platform.cpp | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index db09beb9e7137..22c55ec2a32e9 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -41,6 +41,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-private-enumerations.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
@@ -158,33 +159,26 @@ Status Platform::GetFileWithUUID(const FileSpec &platform_file,
return Status();
}
-// FIXME: move this into lldb-private-enumerations.h?
-enum class OptionalBool {
- eYes,
- eNo,
- eDontKnow,
-};
-
-/// Returns \c OptionalBool::eYes if scripting resources associated with the
+/// Returns \c eLazyBoolNo if scripting resources associated with the
/// specified module \c FileSpec can be automatically loaded. If a module is
-/// explicitly disallowed from being auto-loaded, returns \c OptionalBool::eNo.
-/// In all other cases, returns \c OptionalBool::eDontKnow.
-static OptionalBool CanAutoLoadModule(const FileSpec &module_fspec,
- const Target &target) {
+/// explicitly disallowed from being auto-loaded, returns \c eLazyBoolNo.
+/// In all other cases, returns \c eDontKnow.
+static LazyBool CanAutoLoadModule(const FileSpec &module_fspec,
+ const Target &target) {
OptionValueDictionary *names = target.GetAutoLoadScriptsForModules();
if (!names)
- return OptionalBool::eDontKnow;
+ return eLazyBoolCalculate;
OptionValueSP value_sp =
names->GetValueForKey(module_fspec.GetFileNameStrippingExtension());
if (!value_sp)
- return OptionalBool::eDontKnow;
+ return eLazyBoolCalculate;
auto maybe_can_load = value_sp->GetValueAs<bool>();
if (!maybe_can_load)
- return OptionalBool::eDontKnow;
+ return eLazyBoolCalculate;
- return *maybe_can_load ? OptionalBool::eYes : OptionalBool::eNo;
+ return *maybe_can_load ? eLazyBoolYes : eLazyBoolNo;
}
std::pair<FileSpecList, FileSpecList>
@@ -229,10 +223,10 @@ Platform::LocateExecutableScriptingResourcesFromSafePaths(
orig_script_fspec, script_fspec);
if (FileSystem::Instance().Exists(script_fspec)) {
- OptionalBool can_auto_load = CanAutoLoadModule(module_spec, target);
- if (can_auto_load == OptionalBool::eYes)
+ LazyBool can_auto_load = CanAutoLoadModule(module_spec, target);
+ if (can_auto_load == eLazyBoolYes)
auto_load_files.Append(script_fspec);
- else if (can_auto_load == OptionalBool::eDontKnow)
+ else if (can_auto_load == eLazyBoolCalculate)
non_auto_load_files.Append(script_fspec);
}
More information about the lldb-commits
mailing list