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    NO_DEBUG_INFO_TESTCASE = True
15
16    def test_frame_disassemble(self):
17        """Sample test to ensure SBFrame::Disassemble produces SOME output."""
18        self.build()
19        self.frame_disassemble_test()
20
21    def frame_disassemble_test(self):
22        """Sample test to ensure SBFrame::Disassemble produces SOME output"""
23        # Create a target by the debugger.
24        target = self.createTestTarget()
25
26        # Now create a breakpoint in main.c at the source matching
27        # "Set a breakpoint here"
28        breakpoint = target.BreakpointCreateBySourceRegex(
29            "Set a breakpoint here", lldb.SBFileSpec("main.cpp"))
30        self.assertTrue(breakpoint and
31                        breakpoint.GetNumLocations() >= 1,
32                        VALID_BREAKPOINT)
33
34        error = lldb.SBError()
35        # This is the launch info.  If you want to launch with arguments or
36        # environment variables, add them using SetArguments or
37        # SetEnvironmentEntries
38
39        launch_info = target.GetLaunchInfo()
40        process = target.Launch(launch_info, error)
41        self.assertTrue(process, PROCESS_IS_VALID)
42
43        # Did we hit our breakpoint?
44        from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
45        threads = get_threads_stopped_at_breakpoint(process, breakpoint)
46        self.assertEqual(
47            len(threads), 1,
48            "There should be a thread stopped at our breakpoint")
49
50        # The hit count for the breakpoint should be 1.
51        self.assertEquals(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