~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to lldb/test/lang/c/anonymous/TestAnonymous.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    mydir = os.path.join("lang", "c", "anonymous")
12
12
 
13
13
    @dsym_test
14
 
    def test_expr_with_dsym(self):
15
 
        self.buildDsym()
16
 
        self.expr()
17
 
 
18
 
    @skipIfGcc # llvm.org/pr15036: LLDB is unable to parse DWARF generated by GCC
 
14
    def test_expr_nest_with_dsym(self):
 
15
        self.buildDsym()
 
16
        self.expr_nest()
 
17
 
 
18
    @dsym_test
 
19
    def test_expr_child_with_dsym(self):
 
20
        self.buildDsym()
 
21
        self.expr_child()
 
22
 
 
23
    @dsym_test
 
24
    def test_expr_grandchild_with_dsym(self):
 
25
        self.buildDsym()
 
26
        self.expr_grandchild()
 
27
 
 
28
    @dsym_test
 
29
    def test_expr_parent(self):
 
30
        self.buildDsym()
 
31
        self.expr_parent()
 
32
 
 
33
    @unittest2.expectedFailure # llvm.org/pr15591 
 
34
    @dsym_test
 
35
    def test_expr_null(self):
 
36
        self.buildDsym()
 
37
        self.expr_null()
 
38
 
 
39
    @skipIfGcc # llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by GCC
19
40
    @skipIfIcc # llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by ICC
20
41
    @dwarf_test
21
 
    def test_expr_with_dwarf(self):
22
 
        self.buildDwarf()
23
 
        self.expr()
 
42
    def test_expr_nest_with_dwarf(self):
 
43
        self.buildDwarf()
 
44
        self.expr_nest()
 
45
 
 
46
    @dwarf_test
 
47
    def test_expr_child_with_dwarf(self):
 
48
        self.skipTest("Skipped because LLDB asserts due to an incorrect AST layout for an anonymous struct: see llvm.org/pr15036")
 
49
        self.buildDwarf()
 
50
        self.expr_child()
 
51
 
 
52
    @skipIfGcc # llvm.org/pr15036: This particular regression was introduced by r181498
 
53
    @skipIfIcc # llvm.org/pr15036: This particular regression was introduced by r181498
 
54
    @dwarf_test
 
55
    def test_expr_grandchild_with_dwarf(self):
 
56
        self.buildDwarf()
 
57
        self.expr_grandchild()
 
58
 
 
59
    @dwarf_test
 
60
    def test_expr_parent(self):
 
61
        self.buildDwarf()
 
62
        self.expr_parent()
 
63
 
 
64
    @unittest2.expectedFailure # llvm.org/pr15591 
 
65
    @dwarf_test
 
66
    def test_expr_null(self):
 
67
        self.buildDwarf()
 
68
        self.expr_null()
24
69
 
25
70
    def setUp(self):
26
71
        # Call super's setUp().
27
72
        TestBase.setUp(self)
28
 
        # Find the line number to break inside main().
29
 
        self.line = line_number('main.c', '// Set breakpoint 0 here.')
 
73
        # Find the line numbers to break in main.c.
 
74
        self.line0 = line_number('main.c', '// Set breakpoint 0 here.')
 
75
        self.line1 = line_number('main.c', '// Set breakpoint 1 here.')
 
76
        self.line2 = line_number('main.c', '// Set breakpoint 2 here.')
30
77
 
31
 
    def common_setup(self):
 
78
    def common_setup(self, line):
32
79
        exe = os.path.join(os.getcwd(), "a.out")
33
80
        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
34
81
 
35
 
        # Break inside the foo function which takes a bar_ptr argument.
36
 
        lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
 
82
        # Set breakpoints inside and outside methods that take pointers to the containing struct.
 
83
        lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)
37
84
 
38
85
        self.runCmd("run", RUN_SUCCEEDED)
39
86
 
46
93
        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
47
94
            substrs = [' resolved, hit count = 1'])
48
95
 
49
 
    def expr(self):
50
 
        self.common_setup()
51
 
 
52
 
        # This should display correctly.
 
96
    def expr_nest(self):
 
97
        self.common_setup(self.line0)
 
98
 
 
99
        # These should display correctly.
 
100
        self.expect("expression n->foo.d", VARIABLES_DISPLAYED_CORRECTLY,
 
101
            substrs = ["= 4"])
 
102
            
 
103
        self.expect("expression n->b", VARIABLES_DISPLAYED_CORRECTLY,
 
104
            substrs = ["= 2"])
 
105
 
 
106
    def expr_child(self):
 
107
        self.common_setup(self.line1)
 
108
 
 
109
        # These should display correctly.
53
110
        self.expect("expression c->foo.d", VARIABLES_DISPLAYED_CORRECTLY,
54
111
            substrs = ["= 4"])
55
112
            
56
 
        self.expect("expression c->b", VARIABLES_DISPLAYED_CORRECTLY,
57
 
            substrs = ["= 2"])
 
113
        self.expect("expression c->grandchild.b", VARIABLES_DISPLAYED_CORRECTLY,
 
114
            substrs = ["= 2"])
 
115
 
 
116
    def expr_grandchild(self):
 
117
        self.common_setup(self.line2)
 
118
 
 
119
        # These should display correctly.
 
120
        self.expect("expression g.child.foo.d", VARIABLES_DISPLAYED_CORRECTLY,
 
121
            substrs = ["= 4"])
 
122
            
 
123
        self.expect("expression g.child.b", VARIABLES_DISPLAYED_CORRECTLY,
 
124
            substrs = ["= 2"])
 
125
 
 
126
    def expr_parent(self):
 
127
        self.common_setup(self.line2)
 
128
 
 
129
        # These should display correctly.
 
130
        self.expect("expression pz", VARIABLES_DISPLAYED_CORRECTLY,
 
131
            substrs = ["(type_z *) $0 = 0x0000"])
 
132
 
 
133
        self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
 
134
            substrs = ["(type_y) $1 = {"])
 
135
 
 
136
        self.expect("expression z", VARIABLES_DISPLAYED_CORRECTLY,
 
137
            substrs = ["dummy = 2"])
 
138
 
 
139
    def expr_null(self):
 
140
        self.common_setup(self.line2)
 
141
 
 
142
        # This should fail because pz is 0, but it succeeds on OS/X.
 
143
        # This fails on Linux with an upstream error "Couldn't dematerialize struct", as does "p *n" with "int *n = 0".
 
144
        # Note that this can also trigger llvm.org/pr15036 when run interactively at the lldb command prompt.
 
145
        self.expect("expression *(type_z *)pz",
 
146
            substrs = ["Cannot access memory at address 0x0"], error = True)
 
147
 
58
148
 
59
149
if __name__ == '__main__':
60
150
    import atexit