1# encoding: utf-8 2""" 3Test lldb data formatter subsystem. 4""" 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase 13 14 15class ObjCDataFormatterNSPlain(ObjCDataFormatterTestCase): 16 17 @skipUnlessDarwin 18 def test_plain_objc_with_run_command(self): 19 """Test basic ObjC formatting behavior.""" 20 self.build() 21 self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( 22 self, '// Set break point at this line.', 23 lldb.SBFileSpec('main.m', False)) 24 25 # The stop reason of the thread should be breakpoint. 26 self.expect( 27 "thread list", 28 STOPPED_DUE_TO_BREAKPOINT, 29 substrs=['stopped', 'stop reason = breakpoint']) 30 31 # This is the function to remove the custom formats in order to have a 32 # clean slate for the next test case. 33 def cleanup(): 34 self.runCmd('type format clear', check=False) 35 self.runCmd('type summary clear', check=False) 36 self.runCmd('type synth clear', check=False) 37 38 # Execute the cleanup function during test case tear down. 39 self.addTearDownHook(cleanup) 40 41 self.runCmd("type summary add --summary-string \"${var%@}\" MyClass") 42 43 self.expect("frame variable object2", substrs=['MyOtherClass']) 44 45 self.expect("frame variable *object2", substrs=['MyOtherClass']) 46 47 # Now let's delete the 'MyClass' custom summary. 48 self.runCmd("type summary delete MyClass") 49 50 # The type format list should not show 'MyClass' at this point. 51 self.expect("type summary list", matching=False, substrs=['MyClass']) 52 53 self.runCmd("type summary add --summary-string \"a test\" MyClass") 54 55 self.expect( 56 "frame variable *object2", 57 substrs=['*object2 =', 'MyClass = a test', 'backup = ']) 58 59 self.expect( 60 "frame variable object2", matching=False, substrs=['a test']) 61 62 self.expect("frame variable object", substrs=['a test']) 63 64 self.expect("frame variable *object", substrs=['a test']) 65 66 self.expect( 67 'frame variable myclass', substrs=['(Class) myclass = NSValue']) 68 self.expect( 69 'frame variable myclass2', 70 substrs=['(Class) myclass2 = ', 'NS', 'String']) 71 self.expect( 72 'frame variable myclass3', substrs=['(Class) myclass3 = Molecule']) 73 self.expect( 74 'frame variable myclass4', 75 substrs=['(Class) myclass4 = NSMutableArray']) 76 self.expect( 77 'frame variable myclass5', substrs=['(Class) myclass5 = nil']) 78