[Lldb-commits] [lldb] 2e82608 - [lldb] Fix a bug in D96779 (shared lib directory logic)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 9 06:21:41 PST 2021


Author: Pavel Labath
Date: 2021-03-09T15:15:45+01:00
New Revision: 2e826088b9832067994e0348fc768b81632be687

URL: https://github.com/llvm/llvm-project/commit/2e826088b9832067994e0348fc768b81632be687
DIFF: https://github.com/llvm/llvm-project/commit/2e826088b9832067994e0348fc768b81632be687.diff

LOG: [lldb] Fix a bug in D96779 (shared lib directory logic)

This function would fail in debug builds, as the two usages of the
LLDB_PYTHON_RELATIVE_LIBDIR macro would expand to two distinct strings.
The path iterator macros don't support that.

Use a temporary variable to ensure everything points to a single string.

Added: 
    

Modified: 
    lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index b3f72066195b..c4cc67cf7ab3 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -421,8 +421,9 @@ void ScriptInterpreterPython::SharedLibraryDirectoryHelper(
   if (this_file.GetFileNameExtension() == ConstString(".pyd")) {
     this_file.RemoveLastPathComponent(); // _lldb.pyd or _lldb_d.pyd
     this_file.RemoveLastPathComponent(); // lldb
-    for (auto it = llvm::sys::path::begin(LLDB_PYTHON_RELATIVE_LIBDIR),
-              end = llvm::sys::path::end(LLDB_PYTHON_RELATIVE_LIBDIR);
+    llvm::StringRef libdir = LLDB_PYTHON_RELATIVE_LIBDIR;
+    for (auto it = llvm::sys::path::begin(libdir),
+              end = llvm::sys::path::end(libdir);
          it != end; ++it)
       this_file.RemoveLastPathComponent();
     this_file.AppendPathComponent("bin");


        


More information about the lldb-commits mailing list