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 ObjCDataFormatterCF(ObjCDataFormatterTestCase): 16 17 def test_coreframeworks_and_run_command(self): 18 """Test formatters for Core OSX frameworks.""" 19 self.build() 20 self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( 21 self, '// Set break point at this line.', 22 lldb.SBFileSpec('main.m', False)) 23 24 # The stop reason of the thread should be breakpoint. 25 self.expect( 26 "thread list", 27 STOPPED_DUE_TO_BREAKPOINT, 28 substrs=['stopped', 'stop reason = breakpoint']) 29 30 # check formatters for common Objective-C types 31 expect_strings = [ 32 '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', 33 '(CFGregorianDate) cf_greg_date = @"4/10/1985 18:0:0"', 34 '(CFRange) cf_range = location=4 length=4', 35 '(NSPoint) ns_point = (x = 4, y = 4)', 36 '(NSRange) ns_range = location=4, length=4', 37 '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))', 38 '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...', 39 '(NSSize) ns_size = (width = 5, height = 7)', 40 '(CGSize) cg_size = (width = 1, height = 6)', 41 '(CGPoint) cg_point = (x = 2, y = 7)', 42 '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))', 43 '(Rect) rect = (t=4, l=8, b=4, r=7)', 44 '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', 45 '(Point) point = (v=7, h=12)', '(Point *) point_ptr = (v=7, h=12)', 46 '(SEL) foo_selector = "foo_selector_impl"' 47 ] 48 self.expect("frame variable", substrs=expect_strings) 49 50 if self.getArchitecture() in ['i386', 'x86_64']: 51 extra_string = [ 52 '(RGBColor) rgb_color = red=3 green=56 blue=35', 53 '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35', 54 '(HIPoint) hi_point = (x=7, y=12)', 55 '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)', 56 ] 57 self.expect("frame variable", substrs=extra_string) 58 59 # The original tests left out testing the NSNumber values, so do that here. 60 # This set is all pointers, with summaries, so we only check the summary. 61 var_list_pointer = [ 62 ['NSNumber *', 'num1', '(int)5'], 63 ['NSNumber *', 'num2', '(float)3.140000'], 64 ['NSNumber *', 'num3', '(double)3.14'], 65 ['NSNumber *', 'num4', '(int128_t)18446744073709551614'], 66 ['NSNumber *', 'num5', '(char)65'], 67 ['NSNumber *', 'num6', '(long)255'], 68 ['NSNumber *', 'num7', '(long)2000000'], 69 ['NSNumber *', 'num8_Y', 'YES'], 70 ['NSNumber *', 'num8_N', 'NO'], 71 ['NSNumber *', 'num9', '(short)-31616'], 72 ['NSNumber *', 'num_at1', '(int)12'], 73 ['NSNumber *', 'num_at2', '(int)-12'], 74 ['NSNumber *', 'num_at3', '(double)12.5'], 75 ['NSNumber *', 'num_at4', '(double)-12.5'], 76 ['NSDecimalNumber *', 'decimal_number', '123456 x 10^-10'], 77 ['NSDecimalNumber *', 'decimal_number_neg', '-123456 x 10^10'] 78 ] 79 for type, var_path, summary in var_list_pointer: 80 self.expect_var_path(var_path, summary, None, type) 81 82 83