58 lines · python
1"""2Test to ensure SBFrame::Disassemble produces SOME output3"""4 5 6import lldb7import lldbsuite.test.lldbutil as lldbutil8from lldbsuite.test.lldbtest import *9 10 11class FrameDisassembleTestCase(TestBase):12 NO_DEBUG_INFO_TESTCASE = True13 14 def test_frame_disassemble(self):15 """Sample test to ensure SBFrame::Disassemble produces SOME output."""16 self.build()17 self.frame_disassemble_test()18 19 def frame_disassemble_test(self):20 """Sample test to ensure SBFrame::Disassemble produces SOME output"""21 # Create a target by the debugger.22 target = self.createTestTarget()23 24 # Now create a breakpoint in main.c at the source matching25 # "Set a breakpoint here"26 breakpoint = target.BreakpointCreateBySourceRegex(27 "Set a breakpoint here", lldb.SBFileSpec("main.cpp")28 )29 self.assertTrue(30 breakpoint and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT31 )32 33 error = lldb.SBError()34 # This is the launch info. If you want to launch with arguments or35 # environment variables, add them using SetArguments or36 # SetEnvironmentEntries37 38 launch_info = target.GetLaunchInfo()39 process = target.Launch(launch_info, error)40 self.assertTrue(process, PROCESS_IS_VALID)41 42 # Did we hit our breakpoint?43 from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint44 45 threads = get_threads_stopped_at_breakpoint(process, breakpoint)46 self.assertEqual(47 len(threads), 1, "There should be a thread stopped at our breakpoint"48 )49 50 # The hit count for the breakpoint should be 1.51 self.assertEqual(breakpoint.GetHitCount(), 1)52 53 frame = threads[0].GetFrameAtIndex(0)54 disassembly = frame.Disassemble()55 self.assertNotEqual(disassembly, "")56 self.assertNotIn("error", disassembly)57 self.assertIn(": nop", disassembly)58