1""" 2Test that we do not attempt to make a dynamic type for a 'const char*' 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class Rdar10967107TestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # We'll use the test method name as the exe_name. 21 self.exe_name = self.testMethodName 22 # Find the line number to break inside main(). 23 self.main_source = "main.m" 24 self.line = line_number(self.main_source, '// Set breakpoint here.') 25 26 def test_charstar_dyntype(self): 27 """Test that we do not attempt to make a dynamic type for a 'const char*'""" 28 d = {'EXE': self.exe_name} 29 self.build(dictionary=d) 30 self.setTearDownCleanup(dictionary=d) 31 32 exe = self.getBuildArtifact(self.exe_name) 33 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 34 35 lldbutil.run_break_set_by_file_and_line( 36 self, 37 self.main_source, 38 self.line, 39 num_expected_locations=1, 40 loc_exact=True) 41 42 self.runCmd("run", RUN_SUCCEEDED) 43 # check that we correctly see the const char*, even with dynamic types 44 # on 45 self.expect("frame variable -raw-output my_string", substrs=['const char *']) 46 self.expect( 47 "frame variable my_string --raw-output --dynamic-type run-target", 48 substrs=['const char *']) 49 # check that expr also gets it right 50 self.expect("e -R -- my_string", substrs=['const char *']) 51 self.expect("expr -R -d run -- my_string", substrs=['const char *']) 52 # but check that we get the real Foolie as such 53 self.expect("frame variable my_foolie", substrs=['FoolMeOnce *']) 54 self.expect( 55 "frame variable my_foolie --dynamic-type run-target", 56 substrs=['FoolMeOnce *']) 57 # check that expr also gets it right 58 self.expect("expr my_foolie", substrs=['FoolMeOnce *']) 59 self.expect("expr -d run -- my_foolie", substrs=['FoolMeOnce *']) 60 # now check that assigning a true string does not break anything 61 self.runCmd("next") 62 # check that we correctly see the const char*, even with dynamic types 63 # on 64 self.expect("frame variable my_string", substrs=['const char *']) 65 self.expect( 66 "frame variable my_string --dynamic-type run-target", 67 substrs=['const char *']) 68 # check that expr also gets it right 69 self.expect("expr my_string", substrs=['const char *']) 70 self.expect("expr -d run -- my_string", substrs=['const char *']) 71 # but check that we get the real Foolie as such 72 self.expect("frame variable my_foolie", substrs=['FoolMeOnce *']) 73 self.expect( 74 "frame variable my_foolie --dynamic-type run-target", 75 substrs=['FoolMeOnce *']) 76 # check that expr also gets it right 77 self.expect("expr my_foolie", substrs=['FoolMeOnce *']) 78 self.expect("expr -d run -- my_foolie", substrs=['FoolMeOnce *']) 79