| 1 |
""" |
| 2 |
Test to ensure SBFrame::Disassemble produces SOME output |
| 3 |
""" |
| 4 |
|
| 5 |
|
| 6 |
import lldb |
| 7 |
import lldbsuite.test.lldbutil as lldbutil |
| 8 |
from lldbsuite.test.lldbtest import * |
| 9 |
|
| 10 |
|
| 11 |
class FrameDisassembleTestCase(TestBase): |
| 12 |
NO_DEBUG_INFO_TESTCASE = True |
| 13 |
|
| 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 matching |
| 25 |
# "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_BREAKPOINT |
| 31 |
) |
| 32 |
|
| 33 |
error = lldb.SBError() |
| 34 |
# This is the launch info. If you want to launch with arguments or |
| 35 |
# environment variables, add them using SetArguments or |
| 36 |
# SetEnvironmentEntries |
| 37 |
|
| 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_breakpoint |
| 44 |
|
| 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) |