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