8f974f03838942a5a71a532ffe2947e0fe26974a
[openbsd] /
1 """
2 Use lldb Python API to test base class resolution for ObjC classes
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class ObjCDynamicValueTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         # Call super's setUp().
19         TestBase.setUp(self)
20
21         self.line = line_number('main.m', '// Set breakpoint here.')
22
23     @skipUnlessDarwin
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")
30
31         self.build()
32         exe = self.getBuildArtifact("a.out")
33
34         # Create a target from the debugger.
35
36         target = self.dbg.CreateTarget(exe)
37         self.assertTrue(target, VALID_TARGET)
38
39         # Set up our breakpoints:
40
41         target.BreakpointCreateByLocation('main.m', self.line)
42         process = target.LaunchSimple(
43             None, None, self.get_process_working_directory())
44
45         self.assertTrue(process.GetState() == lldb.eStateStopped,
46                         PROCESS_STOPPED)
47
48         var = self.frame().FindVariable("foo")
49         var_ptr_type = var.GetType()
50         var_pte_type = var_ptr_type.GetPointeeType()
51         self.assertTrue(
52             var_ptr_type.GetNumberOfDirectBaseClasses() == 1,
53             "Foo * has one base class")
54         self.assertTrue(
55             var_pte_type.GetNumberOfDirectBaseClasses() == 1,
56             "Foo has one base class")
57
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")
62
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")