I've seen a couple new testcases coming past that copy the standard:
exe = self.getBuildArtifact("a.out")
self.target = self.dbg.CreateTarget(exe)
main_bp = self.target.BreakpointCreateByName("main")
self.process = self.target.LaunchSimple(
None, None, self.get_process_working_directory())
# The stop reason of the thread should be breakpoint.
self.assertTrue(self.process.GetState() == lldb.eStateStopped,
etc. to make a target, set a breakpoint by name (or source regex), run the target, and make sure it hits the breakpoint. That's really my fault, I should have provided a better way to do that a long time ago - apologies - but now you should be able to do all that with:
(target, process, thread, breakpoint) = lldbutil.run_to_name_breakpoint(self, "main")
or the equivalent "run_to_source_breakpoint". I bet a good percentage of the text in the testsuite is this repetitive pattern. Simplifying it would for instance have made Adrian's task of building out of tree much less tedious...
It would be great if folks writing new tests would use this form instead, and if you're touching a test and have itchy fingers (or generally find time hanging heavy on your hands) by all means convert tests to this form!
If there's anything else that needs to get added to make these functions broadly useable, please ping me and I'll add it.
For reference, there's a sample test in:
that does it this way and is a better starting point for new tests.