1""" 2Test basic std::vector functionality but with a declaration from 3the debug info (the Foo struct) as content. 4""" 5 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class TestDbgInfoContentVector(TestBase): 12 13 @add_test_categories(["libc++"]) 14 @skipIf(compiler=no_match("clang")) 15 def test(self): 16 self.build() 17 18 lldbutil.run_to_source_breakpoint(self, 19 "// Set break point at this line.", 20 lldb.SBFileSpec("main.cpp")) 21 22 self.runCmd("settings set target.import-std-module true") 23 24 vector_type = "std::vector<Foo>" 25 size_type = vector_type + "::size_type" 26 value_type = vector_type + "::value_type" 27 iterator = vector_type + "::iterator" 28 # LLDB's formatter provides us with a artificial 'item' member. 29 iterator_children = [ValueCheck(name="item")] 30 riterator = vector_type + "::reverse_iterator" 31 riterator_children = [ 32 ValueCheck(name="__t"), 33 ValueCheck(name="current") 34 ] 35 36 self.expect_expr("a", 37 result_type=vector_type, 38 result_children=[ 39 ValueCheck(children=[ValueCheck(value="3")]), 40 ValueCheck(children=[ValueCheck(value="1")]), 41 ValueCheck(children=[ValueCheck(value="2")]), 42 ]) 43 44 self.expect_expr("a.size()", result_type=size_type, result_value="3") 45 self.expect_expr("a.front().a", result_type="int", result_value="3") 46 self.expect_expr("a[1].a", result_type="int", result_value="1") 47 self.expect_expr("a.back().a", result_type="int", result_value="2") 48 49 self.expect("expr std::reverse(a.begin(), a.end())") 50 self.expect_expr("a.front().a", result_type="int", result_value="2") 51 52 self.expect_expr("a.begin()->a", result_type="int", result_value="2") 53 self.expect_expr("a.rbegin()->a", result_type="int", result_value="3") 54 55 self.expect("expr a.pop_back()") 56 self.expect_expr("a.back().a", result_type="int", result_value="1") 57 self.expect_expr("a.size()", result_type=size_type, result_value="2") 58 59 self.expect_expr("a.at(0).a", result_type="int", result_value="2") 60 61 self.expect("expr a.push_back({4})") 62 self.expect_expr("a.back().a", result_type="int", result_value="4") 63 self.expect_expr("a.size()", result_type=size_type, result_value="3") 64 65 self.expect_expr("a.begin()", 66 result_type=iterator, 67 result_children=iterator_children) 68 self.expect_expr("a.rbegin()", 69 result_type=riterator, 70 result_children=riterator_children) 71