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