[Lldb-commits] [PATCH] D83552: [lldb/test] Do a better job at setting (DY)LD_LIBRARY_PATH
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 10 06:08:00 PDT 2020
labath created this revision.
labath added reviewers: davide, jingham.
Herald added a project: LLDB.
registerSharedLibrariesWithTarget was setting the library path
environment variable to the process build directory, but the function is
also accepting libraries in other directories (in which case they won't
be found automatically).
This patch makes the function set the path variable correctly for these
libraries too. This enables us to remove the code for setting the path
variable in TestWeakSymbols.py, which was working only accidentally --
it was relying on the fact that
launch_info.SetEnvironmentEntries(..., append=True)
would not overwrite the path variable it has set, but that is going to
change with D83306 <https://reviews.llvm.org/D83306>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83552
Files:
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
Index: lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
===================================================================
--- lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
+++ lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
@@ -48,10 +48,6 @@
launch_info = lldb.SBLaunchInfo(None)
launch_info.SetWorkingDirectory(self.getBuildDir())
- # We have to point to the hidden directory to pick up the
- # version of the dylib without the weak symbols:
- env_expr = self.platformContext.shlib_environment_var + "=" + hidden_dir
- launch_info.SetEnvironmentEntries([env_expr], True)
(self.target, _, thread, _) = lldbutil.run_to_source_breakpoint(
self, "Set a breakpoint here",
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1928,8 +1928,7 @@
shlib_prefix = self.platformContext.shlib_prefix
shlib_extension = '.' + self.platformContext.shlib_extension
- working_dir = self.get_process_working_directory()
- environment = ['%s=%s' % (shlib_environment_var, working_dir)]
+ dirs = []
# Add any shared libraries to our target if remote so they get
# uploaded into the working directory on the remote side
for name in shlibs:
@@ -1952,6 +1951,7 @@
# Make sure we found the local shared library in the above code
self.assertTrue(os.path.exists(local_shlib_path))
+
# Add the shared library to our target
shlib_module = target.AddModule(local_shlib_path, None, None, None)
if lldb.remote_platform:
@@ -1961,8 +1961,15 @@
os.path.basename(local_shlib_path))
shlib_module.SetRemoteInstallFileSpec(
lldb.SBFileSpec(remote_shlib_path, False))
+ dir_to_add = self.get_process_working_directory()
+ else:
+ dir_to_add = os.path.dirname(local_shlib_path)
+
+ if dir_to_add not in dirs:
+ dirs.append(dir_to_add)
- return environment
+ env_value = self.platformContext.shlib_path_separator.join(dirs)
+ return ['%s=%s' % (shlib_environment_var, env_value)]
def registerSanitizerLibrariesWithTarget(self, target):
runtimes = []
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83552.277014.patch
Type: text/x-patch
Size: 2560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200710/2c444c78/attachment.bin>
More information about the lldb-commits
mailing list