[Lldb-commits] [lldb] [lldb][test] Introduce build_and_run test utility (PR #194386)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 28 21:46:36 PDT 2026
================
@@ -1579,6 +1579,23 @@ def build(
self.runBuildCommand(command)
+ def build_and_run(self, dictionary=None):
+ """
+ Builds the target binary, launches it and runs to the breakpoint
+ location specified by the '// break here' comment.
+ """
+ self.build(dictionary=dictionary)
+
+ main_candidates = ["main.c", "main.cpp", "main.m", "main.mm"]
+
+ for candidate in main_candidates:
+ if os.path.exists(candidate):
+ lldbutil.run_to_source_breakpoint(
+ self, "// break here", lldb.SBFileSpec(candidate, False)
+ )
----------------
medismailben wrote:
I've seen some test use just `// break` instead of `// break here`. Having the ability to optionally specify a pattern or file would be nice:
```suggestion
def build_and_run(self, dictionary=None, file=None, pattern=None):
"""
Builds the target binary, launches it and runs to the breakpoint
location specified by the '// break' comment.
"""
self.build(dictionary=dictionary)
if not pattern:
pattern = "// break "
if os.path.exists(file):
lldbutil.run_to_source_breakpoint(
self, pattern, lldb.SBFileSpec(file, False)
)
main_candidates = ["main.c", "main.cpp", "main.m", "main.mm" ]
for candidate in main_candidates:
if os.path.exists(candidate):
lldbutil.run_to_source_breakpoint(
self, pattern, lldb.SBFileSpec(candidate, False)
)
```
https://github.com/llvm/llvm-project/pull/194386
More information about the lldb-commits
mailing list