1""" 2Test calling std::String member functions. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class ExprCommandCallFunctionTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # Find the line number to break for main.c. 21 self.line = line_number( 22 'main.cpp', 23 '// Please test these expressions while stopped at this line:') 24 25 @expectedFailureAll( 26 compiler="icc", 27 bugnumber="llvm.org/pr14437, fails with ICC 13.1") 28 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") 29 def test_with(self): 30 """Test calling std::String member function.""" 31 self.build() 32 self.runCmd("file " + self.getBuildArtifact("a.out"), 33 CURRENT_EXECUTABLE_SET) 34 35 # Some versions of GCC encode two locations for the 'return' statement 36 # in main.cpp 37 lldbutil.run_break_set_by_file_and_line( 38 self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) 39 40 self.runCmd("run", RUN_SUCCEEDED) 41 42 self.expect("print str", 43 substrs=['Hello world']) 44 45 # Calling this function now succeeds, but we follow the typedef return type through to 46 # const char *, and thus don't invoke the Summary formatter. 47 48 # clang's libstdc++ on ios arm64 inlines std::string::c_str() always; 49 # skip this part of the test. 50 triple = self.dbg.GetSelectedPlatform().GetTriple() 51 do_cstr_test = True 52 if triple in ["arm64-apple-ios", "arm64e-apple-ios", "arm64-apple-tvos", "armv7k-apple-watchos", "arm64-apple-bridgeos", "arm64_32-apple-watchos"]: 53 do_cstr_test = False 54 if do_cstr_test: 55 self.expect("print str.c_str()", 56 substrs=['Hello world']) 57