From 78b9749c0a4ea980a8b934645da6ae98fcc665e8 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 6 Jan 2016 20:12:03 +0000 Subject: Vendor import of lldb trunk r256945: https://llvm.org/svn/llvm-project/lldb/trunk@256945 --- .../data-formatter/data-formatter-objc/.categories | 1 + .../data-formatter/data-formatter-objc/Makefile | 9 + .../data-formatter-objc/TestDataFormatterObjC.py | 464 ++++++++++++++ .../data-formatter/data-formatter-objc/main.m | 694 +++++++++++++++++++++ .../data-formatter-objc/nsstring/Makefile | 9 + .../nsstring/TestDataFormatterNSString.py | 107 ++++ .../data-formatter-objc/nsstring/main.m | 99 +++ 7 files changed, 1383 insertions(+) create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m (limited to 'packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc') diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories new file mode 100644 index 0000000..6326dbc --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories @@ -0,0 +1 @@ +dataformatters,objc diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile new file mode 100644 index 0000000..9f7fb1c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile @@ -0,0 +1,9 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m + +CFLAGS_EXTRAS += -w + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py new file mode 100644 index 0000000..e12ddca --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -0,0 +1,464 @@ +# encoding: utf-8 +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +import datetime +import lldbsuite.test.lldbutil as lldbutil + +class ObjCDataFormatterTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test_plain_objc_with_run_command(self): + """Test basic ObjC formatting behavior.""" + self.build() + self.plain_data_formatter_commands() + + def appkit_tester_impl(self,commands): + self.build() + self.appkit_common_data_formatters_command() + commands() + + @skipUnlessDarwin + def test_nsnumber_with_run_command(self): + """Test formatters for NSNumber.""" + self.appkit_tester_impl(self.nsnumber_data_formatter_commands) + + @skipUnlessDarwin + def test_nscontainers_with_run_command(self): + """Test formatters for NS container classes.""" + self.appkit_tester_impl(self.nscontainers_data_formatter_commands) + + @skipUnlessDarwin + def test_nsdata_with_run_command(self): + """Test formatters for NSData.""" + self.appkit_tester_impl(self.nsdata_data_formatter_commands) + + @skipUnlessDarwin + def test_nsurl_with_run_command(self): + """Test formatters for NSURL.""" + self.appkit_tester_impl(self.nsurl_data_formatter_commands) + + + @skipUnlessDarwin + def test_nserror_with_run_command(self): + """Test formatters for NSError.""" + self.appkit_tester_impl(self.nserror_data_formatter_commands) + + + @skipUnlessDarwin + def test_nsbundle_with_run_command(self): + """Test formatters for NSBundle.""" + self.appkit_tester_impl(self.nsbundle_data_formatter_commands) + + + @skipUnlessDarwin + def test_nsexception_with_run_command(self): + """Test formatters for NSException.""" + self.appkit_tester_impl(self.nsexception_data_formatter_commands) + + @skipUnlessDarwin + def test_nsmisc_with_run_command(self): + """Test formatters for misc NS classes.""" + self.appkit_tester_impl(self.nsmisc_data_formatter_commands) + + + @skipUnlessDarwin + def test_nsdate_with_run_command(self): + """Test formatters for NSDate.""" + self.appkit_tester_impl(self.nsdate_data_formatter_commands) + + @skipUnlessDarwin + def test_coreframeworks_and_run_command(self): + """Test formatters for Core OSX frameworks.""" + self.build() + self.cf_data_formatter_commands() + + @skipUnlessDarwin + def test_kvo_with_run_command(self): + """Test the behavior of formatters when KVO is in use.""" + self.build() + self.kvo_data_formatter_commands() + + @skipUnlessDarwin + def test_expr_with_run_command(self): + """Test common cases of expression parser <--> formatters interaction.""" + self.build() + self.expr_objc_data_formatter_commands() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.m', '// Set break point at this line.') + + def plain_data_formatter_commands(self): + """Test basic ObjC formatting behavior.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("type summary add --summary-string \"${var%@}\" MyClass") + + self.expect("frame variable object2", + substrs = ['MyOtherClass']); + + self.expect("frame variable *object2", + substrs = ['MyOtherClass']); + + # Now let's delete the 'MyClass' custom summary. + self.runCmd("type summary delete MyClass") + + # The type format list should not show 'MyClass' at this point. + self.expect("type summary list", matching=False, + substrs = ['MyClass']) + + self.runCmd("type summary add --summary-string \"a test\" MyClass") + + self.expect("frame variable *object2", + substrs = ['*object2 =', + 'MyClass = a test', + 'backup = ']); + + self.expect("frame variable object2", matching=False, + substrs = ['a test']); + + self.expect("frame variable object", + substrs = ['a test']); + + self.expect("frame variable *object", + substrs = ['a test']); + + self.expect('frame variable myclass', + substrs = ['(Class) myclass = NSValue']) + self.expect('frame variable myclass2', + substrs = ['(Class) myclass2 = ','NS','String']) + self.expect('frame variable myclass3', + substrs = ['(Class) myclass3 = Molecule']) + self.expect('frame variable myclass4', + substrs = ['(Class) myclass4 = NSMutableArray']) + self.expect('frame variable myclass5', + substrs = ['(Class) myclass5 = nil']) + + def appkit_common_data_formatters_command(self): + """Test formatters for AppKit classes.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + def nsnumber_data_formatter_commands(self): + # Now enable AppKit and check we are displaying Cocoa classes correctly + self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num8_Y num8_N num9', + substrs = ['(NSNumber *) num1 = ',' (int)5', + '(NSNumber *) num2 = ',' (float)3.1', + '(NSNumber *) num3 = ',' (double)3.14', + '(NSNumber *) num4 = ',' (long)-2', + '(NSNumber *) num5 = ',' (char)65', + '(NSNumber *) num6 = ',' (long)255', + '(NSNumber *) num7 = ','2000000', + '(NSNumber *) num8_Y = ',' @"1"', + '(NSNumber *) num8_N = ',' @"0"', + '(NSNumber *) num9 = ',' (short)-31616']) + + self.expect('frame variable decimal_one', + substrs = ['(NSDecimalNumber *) decimal_one = 0x','1']) + + self.expect('frame variable num_at1 num_at2 num_at3 num_at4', + substrs = ['(NSNumber *) num_at1 = ',' (int)12', + '(NSNumber *) num_at2 = ',' (int)-12', + '(NSNumber *) num_at3 = ',' (double)12.5', + '(NSNumber *) num_at4 = ',' (double)-12.5']) + + def nscontainers_data_formatter_commands(self): + self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref', + substrs = ['(NSArray *) newArray = ','@"50 elements"', + '(NSDictionary *) newDictionary = ',' 12 key/value pairs', + '(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs', + '(CFDictionaryRef) cfdict_ref = ','3 key/value pairs', + '(CFMutableDictionaryRef) mutable_dict_ref = ','12 key/value pairs', + '(CFArrayRef) cfarray_ref = ','@"3 elements"', + '(CFMutableArrayRef) mutable_array_ref = ','@"11 elements"']) + + self.expect('frame variable nscounted_set', + substrs = ['(NSCountedSet *) nscounted_set = ','5 elements']) + + self.expect('frame variable iset1 iset2 imset', + substrs = ['4 indexes','512 indexes','10 indexes']) + + self.expect('frame variable mutable_bag_ref cfbag_ref binheap_ref', + substrs = ['(CFMutableBagRef) mutable_bag_ref = ','@"17 values"', + '(CFBagRef) cfbag_ref = ','@"15 values"', + '(CFBinaryHeapRef) binheap_ref = ','@"21 items"']) + + self.expect('expression -d run -- [NSArray new]', substrs=['@"0 elements"']) + + def nsdata_data_formatter_commands(self): + self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', + substrs = ['(NSData *) immutableData = ',' 4 bytes', + '(NSData *) mutableData = ',' 14 bytes', + '(CFDataRef) data_ref = ','@"5 bytes"', + '(CFMutableDataRef) mutable_data_ref = ','@"5 bytes"', + '(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"']) + + def nsurl_data_formatter_commands(self): + self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref', + substrs = ['(CFURLRef) cfurl_ref = ','@"http://www.foo.bar', + 'cfchildurl_ref = ','@"page.html -- http://www.foo.bar', + '(CFURLRef) cfgchildurl_ref = ','@"?whatever -- http://www.foo.bar/page.html"']) + + self.expect('frame variable nsurl nsurl2 nsurl3', + substrs = ['(NSURL *) nsurl = ','@"http://www.foo.bar', + '(NSURL *) nsurl2 =','@"page.html -- http://www.foo.bar', + '(NSURL *) nsurl3 = ','@"?whatever -- http://www.foo.bar/page.html"']) + + def nserror_data_formatter_commands(self): + self.expect('frame variable nserror', + substrs = ['domain: @"Foobar" - code: 12']) + + self.expect('frame variable nserror->_userInfo', + substrs = ['2 key/value pairs']) + + self.expect('frame variable nserror->_userInfo --ptr-depth 1 -d run-target', + substrs = ['@"a"','@"b"',"1","2"]) + + def nsbundle_data_formatter_commands(self): + self.expect('frame variable bundle_string bundle_url main_bundle', + substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"', + '(NSBundle *) bundle_url = ',' @"/System/Library/Frameworks/Cocoa.framework"', + '(NSBundle *) main_bundle = ','data-formatter-objc']) + + def nsexception_data_formatter_commands(self): + self.expect('frame variable except0 except1 except2 except3', + substrs = ['(NSException *) except0 = ','name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"', + '(NSException *) except1 = ','name:@"TheGuyWhoHasNoName~1" reason:@"cuz it\'s funny"', + '(NSException *) except2 = ','name:@"TheGuyWhoHasNoName`2" reason:@"cuz it\'s funny"', + '(NSException *) except3 = ','name:@"TheGuyWhoHasNoName/3" reason:@"cuz it\'s funny"']) + + def nsmisc_data_formatter_commands(self): + self.expect('frame variable localhost', + substrs = [' localhost ((','"127.0.0.1"']) + + if self.getArchitecture() in ['i386', 'x86_64']: + self.expect('frame variable my_task', + substrs = [' formatters interaction.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + # check that the formatters are able to deal safely and correctly + # with ValueObjects that the expression parser returns + self.expect('expression ((id)@"Hello for long enough to avoid short string types")', matching=False, + substrs = ['Hello for long enough to avoid short string types']) + + self.expect('expression -d run -- ((id)@"Hello for long enough to avoid short string types")', + substrs = ['Hello for long enough to avoid short string types']) + + self.expect('expr -d run -- label1', + substrs = ['Process Name']) + + self.expect('expr -d run -- @"Hello for long enough to avoid short string types"', + substrs = ['Hello for long enough to avoid short string types']) + + self.expect('expr -d run --object-description -- @"Hello for long enough to avoid short string types"', + substrs = ['Hello for long enough to avoid short string types']) + self.expect('expr -d run --object-description -- @"Hello"', matching=False, + substrs = ['@"Hello" Hello']) + + + def cf_data_formatter_commands(self): + """Test formatters for Core OSX frameworks.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + self.runCmd('log timers disable', check=False) + + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + # check formatters for common Objective-C types + expect_strings = ['(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', + '(CFRange) cf_range = location=4 length=4', + '(NSPoint) ns_point = (x = 4, y = 4)', + '(NSRange) ns_range = location=4, length=4', + '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))', + '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...', + '(NSSize) ns_size = (width = 5, height = 7)', + '(CGSize) cg_size = (width = 1, height = 6)', + '(CGPoint) cg_point = (x = 2, y = 7)', + '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))', + '(Rect) rect = (t=4, l=8, b=4, r=7)', + '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', + '(Point) point = (v=7, h=12)', + '(Point *) point_ptr = (v=7, h=12)', + 'name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"', + '1985', + 'foo_selector_impl']; + + if self.getArchitecture() in ['i386', 'x86_64']: + expect_strings.append('(HIPoint) hi_point = (x=7, y=12)') + expect_strings.append('(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)') + expect_strings.append('(RGBColor) rgb_color = red=3 green=56 blue=35') + expect_strings.append('(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35') + + self.expect("frame variable", + substrs = expect_strings) + + + def kvo_data_formatter_commands(self): + """Test the behavior of formatters when KVO is in use.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + # as long as KVO is implemented by subclassing, this test should succeed + # we should be able to dynamically figure out that the KVO implementor class + # is a subclass of Molecule, and use the appropriate summary for it + self.runCmd("type summary add -s JustAMoleculeHere Molecule") + self.expect('frame variable molecule', substrs = ['JustAMoleculeHere']) + self.runCmd("next") + self.expect("thread list", + substrs = ['stopped', + 'step over']) + self.expect('frame variable molecule', substrs = ['JustAMoleculeHere']) + + self.runCmd("next") + # check that NSMutableDictionary's formatter is not confused when dealing with a KVO'd dictionary + self.expect('frame variable newMutableDictionary', substrs = ['(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs']) + + lldbutil.run_break_set_by_regexp (self, 'setAtoms') + + self.runCmd("continue") + self.expect("frame variable _cmd",substrs = ['setAtoms:']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m new file mode 100644 index 0000000..6eb7e02 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m @@ -0,0 +1,694 @@ +//===-- main.m ------------------------------------------------*- ObjC -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import + +#if defined(__APPLE__) +#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) +#define IOS +#endif +#endif + +#if defined(IOS) +#import +#else +#import +#endif + +@interface MyClass : NSObject +{ + int i; + char c; + float f; +} + +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z; +- (int)doIncrementByInt: (int)x; + +@end + +@interface MyOtherClass : MyClass +{ + int i2; + MyClass *backup; +} +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q; + +@end + +@implementation MyClass + +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z +{ + self = [super init]; + if (self) { + self->i = x; + self->f = y; + self->c = z; + } + return self; +} + +- (int)doIncrementByInt: (int)x +{ + self->i += x; + return self->i; +} + +@end + +@implementation MyOtherClass + +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q +{ + self = [super initWithInt:x andFloat:y andChar:z]; + if (self) { + self->i2 = q; + self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z]; + } + return self; +} + +@end + +@interface Atom : NSObject { + float mass; +} +-(void)setMass:(float)newMass; +-(float)mass; +@end + +@interface Molecule : NSObject { + NSArray *atoms; +} +-(void)setAtoms:(NSArray *)newAtoms; +-(NSArray *)atoms; +@end + +@implementation Atom + +-(void)setMass:(float)newMass +{ + mass = newMass; +} +-(float)mass +{ + return mass; +} + +@end + +@implementation Molecule + +-(void)setAtoms:(NSArray *)newAtoms +{ + atoms = newAtoms; +} +-(NSArray *)atoms +{ + return atoms; +} +@end + +@interface My_KVO_Observer : NSObject +-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change + context:(void *)context; +- (id) init; +- (void) dealloc; +@end + +@implementation My_KVO_Observer +-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change + context:(void *)context { + // we do not really care about KVO'ing - do nothing + return; +} +- (id) init +{ + self = [super init]; + return self; +} + +- (void) dealloc +{ + [super dealloc]; +} +@end + +int main (int argc, const char * argv[]) +{ + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar: 'E']; + + [object doIncrementByInt:3]; + + MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2 andFloat:6.28 andChar: 'G' andOtherInt:-1]; + + [object2 doIncrementByInt:3]; + + NSNumber* num1 = [NSNumber numberWithInt:5]; + NSNumber* num2 = [NSNumber numberWithFloat:3.14]; + NSNumber* num3 = [NSNumber numberWithDouble:3.14]; + NSNumber* num4 = [NSNumber numberWithUnsignedLongLong:0xFFFFFFFFFFFFFFFE]; + NSNumber* num5 = [NSNumber numberWithChar:'A']; + NSNumber* num6 = [NSNumber numberWithUnsignedLongLong:0xFF]; + NSNumber* num7 = [NSNumber numberWithLong:0x1E8480]; + NSNumber* num8_Y = [NSNumber numberWithBool:YES]; + NSNumber* num8_N = [NSNumber numberWithBool:NO]; + NSNumber* num9 = [NSNumber numberWithShort:0x1E8480]; + NSNumber* num_at1 = @12; + NSNumber* num_at2 = @-12; + NSNumber* num_at3 = @12.5; + NSNumber* num_at4 = @-12.5; + + NSDecimalNumber* decimal_one = [NSDecimalNumber one]; + + NSString *str0 = [num6 stringValue]; + + NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; + + NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; + + NSString *str3 = @"A string made with the at sign is here"; + + NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; + + NSRect ns_rect_4str = {{1,1},{5,5}}; + + NSString* str5 = NSStringFromRect(ns_rect_4str); + + NSString* str6 = [@"/usr/doc/README.1ST" pathExtension]; + + const unichar myCharacters[] = {0x03C3,'x','x'}; + NSString *str7 = [NSString stringWithCharacters: myCharacters + length: sizeof myCharacters / sizeof *myCharacters]; + + NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; + + const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ', + 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', + ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', + 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0}; + NSString *str9 = [NSString stringWithCharacters: myOtherCharacters + length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; + + const unichar myNextCharacters[] = {0x03C3, 0x0000}; + + NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; + + NSString *str11 = NSStringFromClass([str10 class]); + + NSString *label1 = @"Process Name: "; + NSString *label2 = @"Process Id: "; + NSString *processName = [[NSProcessInfo processInfo] processName]; + NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]; + NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + + NSString *strA1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; + + NSString *strA2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; + + NSString *strA3 = @"A string made with the at sign is here"; + + NSString *strA4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; + + NSString* strA5 = NSStringFromRect(ns_rect_4str); + + NSString* strA6 = [@"/usr/doc/README.1ST" pathExtension]; + + NSString *strA7 = [NSString stringWithCharacters: myCharacters + length: sizeof myCharacters / sizeof *myCharacters]; + + NSString* strA8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; + + NSString *strA9 = [NSString stringWithCharacters: myOtherCharacters + length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; + + NSString *strA10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; + + NSString *strA11 = NSStringFromClass([str10 class]); + + NSString *strA12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + + NSString *strB1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; + + NSString *strB2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; + + NSString *strB3 = @"A string made with the at sign is here"; + + NSString *strB4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; + + NSString* strB5 = NSStringFromRect(ns_rect_4str); + + NSString* strB6 = [@"/usr/doc/README.1ST" pathExtension]; + + NSString *strB7 = [NSString stringWithCharacters: myCharacters + length: sizeof myCharacters / sizeof *myCharacters]; + + NSString* strB8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; + + NSString *strB9 = [NSString stringWithCharacters: myOtherCharacters + length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; + + NSString *strB10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; + + NSString *strB11 = NSStringFromClass([str10 class]); + + NSString *strB12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + + NSString *strC11 = NSStringFromClass([str10 class]); + + NSString *strC12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + + NSString *strC1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; + + NSString *strC2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; + + NSString *strC3 = @"A string made with the at sign is here"; + + NSString *strC4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; + + NSString* strC5 = NSStringFromRect(ns_rect_4str); + + NSString* strC6 = [@"/usr/doc/README.1ST" pathExtension]; + + NSString *strC7 = [NSString stringWithCharacters: myCharacters + length: sizeof myCharacters / sizeof *myCharacters]; + + NSString* strC8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; + + NSString *strC9 = [NSString stringWithCharacters: myOtherCharacters + length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; + + NSString *strC10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; + + NSString *strD11 = NSStringFromClass([str10 class]); + + NSString *strD12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + + NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9]; + NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5]; + NSString *japanese = @"色は匂へど散りぬるを"; + NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione."; + NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?"; + NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt"; + + void* data_set[3] = {str1,str2,str3}; + + NSString *hebrew = [NSString stringWithString:@"לילה טוב"]; + + NSArray* newArray = [[NSMutableArray alloc] init]; + [newArray addObject:str1]; + [newArray addObject:str2]; + [newArray addObject:str3]; + [newArray addObject:str4]; + [newArray addObject:str5]; + [newArray addObject:str6]; + [newArray addObject:str7]; + [newArray addObject:str8]; + [newArray addObject:str9]; + [newArray addObject:str10]; + [newArray addObject:str11]; + [newArray addObject:str12]; + [newArray addObject:strA1]; + [newArray addObject:strA2]; + [newArray addObject:strA3]; + [newArray addObject:strA4]; + [newArray addObject:strA5]; + [newArray addObject:strA6]; + [newArray addObject:strA7]; + [newArray addObject:strA8]; + [newArray addObject:strA9]; + [newArray addObject:strA10]; + [newArray addObject:strA11]; + [newArray addObject:strA12]; + [newArray addObject:strB1]; + [newArray addObject:strB2]; + [newArray addObject:strB3]; + [newArray addObject:strB4]; + [newArray addObject:strB5]; + [newArray addObject:strB6]; + [newArray addObject:strB7]; + [newArray addObject:strB8]; + [newArray addObject:strB9]; + [newArray addObject:strB10]; + [newArray addObject:strB11]; + [newArray addObject:strB12]; + [newArray addObject:strC1]; + [newArray addObject:strC2]; + [newArray addObject:strC3]; + [newArray addObject:strC4]; + [newArray addObject:strC5]; + [newArray addObject:strC6]; + [newArray addObject:strC7]; + [newArray addObject:strC8]; + [newArray addObject:strC9]; + [newArray addObject:strC10]; + [newArray addObject:strC11]; + [newArray addObject:strC12]; + [newArray addObject:strD11]; + [newArray addObject:strD12]; + + NSDictionary* newDictionary = [[NSDictionary alloc] initWithObjects:newArray forKeys:newArray]; + NSDictionary *newMutableDictionary = [[NSMutableDictionary alloc] init]; + [newMutableDictionary setObject:@"foo" forKey:@"bar0"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar1"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar2"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar3"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar4"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar5"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar6"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar7"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar8"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar9"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar10"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar11"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar12"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar13"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar14"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar15"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar16"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar17"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar18"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar19"]; + [newMutableDictionary setObject:@"foo" forKey:@"bar20"]; + + NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; + [attrString isEqual:nil]; + NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; + [mutableAttrString isEqual:nil]; + + NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"]; + [mutableString insertString:@"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 " atIndex:0]; + + NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]]; + + [mutableGetConst length]; + + NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:4]; + NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6]; + + [mutableData appendBytes:"MOREDATA" length:8]; + + [immutableData length]; + [mutableData length]; + + NSSet* nsset = [[NSSet alloc] initWithObjects:str1,str2,str3,nil]; + NSSet *nsmutableset = [[NSMutableSet alloc] initWithObjects:str1,str2,str3,nil]; + [nsmutableset addObject:str4]; + + CFDataRef data_ref = CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5); + + CFMutableDataRef mutable_data_ref = CFDataCreateMutable(kCFAllocatorDefault, 8); + CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5); + + CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100); + CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew")); + + CFStringRef cfstring_ref = CFSTR("HELLO WORLD"); + + + CFSetRef set_ref = CFSetCreate(NULL, data_set, 3, NULL); + + CFMutableSetRef mutable_set_ref = CFSetCreateMutable(NULL, 5, NULL); + + CFSetAddValue(mutable_set_ref, str1); + CFSetAddValue(mutable_set_ref, str2); + CFSetAddValue(mutable_set_ref, str3); + CFSetAddValue(mutable_set_ref, str4); + CFSetAddValue(mutable_set_ref, str5); + CFSetAddValue(mutable_set_ref, str6); + CFSetAddValue(mutable_set_ref, str7); + CFSetAddValue(mutable_set_ref, str8); + CFSetAddValue(mutable_set_ref, str9); + CFSetAddValue(mutable_set_ref, str10); + CFSetAddValue(mutable_set_ref, str11); + CFSetAddValue(mutable_set_ref, str12); + + + CFDictionaryRef cfdict_ref = CFDictionaryCreate(NULL, data_set, data_set, 3, NULL, NULL); + CFMutableDictionaryRef mutable_dict_ref = CFDictionaryCreateMutable(NULL, 16, NULL, NULL); + + CFDictionarySetValue(mutable_dict_ref, str1, str1); + CFDictionarySetValue(mutable_dict_ref, str2, str2); + CFDictionarySetValue(mutable_dict_ref, str3, str3); + CFDictionarySetValue(mutable_dict_ref, str4, str1); + CFDictionarySetValue(mutable_dict_ref, str5, str2); + CFDictionarySetValue(mutable_dict_ref, str6, str3); + CFDictionarySetValue(mutable_dict_ref, str7, str1); + CFDictionarySetValue(mutable_dict_ref, str8, str2); + CFDictionarySetValue(mutable_dict_ref, str9, str3); + CFDictionarySetValue(mutable_dict_ref, str10, str1); + CFDictionarySetValue(mutable_dict_ref, str11, str2); + CFDictionarySetValue(mutable_dict_ref, str12, str3); + + CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL); + CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL); + + CFArraySetValueAtIndex(mutable_array_ref, 0, str1); + CFArraySetValueAtIndex(mutable_array_ref, 1, str2); + CFArraySetValueAtIndex(mutable_array_ref, 2, str3); + CFArraySetValueAtIndex(mutable_array_ref, 3, str4); + CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!! + CFArraySetValueAtIndex(mutable_array_ref, 4, str6); + CFArraySetValueAtIndex(mutable_array_ref, 5, str7); + CFArraySetValueAtIndex(mutable_array_ref, 6, str8); + CFArraySetValueAtIndex(mutable_array_ref, 7, str9); + CFArraySetValueAtIndex(mutable_array_ref, 8, str10); + CFArraySetValueAtIndex(mutable_array_ref, 9, str11); + CFArraySetValueAtIndex(mutable_array_ref, 10, str12); + + CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL); + + CFBagSetValue(mutable_bag_ref, strB10); + CFBagSetValue(mutable_bag_ref, str1); + CFBagSetValue(mutable_bag_ref, str2); + CFBagSetValue(mutable_bag_ref, str3); + CFBagSetValue(mutable_bag_ref, str4); + CFBagSetValue(mutable_bag_ref, str5); + CFBagSetValue(mutable_bag_ref, str6); + CFBagSetValue(mutable_bag_ref, str7); + CFBagSetValue(mutable_bag_ref, str8); + CFBagSetValue(mutable_bag_ref, str9); + CFBagSetValue(mutable_bag_ref, str10); + CFBagSetValue(mutable_bag_ref, str11); + CFBagSetValue(mutable_bag_ref, str12); + CFBagSetValue(mutable_bag_ref, strA1); + CFBagSetValue(mutable_bag_ref, strA2); + CFBagSetValue(mutable_bag_ref, strA3); + + CFBagRef cfbag_ref = CFBagCreateCopy(NULL, mutable_bag_ref); + + CFBagSetValue(mutable_bag_ref, strB8); + CFBagSetValue(mutable_bag_ref, strC4); + + + CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL); + CFBinaryHeapAddValue(binheap_ref, str1); + CFBinaryHeapAddValue(binheap_ref, str2); + CFBinaryHeapAddValue(binheap_ref, str3); + CFBinaryHeapAddValue(binheap_ref, str4); + CFBinaryHeapAddValue(binheap_ref, str5); + CFBinaryHeapAddValue(binheap_ref, str6); + CFBinaryHeapAddValue(binheap_ref, str7); + CFBinaryHeapAddValue(binheap_ref, str8); + CFBinaryHeapAddValue(binheap_ref, str9); + CFBinaryHeapAddValue(binheap_ref, str10); + CFBinaryHeapAddValue(binheap_ref, str11); + CFBinaryHeapAddValue(binheap_ref, str12); + CFBinaryHeapAddValue(binheap_ref, strA1); + CFBinaryHeapAddValue(binheap_ref, strB1); + CFBinaryHeapAddValue(binheap_ref, strC1); + CFBinaryHeapAddValue(binheap_ref, strA11); + CFBinaryHeapAddValue(binheap_ref, strB11); + CFBinaryHeapAddValue(binheap_ref, strC11); + CFBinaryHeapAddValue(binheap_ref, strB12); + CFBinaryHeapAddValue(binheap_ref, strC12); + CFBinaryHeapAddValue(binheap_ref, strA12); + + CFURLRef cfurl_ref = CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL); + CFURLRef cfchildurl_ref = CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref); + CFURLRef cfgchildurl_ref = CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref); + + NSDictionary *error_userInfo = @{@"a": @1, @"b" : @2}; + NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar" code:12 userInfo:error_userInfo]; + + NSBundle* bundle_string = [[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/Accelerate.framework"]; + NSBundle* bundle_url = [[NSBundle alloc] initWithURL:[[NSURL alloc] initWithString:@"file://localhost/System/Library/Frameworks/Cocoa.framework"]]; + + NSBundle* main_bundle = [NSBundle mainBundle]; + + NSArray* bundles = [NSBundle allBundles]; + + NSURL *nsurl0; + + for (NSBundle* bundle in bundles) + { + nsurl0 = [bundle bundleURL]; + } + + NSException* except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" reason:@"cuz it's funny" userInfo:nil]; + NSException* except1 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" reason:@"cuz it's funny" userInfo:nil]; + NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil]; + NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil]; + + NSMachPort *port = [NSMachPort port]; + + NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"]; + NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl]; + NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2]; + + NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm April 10, 1985"]; + NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"]; + NSDate *date3 = [NSDate date]; + NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60]; + + CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1); + CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2); + CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3); + CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4); + + NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5]; + + [nscounted_set addObject:str0]; + [nscounted_set addObject:str1]; + [nscounted_set addObject:str0]; + [nscounted_set addObject:str0]; + [nscounted_set addObject:@"foo1"]; + [nscounted_set addObject:@"foo2"]; + [nscounted_set addObject:@"foo3"]; + + NSIndexSet *iset1 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)]; + NSIndexSet *iset2 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)]; + + NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init]; + [imset addIndex:1936]; + [imset addIndex:7]; + [imset addIndex:9]; + [imset addIndex:11]; + [imset addIndex:24]; + [imset addIndex:41]; + [imset addIndex:58]; + [imset addIndex:61]; + [imset addIndex:62]; + [imset addIndex:63]; + + CFTimeZoneRef cupertino = CFTimeZoneCreateWithName ( + NULL, + CFSTR("PST"), + YES); + CFTimeZoneRef home = CFTimeZoneCreateWithName ( + NULL, + CFSTR("Europe/Rome"), + YES); + CFTimeZoneRef europe = CFTimeZoneCreateWithName ( + NULL, + CFSTR("CET"), + YES); + + NSTimeZone *cupertino_ns = [NSTimeZone timeZoneWithAbbreviation:@"PST"]; + NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"]; + NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"]; + + NSHost *localhost = [NSHost hostWithAddress:@"127.0.0.1"]; + +#ifndef IOS + NSTask *my_task = [[NSTask alloc] init]; +#endif + + + CFGregorianUnits cf_greg_units = {1,3,5,12,5,7}; + CFGregorianDate cf_greg_date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL); + CFRange cf_range = {4,4}; + NSPoint ns_point = {4,4}; + NSRange ns_range = {4,4}; + + NSValue *range_value = [NSValue valueWithRange:ns_range]; + + NSRect ns_rect = {{1,1},{5,5}}; + NSRect* ns_rect_ptr = &ns_rect; + NSRectArray ns_rect_arr = &ns_rect; + NSSize ns_size = {5,7}; + NSSize* ns_size_ptr = &ns_size; + + CGSize cg_size = {1,6}; + CGPoint cg_point = {2,7}; + CGRect cg_rect = {{1,2}, {7,7}}; + +#ifndef IOS + RGBColor rgb_color = {3,56,35}; + RGBColor* rgb_color_ptr = &rgb_color; +#endif + + Rect rect = {4,8,4,7}; + Rect* rect_ptr = ▭ + + Point point = {7,12}; + Point* point_ptr = &point; + +#ifndef IOS + HIPoint hi_point = {7,12}; + HIRect hi_rect = {{3,5},{4,6}}; +#endif + + SEL foo_selector = @selector(foo_selector_impl); + + CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64); + CFBitVectorSetCount(mut_bv, 50); + CFBitVectorSetBitAtIndex(mut_bv, 0, 1); + CFBitVectorSetBitAtIndex(mut_bv, 1, 1); + CFBitVectorSetBitAtIndex(mut_bv, 2, 1); + CFBitVectorSetBitAtIndex(mut_bv, 5, 1); + CFBitVectorSetBitAtIndex(mut_bv, 6, 1); + CFBitVectorSetBitAtIndex(mut_bv, 8, 1); + CFBitVectorSetBitAtIndex(mut_bv, 10, 1); + CFBitVectorSetBitAtIndex(mut_bv, 11, 1); + CFBitVectorSetBitAtIndex(mut_bv, 16, 1); + CFBitVectorSetBitAtIndex(mut_bv, 17, 1); + CFBitVectorSetBitAtIndex(mut_bv, 19, 1); + CFBitVectorSetBitAtIndex(mut_bv, 20, 1); + CFBitVectorSetBitAtIndex(mut_bv, 22, 1); + CFBitVectorSetBitAtIndex(mut_bv, 24, 1); + CFBitVectorSetBitAtIndex(mut_bv, 28, 1); + CFBitVectorSetBitAtIndex(mut_bv, 29, 1); + CFBitVectorSetBitAtIndex(mut_bv, 30, 1); + CFBitVectorSetBitAtIndex(mut_bv, 30, 1); + CFBitVectorSetBitAtIndex(mut_bv, 31, 1); + CFBitVectorSetBitAtIndex(mut_bv, 34, 1); + CFBitVectorSetBitAtIndex(mut_bv, 35, 1); + CFBitVectorSetBitAtIndex(mut_bv, 37, 1); + CFBitVectorSetBitAtIndex(mut_bv, 39, 1); + CFBitVectorSetBitAtIndex(mut_bv, 40, 1); + CFBitVectorSetBitAtIndex(mut_bv, 41, 1); + CFBitVectorSetBitAtIndex(mut_bv, 43, 1); + CFBitVectorSetBitAtIndex(mut_bv, 47, 1); + + Molecule *molecule = [Molecule new]; + + Class myclass = NSClassFromString(@"NSValue"); + Class myclass2 = [str0 class]; + Class myclass3 = [molecule class]; + Class myclass4 = NSClassFromString(@"NSMutableArray"); + Class myclass5 = [nil class]; + + NSArray *components = @[@"usr", @"blah", @"stuff"]; + NSString *path = [NSString pathWithComponents: components]; + + [molecule addObserver:[My_KVO_Observer new] forKeyPath:@"atoms" options:0 context:NULL]; // Set break point at this line. + [newMutableDictionary addObserver:[My_KVO_Observer new] forKeyPath:@"weirdKeyToKVO" options:NSKeyValueObservingOptionNew context:NULL]; + + [molecule setAtoms:nil]; + [molecule setAtoms:[NSMutableArray new]]; + + [pool drain]; + return 0; +} + diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile new file mode 100644 index 0000000..0d94c22 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile @@ -0,0 +1,9 @@ +LEVEL = ../../../../make + +OBJC_SOURCES := main.m + +CFLAGS_EXTRAS += -w + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py new file mode 100644 index 0000000..e11c45e --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py @@ -0,0 +1,107 @@ +# encoding: utf-8 +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +import datetime +import lldbsuite.test.lldbutil as lldbutil + +class NSStringDataFormatterTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def appkit_tester_impl(self,commands): + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + commands() + + @skipUnlessDarwin + def test_nsstring_with_run_command(self): + """Test formatters for NSString.""" + self.appkit_tester_impl(self.nsstring_data_formatter_commands) + + @skipUnlessDarwin + def test_rdar11106605_with_run_command(self): + """Check that Unicode characters come out of CFString summary correctly.""" + self.appkit_tester_impl(self.rdar11106605_commands) + + @skipUnlessDarwin + def test_nsstring_withNULS_with_run_command(self): + """Test formatters for NSString.""" + self.appkit_tester_impl(self.nsstring_withNULs_commands) + + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.m', '// break here') + + def rdar11106605_commands(self): + """Check that Unicode characters come out of CFString summary correctly.""" + self.expect('frame variable italian', substrs = ['L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.']) + self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?']) + self.expect('frame variable german', substrs = ['Über-Ich und aus den Ansprüchen der sozialen Umwelt']) + self.expect('frame variable japanese', substrs = ['色は匂へど散りぬるを']) + self.expect('frame variable hebrew', substrs = ['לילה טוב']) + + def nsstring_data_formatter_commands(self): + self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12', + substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"', + # '(NSString *) str0 = ',' @"255"', + '(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"', + '(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"', + '(NSString *) str3 = ',' @"A string made with the at sign is here"', + '(NSString *) str4 = ',' @"This is string number 4 right here"', + '(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"', + '(NSString *) str6 = ',' @"1ST"', + '(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime', + '(NSString *) str9 = ',' @"a very much boring task to write a string this way!!', + '(NSString *) str10 = ',' @"This is a Unicode string σ number 4 right here"', + '(NSString *) str11 = ',' @"__NSCFString"', + '(NSString *) label1 = ',' @"Process Name: "', + '(NSString *) label2 = ',' @"Process Id: "', + '(NSString *) str12 = ',' @"Process Name: a.out Process Id:']) + self.expect('frame variable attrString mutableAttrString mutableGetConst', + substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"', + '(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"', + '(NSString *) mutableGetConst = ',' @"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"']) + + self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff']) + self.expect('frame variable path',substrs = ['usr/blah/stuff']) + + def nsstring_withNULs_commands(self): + """Check that the NSString formatter supports embedded NULs in the text""" + self.expect('po strwithNULs', substrs=['a very much boring task to write']) + self.expect('expr [strwithNULs length]', substrs=['54']) + self.expect('frame variable strwithNULs', substrs=['@"a very much boring task to write\\0a string this way!!']) + self.expect('po strwithNULs2', substrs=['a very much boring task to write']) + self.expect('expr [strwithNULs2 length]', substrs=['52']) + self.expect('frame variable strwithNULs2', substrs=['@"a very much boring task to write\\0a string this way!!']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m new file mode 100644 index 0000000..7b8c378 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m @@ -0,0 +1,99 @@ +//===-- main.m ------------------------------------------------*- ObjC -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import + +#if defined(__APPLE__) +#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) +#define IOS +#endif +#endif + +#if defined(IOS) +#import +#else +#import +#endif + +int main (int argc, const char * argv[]) +{ + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + NSString *str0 = [[NSNumber numberWithUnsignedLongLong:0xFF] stringValue]; + NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; + NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; + NSString *str3 = @"A string made with the at sign is here"; + NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; + NSRect ns_rect_4str = {{1,1},{5,5}}; + NSString* str5 = NSStringFromRect(ns_rect_4str); + NSString* str6 = [@"/usr/doc/README.1ST" pathExtension]; + const unichar myCharacters[] = {0x03C3,'x','x'}; + NSString *str7 = [NSString stringWithCharacters: myCharacters + length: sizeof myCharacters / sizeof *myCharacters]; + NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; + const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ', + 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', + ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', + 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0}; + NSString *str9 = [NSString stringWithCharacters: myOtherCharacters + length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; + const unichar myNextCharacters[] = {0x03C3, 0x0000}; + NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; + NSString *str11 = NSStringFromClass([str10 class]); + NSString *label1 = @"Process Name: "; + NSString *label2 = @"Process Id: "; + NSString *processName = [[NSProcessInfo processInfo] processName]; + NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]; + NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9]; + NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5]; + NSString *japanese = @"色は匂へど散りぬるを"; + NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione."; + NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?"; + NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt"; + void* data_set[3] = {str1,str2,str3}; + NSString *hebrew = [NSString stringWithString:@"לילה טוב"]; + + NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]]; + [attrString isEqual:nil]; + NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]]; + [mutableAttrString isEqual:nil]; + + NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"]; + [mutableString insertString:@"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 " atIndex:0]; + + NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]]; + + [mutableGetConst length]; + CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100); + CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew")); + CFStringRef cfstring_ref = CFSTR("HELLO WORLD"); + + NSArray *components = @[@"usr", @"blah", @"stuff"]; + NSString *path = [NSString pathWithComponents: components]; + + const unichar someOfTheseAreNUL[] = {'a',' ', 'v','e','r','y',' ', + 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', + ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', + 't','h','i','s',' ','w','a','y','!','!', 0x03C3, 0}; + NSString *strwithNULs = [NSString stringWithCharacters: someOfTheseAreNUL + length: sizeof someOfTheseAreNUL / sizeof *someOfTheseAreNUL]; + + const unichar someOfTheseAreNUL2[] = {'a',' ', 'v','e','r','y',' ', + 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', + ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', + 't','h','i','s',' ','w','a','y','!','!'}; + NSString *strwithNULs2 = [NSString stringWithCharacters: someOfTheseAreNUL2 + length: sizeof someOfTheseAreNUL2 / sizeof *someOfTheseAreNUL2]; + + [pool drain]; // break here + return 0; +} + -- cgit v1.1