1 2import lldb 3from lldbsuite.test.decorators import * 4from lldbsuite.test.lldbtest import * 5from lldbsuite.test import lldbutil 6 7class ValueAPIEmptyClassTestCase(TestBase): 8 9 def test(self): 10 self.build() 11 exe = self.getBuildArtifact("a.out") 12 line = line_number('main.cpp', '// Break at this line') 13 14 # Create a target by the debugger. 15 target = self.dbg.CreateTarget(exe) 16 self.assertTrue(target, VALID_TARGET) 17 18 # Create the breakpoint inside function 'main'. 19 breakpoint = target.BreakpointCreateByLocation('main.cpp', line) 20 self.assertTrue(breakpoint, VALID_BREAKPOINT) 21 22 # Now launch the process, and do not stop at entry point. 23 process = target.LaunchSimple( 24 None, None, self.get_process_working_directory()) 25 self.assertTrue(process, PROCESS_IS_VALID) 26 27 # Get Frame #0. 28 self.assertState(process.GetState(), lldb.eStateStopped) 29 thread = lldbutil.get_stopped_thread( 30 process, lldb.eStopReasonBreakpoint) 31 self.assertTrue( 32 thread.IsValid(), 33 "There should be a thread stopped due to breakpoint condition") 34 frame0 = thread.GetFrameAtIndex(0) 35 36 # Verify that we can access to a frame variable with an empty class type 37 e = frame0.FindVariable('e') 38 self.assertTrue(e.IsValid(), VALID_VARIABLE) 39 self.DebugSBValue(e) 40 self.assertEqual(e.GetNumChildren(), 0) 41 42 # Verify that we can acces to a frame variable what is a pointer to an 43 # empty class 44 ep = frame0.FindVariable('ep') 45 self.assertTrue(ep.IsValid(), VALID_VARIABLE) 46 self.DebugSBValue(ep) 47 48 # Verify that we can dereference a pointer to an empty class 49 epd = ep.Dereference() 50 self.assertTrue(epd.IsValid(), VALID_VARIABLE) 51 self.DebugSBValue(epd) 52 self.assertEqual(epd.GetNumChildren(), 0) 53 54