| 1 | // REQUIRES: objc-gnustep |
| 2 | // XFAIL: system-windows |
| 3 | // |
| 4 | // RUN: %build %s --compiler=clang --objc-gnustep --output=%t |
| 5 | |
| 6 | #import "objc/runtime.h" |
| 7 | |
| 8 | @protocol NSCoding |
| 9 | @end |
| 10 | |
| 11 | #ifdef __has_attribute |
| 12 | #if __has_attribute(objc_root_class) |
| 13 | __attribute__((objc_root_class)) |
| 14 | #endif |
| 15 | #endif |
| 16 | @interface NSObject <NSCoding> { |
| 17 | id isa; |
| 18 | int refcount; |
| 19 | } |
| 20 | @end |
| 21 | @implementation NSObject |
| 22 | - (id)class { |
| 23 | return object_getClass(self); |
| 24 | } |
| 25 | + (id)new { |
| 26 | return class_createInstance(self, 0); |
| 27 | } |
| 28 | @end |
| 29 | |
| 30 | @interface TestObj : NSObject { |
| 31 | int _int; |
| 32 | float _float; |
| 33 | char _char; |
| 34 | void *_ptr_void; |
| 35 | NSObject *_ptr_nsobject; |
| 36 | id _id_objc; |
| 37 | } |
| 38 | - (void)check_ivars_zeroed; |
| 39 | - (void)set_ivars; |
| 40 | @end |
| 41 | @implementation TestObj |
| 42 | - (void)check_ivars_zeroed { |
| 43 | ; |
| 44 | } |
| 45 | - (void)set_ivars { |
| 46 | _int = 1; |
| 47 | _float = 2.0f; |
| 48 | _char = '\3'; |
| 49 | _ptr_void = (void*)4; |
| 50 | _ptr_nsobject = (NSObject*)5; |
| 51 | _id_objc = (id)6; |
| 52 | } |
| 53 | @end |
| 54 | |
| 55 | // RUN: %lldb -b -o "b objc-gnustep-print.m:43" -o "run" -o "p self" -o "p *self" -- %t | FileCheck %s --check-prefix=SELF |
| 56 | // |
| 57 | // SELF: (lldb) b objc-gnustep-print.m:43 |
| 58 | // SELF: Breakpoint {{.*}} at objc-gnustep-print.m |
| 59 | // |
| 60 | // SELF: (lldb) run |
| 61 | // SELF: Process {{[0-9]+}} stopped |
| 62 | // SELF: -[TestObj check_ivars_zeroed](self=[[SELF_PTR:0x[0-9a-f]+]]{{.*}}) at objc-gnustep-print.m |
| 63 | // |
| 64 | // SELF: (lldb) p self |
| 65 | // SELF: (TestObj *) [[SELF_PTR]] |
| 66 | // |
| 67 | // SELF: (lldb) p *self |
| 68 | // SELF: (TestObj) { |
| 69 | // SELF: NSObject = { |
| 70 | // SELF: isa |
| 71 | // SELF: refcount |
| 72 | // SELF: } |
| 73 | // SELF: _int = 0 |
| 74 | // SELF: _float = 0 |
| 75 | // SELF: _char = '\0' |
| 76 | // SELF: _ptr_void = 0x{{0*}} |
| 77 | // SELF: _ptr_nsobject = nil |
| 78 | // SELF: _id_objc = nil |
| 79 | // SELF: } |
| 80 | |
| 81 | // RUN: %lldb -b -o "b objc-gnustep-print.m:106" -o "run" -o "p t->_int" -o "p t->_float" -o "p t->_char" \ |
| 82 | // RUN: -o "p t->_ptr_void" -o "p t->_ptr_nsobject" -o "p t->_id_objc" -- %t | FileCheck %s --check-prefix=IVARS_SET |
| 83 | // |
| 84 | // IVARS_SET: (lldb) p t->_int |
| 85 | // IVARS_SET: (int) 1 |
| 86 | // |
| 87 | // IVARS_SET: (lldb) p t->_float |
| 88 | // IVARS_SET: (float) 2 |
| 89 | // |
| 90 | // IVARS_SET: (lldb) p t->_char |
| 91 | // IVARS_SET: (char) '\x03' |
| 92 | // |
| 93 | // IVARS_SET: (lldb) p t->_ptr_void |
| 94 | // IVARS_SET: (void *) 0x{{0*}}4 |
| 95 | // |
| 96 | // IVARS_SET: (lldb) p t->_ptr_nsobject |
| 97 | // IVARS_SET: (NSObject *) 0x{{0*}}5 |
| 98 | // |
| 99 | // IVARS_SET: (lldb) p t->_id_objc |
| 100 | // IVARS_SET: (id) 0x{{0*}}6 |
| 101 | |
| 102 | int main() { |
| 103 | TestObj *t = [TestObj new]; |
| 104 | [t check_ivars_zeroed]; |
| 105 | [t set_ivars]; |
| 106 | return 0; |
| 107 | } |
| 108 | |