2 Use lldb Python API to test base class resolution for ObjC classes
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class ObjCDynamicValueTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
18 # Call super's setUp().
21 self.line = line_number('main.m', '// Set breakpoint here.')
24 @add_test_categories(['pyapi'])
25 def test_get_baseclass(self):
26 """Test fetching ObjC dynamic values."""
27 if self.getArchitecture() == 'i386':
28 # rdar://problem/9946499
29 self.skipTest("Dynamic types for ObjC V1 runtime not implemented")
32 exe = self.getBuildArtifact("a.out")
34 # Create a target from the debugger.
36 target = self.dbg.CreateTarget(exe)
37 self.assertTrue(target, VALID_TARGET)
39 # Set up our breakpoints:
41 target.BreakpointCreateByLocation('main.m', self.line)
42 process = target.LaunchSimple(
43 None, None, self.get_process_working_directory())
45 self.assertTrue(process.GetState() == lldb.eStateStopped,
48 var = self.frame().FindVariable("foo")
49 var_ptr_type = var.GetType()
50 var_pte_type = var_ptr_type.GetPointeeType()
52 var_ptr_type.GetNumberOfDirectBaseClasses() == 1,
53 "Foo * has one base class")
55 var_pte_type.GetNumberOfDirectBaseClasses() == 1,
56 "Foo has one base class")
58 self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(
59 0).IsValid(), "Foo * has a valid base class")
60 self.assertTrue(var_pte_type.GetDirectBaseClassAtIndex(
61 0).IsValid(), "Foo * has a valid base class")
63 self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == var_pte_type.GetDirectBaseClassAtIndex(
64 0).GetName(), "Foo and its pointer type don't agree on their base class")