3 Test lldb data formatter subsystem.
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class NSStringDataFormatterTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
18 def appkit_tester_impl(self, commands):
20 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
22 lldbutil.run_break_set_by_file_and_line(
23 self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
25 self.runCmd("run", RUN_SUCCEEDED)
27 # The stop reason of the thread should be breakpoint.
28 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
30 'stop reason = breakpoint'])
32 # This is the function to remove the custom formats in order to have a
33 # clean slate for the next test case.
35 self.runCmd('type format clear', check=False)
36 self.runCmd('type summary clear', check=False)
37 self.runCmd('type synth clear', check=False)
39 # Execute the cleanup function during test case tear down.
40 self.addTearDownHook(cleanup)
45 def test_nsstring_with_run_command(self):
46 """Test formatters for NSString."""
47 self.appkit_tester_impl(self.nsstring_data_formatter_commands)
51 def test_rdar11106605_with_run_command(self):
52 """Check that Unicode characters come out of CFString summary correctly."""
53 self.appkit_tester_impl(self.rdar11106605_commands)
57 def test_nsstring_withNULS_with_run_command(self):
58 """Test formatters for NSString."""
59 self.appkit_tester_impl(self.nsstring_withNULs_commands)
62 # Call super's setUp().
64 # Find the line number to break at.
65 self.line = line_number('main.m', '// break here')
67 def rdar11106605_commands(self):
68 """Check that Unicode characters come out of CFString summary correctly."""
69 self.expect('frame variable italian', substrs=[
70 'L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.'])
71 self.expect('frame variable french', substrs=[
72 'Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?'])
73 self.expect('frame variable german', substrs=[
74 'Über-Ich und aus den Ansprüchen der sozialen Umwelt'])
75 self.expect('frame variable japanese', substrs=['色は匂へど散りぬるを'])
76 self.expect('frame variable hebrew', substrs=['לילה טוב'])
78 def nsstring_data_formatter_commands(self):
79 self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
80 substrs=['(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"',
81 # '(NSString *) str0 = ',' @"255"',
82 '(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"',
83 '(NSString *) str2 = ', ' @"A rather short UTF8 NSString object is here"',
84 '(NSString *) str3 = ', ' @"A string made with the at sign is here"',
85 '(NSString *) str4 = ', ' @"This is string number 4 right here"',
86 '(NSString *) str5 = ', ' @"{{1, 1}, {5, 5}}"',
87 '(NSString *) str6 = ', ' @"1ST"',
88 '(NSString *) str8 = ', ' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime',
89 '(NSString *) str9 = ', ' @"a very much boring task to write a string this way!!',
90 '(NSString *) str10 = ', ' @"This is a Unicode string σ number 4 right here"',
91 '(NSString *) str11 = ', ' @"__NSCFString"',
92 '(NSString *) label1 = ', ' @"Process Name: "',
93 '(NSString *) label2 = ', ' @"Process Id: "',
94 '(NSString *) str12 = ', ' @"Process Name: a.out Process Id:'])
96 'frame variable attrString mutableAttrString mutableGetConst',
98 '(NSAttributedString *) attrString = ',
99 ' @"hello world from foo"',
100 '(NSAttributedString *) mutableAttrString = ',
101 ' @"hello world from foo"',
102 '(NSString *) mutableGetConst = ',
103 ' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"'])
105 self.expect('expr -d run-target -- path', substrs=['usr/blah/stuff'])
106 self.expect('frame variable path', substrs=['usr/blah/stuff'])
108 def nsstring_withNULs_commands(self):
109 """Check that the NSString formatter supports embedded NULs in the text"""
112 substrs=['a very much boring task to write'])
113 self.expect('expr [strwithNULs length]', substrs=['54'])
114 self.expect('frame variable strwithNULs', substrs=[
115 '@"a very much boring task to write\\0a string this way!!'])
116 self.expect('po strwithNULs2', substrs=[
117 'a very much boring task to write'])
118 self.expect('expr [strwithNULs2 length]', substrs=['52'])
119 self.expect('frame variable strwithNULs2', substrs=[
120 '@"a very much boring task to write\\0a string this way!!'])