1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
"""
Test lldb data formatter subsystem.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestDataFormatterStdTuple(TestBase):
TEST_WITH_PDB_DEBUG_INFO = True
def setUp(self):
TestBase.setUp(self)
self.line = line_number("main.cpp", "// break here")
self.namespace = "std"
def do_test(self):
"""Test that std::tuple is displayed correctly"""
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.cpp", False)
)
tuple_name = self.namespace + "::tuple"
self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"])
self.expect(
"frame variable one_elt",
substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"],
)
self.expect(
"frame variable three_elts",
substrs=[
tuple_name,
"size=3",
"{",
"[0] = 1",
"[1] = 47",
'[2] = "foo"',
"}",
],
)
frame = self.frame()
self.assertTrue(frame.IsValid())
self.assertEqual(
47, frame.GetValueForVariablePath("one_elt[0]").GetValueAsUnsigned()
)
self.assertFalse(frame.GetValueForVariablePath("one_elt[1]").IsValid())
self.assertEqual(
'"foobar"', frame.GetValueForVariablePath("string_elt[0]").GetSummary()
)
self.assertFalse(frame.GetValueForVariablePath("string_elt[1]").IsValid())
self.assertEqual(
1, frame.GetValueForVariablePath("three_elts[0]").GetValueAsUnsigned()
)
self.assertEqual(
47, frame.GetValueForVariablePath("three_elts[1]").GetValueAsUnsigned()
)
self.assertEqual(
'"foo"', frame.GetValueForVariablePath("three_elts[2]").GetSummary()
)
self.assertFalse(frame.GetValueForVariablePath("three_elts[3]").IsValid())
@add_test_categories(["libc++"])
def test_libcxx(self):
self.build(dictionary={"USE_LIBCPP": 1})
self.do_test()
@add_test_categories(["libstdcxx"])
def test_libstdcxx(self):
self.build(dictionary={"USE_LIBSTDCPP": 1})
self.do_test()
@add_test_categories(["msvcstl"])
def test_msvcstl(self):
# No flags, because the "msvcstl" category checks that the MSVC STL is used by default.
self.build()
self.do_test()
|