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        exe = self.getBuildArtifact("a.out")
26
27        # Create a target by the debugger.
28        target = self.dbg.CreateTarget(exe)
29        self.assertTrue(target, VALID_TARGET)
30
31        # Now create a breakpoint in main.c at the source matching
32        # "Set a breakpoint here"
33        breakpoint = target.BreakpointCreateBySourceRegex(
34            "Set a breakpoint here", lldb.SBFileSpec("main.cpp"))
35        self.assertTrue(breakpoint and
36                        breakpoint.GetNumLocations() >= 1,
37                        VALID_BREAKPOINT)
38
39        error = lldb.SBError()
40        # This is the launch info.  If you want to launch with arguments or
41        # environment variables, add them using SetArguments or
42        # SetEnvironmentEntries
43
44        launch_info = target.GetLaunchInfo()
45        process = target.Launch(launch_info, error)
46        self.assertTrue(process, PROCESS_IS_VALID)
47
48        # Did we hit our breakpoint?
49        from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
50        threads = get_threads_stopped_at_breakpoint(process, breakpoint)
51        self.assertTrue(
52            len(threads) == 1,
53            "There should be a thread stopped at our breakpoint")
54
55        # The hit count for the breakpoint should be 1.
56        self.assertEquals(breakpoint.GetHitCount(), 1)
57
58        frame = threads[0].GetFrameAtIndex(0)
59        disassembly = frame.Disassemble()
60        self.assertNotEqual(disassembly, "")
61        self.assertNotIn("error", disassembly)
62        self.assertIn(": nop", disassembly)
63