[Lldb-commits] [lldb] [lldb] Support CommandInterpreter print callbacks (PR #125006)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 30 05:17:46 PST 2025
================
@@ -0,0 +1,66 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class BreakpointAPITestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def run_command_interpreter_with_output_file(self, out_filename, input_str):
+ with open(out_filename, "w") as f:
+ self.dbg.SetOutputFileHandle(f, False)
+ self.dbg.SetInputString(input_str)
+ opts = lldb.SBCommandInterpreterRunOptions()
+ self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False)
+
+ def test_command_interpreter_print_callback(self):
+ """Make sure that if an SBBreakpoint gets deleted its IsValid returns false."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ lldbutil.run_to_source_breakpoint(
+ self, "// Break here", lldb.SBFileSpec("main.c")
+ )
+
+ out_filename = self.getBuildArtifact("output")
+ ci = self.dbg.GetCommandInterpreter()
+ called = False
+
+ # The string we'll be looking for in the command output.
+ needle = "Show a list of all debugger commands"
+
+ # Test registering a callback that handles the printing. Make sure the
+ # result is passed to the callback and that we don't print the result.
+ def handling_callback(return_object):
+ nonlocal called
----------------
labath wrote:
TIL
https://github.com/llvm/llvm-project/pull/125006
More information about the lldb-commits
mailing list