[Lldb-commits] [lldb] [LLDB] Simplify LLDB test launches with lldbutil (NFC) (PR #224175)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 18:05:02 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/224175.diff


2 Files Affected:

- (modified) lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py (+3-14) 
- (modified) lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py (+1-21) 


``````````diff
diff --git a/lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
index 53e59b31b1c01..7e892f26b9105 100644
--- a/lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
+++ b/lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
@@ -15,20 +15,9 @@ class ObjCiVarIMPTestCase(TestBase):
     def test_imp_ivar_type(self):
         """Test that dynamically discovered ivars of type IMP do not crash LLDB"""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-
-        # Create a target from the debugger.
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # Set up our breakpoint
-
-        bkpt = lldbutil.run_break_set_by_source_regexp(self, "break here")
-
-        # Now launch the process, and do not stop at the entry point.
-        process = target.LaunchSimple(None, None, self.get_process_working_directory())
-
-        self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
+        lldbutil.run_to_source_breakpoint(
+            self, "break here", lldb.SBFileSpec("repro.m")
+        )
 
         self.expect(
             "frame variable --ptr-depth=1 --show-types -d run -- object",
diff --git a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
index acecf1981dcf4..e53b966809592 100644
--- a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
+++ b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
@@ -15,28 +15,8 @@ class TestPtrRefsObjC(TestBase):
     def test_ptr_refs(self):
         """Test the ptr_refs tool on Darwin with Objective-C"""
         self.build()
-        exe = self.getBuildArtifact("a.out")
 
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        main_file_spec = lldb.SBFileSpec("main.m")
-        breakpoint = target.BreakpointCreateBySourceRegex("break", main_file_spec)
-        self.assertTrue(
-            breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT
-        )
-
-        process = target.LaunchSimple(None, None, self.get_process_working_directory())
-        self.assertTrue(process, PROCESS_IS_VALID)
-
-        # Frame #0 should be on self.line1 and the break condition should hold.
-        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
-        self.assertTrue(
-            thread.IsValid(),
-            "There should be a thread stopped due to breakpoint condition",
-        )
-
-        frame = thread.GetFrameAtIndex(0)
+        lldbutil.run_to_source_breakpoint(self, "break", lldb.SBFileSpec("main.m"))
 
         self.runCmd("command script import lldb.macosx.heap")
         self.expect("ptr_refs self", substrs=["malloc", "stack"])

``````````

</details>


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


More information about the lldb-commits mailing list