[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 19 09:42:36 PDT 2023


================
@@ -0,0 +1,119 @@
+"""
+Test module locate dwo callback functionality
+"""
+
+import ctypes
+import shutil
+from lldbsuite.test.decorators import *
+import lldb
+from lldbsuite.test import lldbtest, lldbutil
+
+
+class LocateDwoCallbackTestCase(lldbtest.TestBase):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    def setUp(self):
+        lldbtest.TestBase.setUp(self)
+
+        self.build()
+        self.exe = self.getBuildArtifact("a.out")
+        self.dwos = [
+         self.getBuildArtifact("main.dwo"),
+         self.getBuildArtifact("foo.dwo")
+        ]
+
+    def run_program(self):
+        # Set a breakpoint at main
+        target = self.dbg.CreateTarget(self.exe)
+        self.assertTrue(target, lldbtest.VALID_TARGET)
+        lldbutil.run_break_set_by_symbol(self, "main")
+
+        # Now launch the process, and do not stop at entry point.
+        self.process = target.LaunchSimple(None, None, self.get_process_working_directory())
+        self.assertTrue(self.process, lldbtest.PROCESS_IS_VALID)
+
+    def check_symbolicated(self):
+        thread = self.process.GetSelectedThread()
+        frame = thread.GetSelectedFrame()
+        self.assertEquals(len(frame.get_arguments()), 2)
+
+    def check_not_symbolicated(self):
+        thread = self.process.GetSelectedThread()
+        frame = thread.GetSelectedFrame()
+        self.assertNotEquals(len(frame.get_arguments()), 2)
+
+    def moveDwos(self):
+        """Move the dwos to a subdir in the build dir"""
+        dwo_folder = os.path.join(self.getBuildDir(), "dwos")
+        lldbutil.mkdir_p(dwo_folder)
+        for dwo in self.dwos:
+            shutil.move(dwo, dwo_folder)
+
+    @skipIfWindows
+    @skipIfDarwin
+    def test_set_non_callable(self):
+        with self.assertRaises(TypeError):
+            lldb.SBModule.SetLocateDwoCallback("a")
+
+    @skipIfWindows
+    @skipIfDarwin
----------------
bulbazord wrote:

This test should work on Windows and Darwin.

https://github.com/llvm/llvm-project/pull/69517


More information about the lldb-commits mailing list