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