[Lldb-commits] [lldb] caecca0 - [lldb] add getFullLibName to PlatformContext (#188772)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 31 04:09:57 PDT 2026
Author: Charles Zablit
Date: 2026-03-31T12:09:52+01:00
New Revision: caecca035ab9fdccd1fd1b1b17452b415f89b366
URL: https://github.com/llvm/llvm-project/commit/caecca035ab9fdccd1fd1b1b17452b415f89b366
DIFF: https://github.com/llvm/llvm-project/commit/caecca035ab9fdccd1fd1b1b17452b415f89b366.diff
LOG: [lldb] add getFullLibName to PlatformContext (#188772)
This patch introduces `PlatformContext.getFullLibName` which returns the
full dylib name for any platform based on the base name of the dylib.
Example:
```
# Windows
PlatformContext.getFullLibName("Foo") -> "Foo.dll"
# Linux
PlatformContext.getFullLibName("Foo") -> "libFoo.so"
```
Added:
Modified:
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/test/API/commands/target/create-deps/TestTargetCreateDeps.py
lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py
lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_unload/TestLoadUnload.py
lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 0d609dde6fd2a..39b52d6844bee 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -225,6 +225,9 @@ def __init__(
self.shlib_prefix = shlib_prefix
self.shlib_extension = shlib_extension
+ def getFullLibName(self, base_name):
+ return f"{self.shlib_prefix}{base_name}.{self.shlib_extension}"
+
def createPlatformContext():
if platformIsDarwin():
diff --git a/lldb/test/API/commands/target/create-deps/TestTargetCreateDeps.py b/lldb/test/API/commands/target/create-deps/TestTargetCreateDeps.py
index fb60058acfd92..06a28cc459d66 100644
--- a/lldb/test/API/commands/target/create-deps/TestTargetCreateDeps.py
+++ b/lldb/test/API/commands/target/create-deps/TestTargetCreateDeps.py
@@ -74,22 +74,19 @@ def test_dependents_implicit_false_exe(self):
@expectedFailureAndroid # android will return mutiple images
def test_dependents_implicit_default_lib(self):
- ctx = self.platformContext
- dylibName = ctx.shlib_prefix + "load_a." + ctx.shlib_extension
+ dylibName = self.platformContext.getFullLibName("load_a")
lib = self.getBuildArtifact(dylibName)
self.runCmd("target create " + lib, CURRENT_EXECUTABLE_SET)
self.has_exactly_one_image(True)
def test_dependents_explicit_default_lib(self):
- ctx = self.platformContext
- dylibName = ctx.shlib_prefix + "load_a." + ctx.shlib_extension
+ dylibName = self.platformContext.getFullLibName("load_a")
lib = self.getBuildArtifact(dylibName)
self.runCmd("target create -ddefault " + lib, CURRENT_EXECUTABLE_SET)
self.has_exactly_one_image(True)
def test_dependents_explicit_true_lib(self):
- ctx = self.platformContext
- dylibName = ctx.shlib_prefix + "load_a." + ctx.shlib_extension
+ dylibName = self.platformContext.getFullLibName("load_a")
lib = self.getBuildArtifact(dylibName)
self.runCmd("target create -dtrue " + lib, CURRENT_EXECUTABLE_SET)
self.has_exactly_one_image(True)
@@ -100,15 +97,13 @@ def test_dependents_explicit_true_lib(self):
triple=no_match(".*-android"),
)
def test_dependents_explicit_false_lib(self):
- ctx = self.platformContext
- dylibName = ctx.shlib_prefix + "load_a." + ctx.shlib_extension
+ dylibName = self.platformContext.getFullLibName("load_a")
lib = self.getBuildArtifact(dylibName)
self.runCmd("target create -dfalse " + lib, CURRENT_EXECUTABLE_SET)
self.has_exactly_one_image(False)
def test_dependents_implicit_false_lib(self):
- ctx = self.platformContext
- dylibName = ctx.shlib_prefix + "load_a." + ctx.shlib_extension
+ dylibName = self.platformContext.getFullLibName("load_a")
lib = self.getBuildArtifact(dylibName)
self.runCmd("target create -d " + lib, CURRENT_EXECUTABLE_SET)
self.has_exactly_one_image(True)
diff --git a/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py b/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py
index 8da4bf4af8efd..4ff2262b39102 100644
--- a/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py
+++ b/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py
@@ -17,9 +17,7 @@ def common_setup(self):
self.main_spec = lldb.SBFileSpec("main.cpp")
self.b_spec = lldb.SBFileSpec("b.cpp")
self.lib_shortname = "lib_b"
- self.lib_fullname = (
- ctx.shlib_prefix + self.lib_shortname + "." + ctx.shlib_extension
- )
+ self.lib_fullname = ctx.getFullLibName(self.lib_shortname)
self.lib_spec = lldb.SBFileSpec(self.lib_fullname)
def test_break_in_dlopen_dylib_using_lldbutils(self):
diff --git a/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py b/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
index 31ff9b85b4e9f..c39d2083a21da 100644
--- a/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
+++ b/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
@@ -16,8 +16,7 @@ class TestExecutableIsFirst(TestBase):
def test_executable_is_first_before_run(self):
self.build()
- ctx = self.platformContext
- lib_name = ctx.shlib_prefix + "bar." + ctx.shlib_extension
+ lib_name = self.platformContext.getFullLibName("bar")
exe = self.getBuildArtifact("a.out")
lib = self.getBuildArtifact(lib_name)
diff --git a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
index 7e8a336571ab2..ffb4d3e01ea1f 100644
--- a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
+++ b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
@@ -15,8 +15,7 @@ def test_load_after_attach(self):
self, "process_ready"
)
- ctx = self.platformContext
- lib_name = ctx.shlib_prefix + "lib_b." + ctx.shlib_extension
+ lib_name = self.platformContext.getFullLibName("lib_b")
exe = self.getBuildArtifact("a.out")
lib = self.getBuildArtifact(lib_name)
diff --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
index 969a49b846828..036c4a45f58f5 100644
--- a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
+++ b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -25,16 +25,8 @@ def test_load_using_lazy_bind(self):
self.build()
wd = os.path.realpath(self.getBuildDir())
- def make_lib_name(name):
- return (
- self.platformContext.shlib_prefix
- + name
- + "."
- + self.platformContext.shlib_extension
- )
-
def make_lib_path(name):
- libpath = os.path.join(wd, make_lib_name(name))
+ libpath = os.path.join(wd, self.platformContext.getFullLibName(name))
self.assertTrue(os.path.exists(libpath))
return libpath
@@ -51,7 +43,7 @@ def make_lib_path(name):
# Load libt1; should fail unless we use RTLD_LAZY
error = lldb.SBError()
- lib_spec = lldb.SBFileSpec(make_lib_name("t1"))
+ lib_spec = lldb.SBFileSpec(self.platformContext.getFullLibName("t1"))
paths = lldb.SBStringList()
paths.AppendString(wd)
out_spec = lldb.SBFileSpec()
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index cfbfaff10de3c..310e8f9d09fd8 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -243,8 +243,7 @@ def run_lldb_process_load_and_unload_commands(self):
self.runCmd("run", RUN_SUCCEEDED)
- ctx = self.platformContext
- dylibName = ctx.shlib_prefix + "loadunload_a." + ctx.shlib_extension
+ dylibName = self.platformContext.getFullLibName("loadunload_a")
localDylibPath = self.getBuildArtifact(dylibName)
if lldb.remote_platform:
wd = lldb.remote_platform.GetWorkingDirectory()
diff --git a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
index dbb9576ed4d51..43b7f946a44a5 100644
--- a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
+++ b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
@@ -31,8 +31,7 @@ def common_setup(self):
self.target, self.shlib_names
)
- ctx = self.platformContext
- self.shared_lib_name = ctx.shlib_prefix + "foo." + ctx.shlib_extension
+ self.shared_lib_name = self.platformContext.getFullLibName("foo")
@skipIfWindows
def test_source_line_breakpoint(self):
More information about the lldb-commits
mailing list