[Lldb-commits] [lldb] cf2c8e4 - [lldb] Fix TestDyldExecLinux with xml enabled

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 14 02:49:24 PDT 2022


Author: Pavel Labath
Date: 2022-06-14T11:44:59+02:00
New Revision: cf2c8e419dbc6575f82b8ac44b62a2306624899a

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

LOG: [lldb] Fix TestDyldExecLinux with xml enabled

NativeProcessLinux is not able to properly read libraries-svr4 data when
running with ld.so as the "main" executable. Normally, this is not a big
problem, as it returns an error message, and lldb can fallback to manual
library loading.

Unfortunately, lldb-server also does not clear cached svr4 data on exec,
which means that it does *not* return an error when the application
execs from the "regular" to the "ld.so" mode. Instead it returns
incorrect data (it is missing the main executable) and causes
TestDyldExecLinux to fail (but only when building with xml support
enabled).

This patch makes ensures that cached process data is cleared on exec,
fixing the test. Since TestDyldExecLinux has shown to be sensitive to
the way we read library info, I fork it into two (with svr4 enabled and
disabled).

Added: 
    

Modified: 
    lldb/include/lldb/Host/common/NativeProcessProtocol.h
    lldb/source/Host/common/NativeProcessProtocol.cpp
    lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
    lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
    lldb/test/API/functionalities/dyld-exec-linux/TestDyldExecLinux.py

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
index ce16e869489ce..7cb353d477a5c 100644
--- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -457,7 +457,7 @@ class NativeProcessProtocol {
   ///
   /// Provide a mechanism for a delegate to clear out any exec-
   /// sensitive data.
-  void NotifyDidExec();
+  virtual void NotifyDidExec();
 
   NativeThreadProtocol *GetThreadByIDUnlocked(lldb::tid_t tid);
 

diff  --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp
index 761f38080efef..31fc00538b5dd 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -322,6 +322,8 @@ void NativeProcessProtocol::NotifyDidExec() {
   Log *log = GetLog(LLDBLog::Process);
   LLDB_LOG(log, "process {0} exec()ed", GetID());
 
+  m_software_breakpoints.clear();
+
   m_delegate.DidExec(this);
 }
 

diff  --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
index 117d12101a0be..b1f032e0cc02e 100644
--- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
+++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
@@ -180,4 +180,9 @@ NativeProcessELF::GetLoadedSVR4Libraries() {
   return library_list;
 }
 
+void NativeProcessELF::NotifyDidExec() {
+  NativeProcessProtocol::NotifyDidExec();
+  m_shared_library_info_addr.reset();
+}
+
 } // namespace lldb_private

diff  --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
index c01409940daab..8e92899defec3 100644
--- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
+++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
@@ -45,6 +45,8 @@ class NativeProcessELF : public NativeProcessProtocol {
   llvm::Expected<SVR4LibraryInfo>
   ReadSVR4LibraryInfo(lldb::addr_t link_map_addr);
 
+  void NotifyDidExec() override;
+
   std::unique_ptr<AuxVector> m_aux_vector;
   llvm::Optional<lldb::addr_t> m_shared_library_info_addr;
 };

diff  --git a/lldb/test/API/functionalities/dyld-exec-linux/TestDyldExecLinux.py b/lldb/test/API/functionalities/dyld-exec-linux/TestDyldExecLinux.py
index 567bc5344a6ad..889a1243045d2 100644
--- a/lldb/test/API/functionalities/dyld-exec-linux/TestDyldExecLinux.py
+++ b/lldb/test/API/functionalities/dyld-exec-linux/TestDyldExecLinux.py
@@ -12,11 +12,20 @@
 
 class TestLinux64ExecViaDynamicLoader(TestBase):
     mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
 
+    @skipIfXmlSupportMissing
     @skipIf(oslist=no_match(['linux']))
-    @no_debug_info_test
-    @skipIf(oslist=["linux"], archs=["arm"])
-    def test(self):
+    def test_with_svr4(self):
+        self.runCmd("settings set plugin.process.gdb-remote.use-libraries-svr4 true")
+        self._test()
+
+    @skipIf(oslist=no_match(['linux']))
+    def test_without_svr4(self):
+        self.runCmd("settings set plugin.process.gdb-remote.use-libraries-svr4 false")
+        self._test()
+
+    def _test(self):
         self.build()
 
         # Extracts path of the interpreter.


        


More information about the lldb-commits mailing list