]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / static_members / TestCPPStaticMembers.py
1 """
2 Tests that C++ member and static variables have correct layout and scope.
3 """
4
5 from __future__ import print_function
6
7
8 import unittest2
9 import lldb
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
13
14
15 class CPPStaticMembersTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     @unittest2.expectedFailure  # llvm.org/pr15401
20     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
21     def test_with_run_command(self):
22         """Test that member variables have the correct layout, scope and qualifiers when stopped inside and outside C++ methods"""
23         self.build()
24         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
25
26         self.set_breakpoint(line_number('main.cpp', '// breakpoint 1'))
27         self.set_breakpoint(line_number('main.cpp', '// breakpoint 2'))
28
29         self.runCmd("process launch", RUN_SUCCEEDED)
30         self.expect("expression my_a.access()",
31                     startstr="(long) $0 = 10")
32
33         self.expect("expression my_a.m_a",
34                     startstr="(short) $1 = 1")
35
36         # Note: SymbolFileDWARF::ParseChildMembers doesn't call
37         # AddFieldToRecordType, consistent with clang's AST layout.
38         self.expect("expression my_a.s_d",
39                     startstr="(int) $2 = 4")
40
41         self.expect("expression my_a.s_b",
42                     startstr="(long) $3 = 2")
43
44         self.expect("expression A::s_b",
45                     startstr="(long) $4 = 2")
46
47         # should not be available in global scope
48         self.expect("expression s_d",
49                     startstr="error: use of undeclared identifier 's_d'")
50
51         self.runCmd("process continue")
52         self.expect("expression m_c",
53                     startstr="(char) $5 = \'\\x03\'")
54
55         self.expect("expression s_b",
56                     startstr="(long) $6 = 2")
57
58         self.runCmd("process continue")
59
60     def set_breakpoint(self, line):
61         lldbutil.run_break_set_by_file_and_line(
62             self, "main.cpp", line, num_expected_locations=1, loc_exact=False)