|
| 1 | +""" |
| 2 | +Make sure the frame variable -g, -a, and -l flags work. |
| 3 | +""" |
| 4 | + |
| 5 | + |
| 6 | +import lldb |
| 7 | +import lldbsuite.test.lldbutil as lldbutil |
| 8 | +from lldbsuite.test.decorators import * |
| 9 | +from lldbsuite.test.lldbtest import * |
| 10 | +import os |
| 11 | +import shutil |
| 12 | +import time |
| 13 | + |
| 14 | + |
| 15 | +class TestFrameVarAnonStruct(TestBase): |
| 16 | + # If your test case doesn't stress debug info, then |
| 17 | + # set this to true. That way it won't be run once for |
| 18 | + # each debug info format. |
| 19 | + NO_DEBUG_INFO_TESTCASE = True |
| 20 | + |
| 21 | + def test_frame_var(self): |
| 22 | + self.build() |
| 23 | + self.do_test() |
| 24 | + |
| 25 | + def do_test(self): |
| 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 | + ) |
| 33 | + self.assertTrue( |
| 34 | + breakpoint and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT |
| 35 | + ) |
| 36 | + |
| 37 | + error = lldb.SBError() |
| 38 | + # This is the launch info. If you want to launch with arguments or |
| 39 | + # environment variables, add them using SetArguments or |
| 40 | + # SetEnvironmentEntries |
| 41 | + |
| 42 | + launch_info = target.GetLaunchInfo() |
| 43 | + process = target.Launch(launch_info, error) |
| 44 | + self.assertTrue(process, PROCESS_IS_VALID) |
| 45 | + |
| 46 | + # Did we hit our breakpoint? |
| 47 | + from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint |
| 48 | + |
| 49 | + threads = get_threads_stopped_at_breakpoint(process, breakpoint) |
| 50 | + self.assertEqual( |
| 51 | + len(threads), 1, "There should be a thread stopped at our breakpoint" |
| 52 | + ) |
| 53 | + |
| 54 | + # The hit count for the breakpoint should be 1. |
| 55 | + self.assertEqual(breakpoint.GetHitCount(), 1) |
| 56 | + |
| 57 | + frame = threads[0].GetFrameAtIndex(0) |
| 58 | + command_result = lldb.SBCommandReturnObject() |
| 59 | + interp = self.dbg.GetCommandInterpreter() |
| 60 | + |
| 61 | + # Verify that we don't crash in this case. |
| 62 | + self.expect("frame variable 'b.x'", error=True, |
| 63 | + substrs=['"x" is not a member of "(B) b"']) |
0 commit comments