================
@@ -0,0 +1,81 @@
+"""
+Test that we read don't read the nlist symbols for a specially marked dylib
+when read from memory.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from time import sleep
+
+
+class NoNlistsTestCase(TestBase):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    @skipIfRemote
+    @skipUnlessDarwin
+    def test_no_nlist_symbols(self):
+        self.build()
+
+        exe = os.path.realpath(self.getBuildArtifact("a.out"))
+
+        popen = self.spawnSubprocess(exe)
+        pid = popen.pid
+
+        self.dbg.SetAsync(False)
+
+        m_no_nlist = lldb.SBModule()
+        m_has_nlist = lldb.SBModule()
+        target = lldb.SBTarget()
+        process = lldb.SBProcess()
+        reattach_count = 0
+
+        # Attach to the process, see if we have a memory module
+        # for libno-nlists.dylib and libhas-nlists.dylib.
+        # If not, detach, delete the Target, and flush the orphaned
+        # modules from the Debugger so we don't hold on to a reference
+        # of the on-disk binary.
+
+        # If we haven't succeeded after ten attemps of attaching and
----------------
JDevlieghere wrote:

Okay, I think I understand the challenge: you can't use lldb to synchronize 
(e.g. by waiting on a `pause()`) because by attaching, you're already going to 
be parsing the library. We have a few other tests that have this issue, and 
they use a file to synchronize through `lldbutil.wait_for_file_on_target`. 

```
        # Use a file as a synchronization point between test and inferior.
        pid_file_path = lldbutil.append_to_process_working_directory(
            self, "pid_file_%d" % (int(time.time()))
        )
        self.addTearDownHook(
            lambda: self.run_platform_command("rm %s" % (pid_file_path))
        )

        popen = self.spawnSubprocess(exe, [pid_file_path])

        pid = lldbutil.wait_for_file_on_target(self, pid_file_path)
```

I think we could use the same approach here. 

https://github.com/llvm/llvm-project/pull/129967
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to