Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 1 | """ |
| 2 | Objective-C runtime wrapper for use by LLDB Python formatters |
| 3 | |
| 4 | part of The LLVM Compiler Infrastructure |
| 5 | This file is distributed under the University of Illinois Open Source |
| 6 | License. See LICENSE.TXT for details. |
| 7 | """ |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 8 | import lldb |
| 9 | import cache |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 10 | import attrib_fromdict |
| 11 | import functools |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 12 | |
| 13 | class Utilities: |
| 14 | @staticmethod |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 15 | def read_ascii(process, pointer,max_len=128): |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 16 | error = lldb.SBError() |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 17 | content = None |
| 18 | try: |
| 19 | content = process.ReadCStringFromMemory(pointer,max_len,error) |
| 20 | except: |
| 21 | pass |
| 22 | if content == None or len(content) == 0 or error.fail == True: |
| 23 | return None |
| 24 | return content |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 25 | |
| 26 | @staticmethod |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 27 | def is_valid_pointer(pointer, pointer_size, allow_tagged=False, allow_NULL=False): |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 28 | if pointer == None: |
| 29 | return False |
| 30 | if pointer == 0: |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 31 | return allow_NULL |
| 32 | if allow_tagged and (pointer % 2) == 1: |
| 33 | return True |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 34 | return ((pointer % pointer_size) == 0) |
| 35 | |
| 36 | # Objective-C runtime has a rule that pointers in a class_t will only have bits 0 thru 46 set |
| 37 | # so if any pointer has bits 47 thru 63 high we know that this is not a valid isa |
| 38 | @staticmethod |
| 39 | def is_allowed_pointer(pointer): |
| 40 | if pointer == None: |
| 41 | return False |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 42 | return ((pointer & 0xFFFF800000000000) == 0) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 43 | |
| 44 | @staticmethod |
| 45 | def read_child_of(valobj,offset,type): |
| 46 | child = valobj.CreateChildAtOffset("childUNK",offset,type) |
| 47 | if child == None or child.IsValid() == False: |
| 48 | return None; |
| 49 | return child.GetValueAsUnsigned() |
| 50 | |
| 51 | @staticmethod |
| 52 | def is_valid_identifier(name): |
| 53 | if name is None: |
| 54 | return None |
| 55 | if len(name) == 0: |
| 56 | return None |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 57 | # technically, the ObjC runtime does not enforce any rules about what name a class can have |
| 58 | # in practice, the commonly used byte values for a class name are the letters, digits and some |
| 59 | # symbols: $, %, -, _, . |
| 60 | # WARNING: this means that you cannot use this runtime implementation if you need to deal |
| 61 | # with class names that use anything but what is allowed here |
| 62 | ok_values = dict.fromkeys("$%_.-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890") |
| 63 | return all(c in ok_values for c in name) |
| 64 | |
| 65 | @staticmethod |
| 66 | def check_is_osx_lion(target): |
| 67 | # assume the only thing that has a Foundation.framework is a Mac |
| 68 | # assume anything < Lion does not even exist |
| 69 | mod = target.module['Foundation'] |
| 70 | if mod == None or mod.IsValid() == False: |
| 71 | return None |
| 72 | ver = mod.GetVersion() |
| 73 | if ver == None or ver == []: |
| 74 | return None |
| 75 | return (ver[0] < 900) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 76 | |
Enrico Granata | 3f1052b | 2012-03-13 21:52:00 +0000 | [diff] [blame^] | 77 | # a utility method that factors out code common to almost all the formatters |
| 78 | # takes in an SBValue and a metrics object |
| 79 | # returns a class_data and a wrapper (or None, if the runtime alone can't decide on a wrapper) |
| 80 | @staticmethod |
| 81 | def prepare_class_detection(valobj,statistics): |
| 82 | class_data = ObjCRuntime(valobj) |
| 83 | if class_data.is_valid() == False: |
| 84 | statistics.metric_hit('invalid_pointer',valobj) |
| 85 | wrapper = InvalidPointer_Description(valobj.GetValueAsUnsigned(0) == 0) |
| 86 | return class_data,wrapper |
| 87 | class_data = class_data.read_class_data() |
| 88 | if class_data.is_valid() == False: |
| 89 | statistics.metric_hit('invalid_isa',valobj) |
| 90 | wrapper = InvalidISA_Description() |
| 91 | return class_data,wrapper |
| 92 | if class_data.is_kvo(): |
| 93 | class_data = class_data.get_superclass() |
| 94 | if class_data.is_valid() == False: |
| 95 | statistics.metric_hit('invalid_isa',valobj) |
| 96 | wrapper = InvalidISA_Description() |
| 97 | return class_data,wrapper |
| 98 | return class_data,None |
| 99 | |
| 100 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 101 | class RoT_Data: |
| 102 | def __init__(self,rot_pointer,params): |
| 103 | if (Utilities.is_valid_pointer(rot_pointer.GetValueAsUnsigned(),params.pointer_size, allow_tagged=False)): |
| 104 | self.sys_params = params |
| 105 | self.valobj = rot_pointer |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 106 | #self.flags = Utilities.read_child_of(self.valobj,0,self.sys_params.uint32_t) |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 107 | #self.instanceStart = Utilities.read_child_of(self.valobj,4,self.sys_params.uint32_t) |
| 108 | self.instanceSize = None # lazy fetching |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 109 | offset = 24 if self.sys_params.is_64_bit else 16 |
| 110 | #self.ivarLayoutPtr = Utilities.read_child_of(self.valobj,offset,self.sys_params.addr_ptr_type) |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 111 | self.namePointer = Utilities.read_child_of(self.valobj,offset,self.sys_params.types_cache.addr_ptr_type) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 112 | self.check_valid() |
| 113 | else: |
| 114 | self.valid = False |
| 115 | if self.valid: |
| 116 | self.name = Utilities.read_ascii(self.valobj.GetTarget().GetProcess(),self.namePointer) |
| 117 | if not(Utilities.is_valid_identifier(self.name)): |
| 118 | self.valid = False |
| 119 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 120 | # perform sanity checks on the contents of this class_ro_t |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 121 | def check_valid(self): |
| 122 | self.valid = True |
| 123 | # misaligned pointers seem to be possible for this field |
| 124 | #if not(Utilities.is_valid_pointer(self.namePointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 125 | # self.valid = False |
| 126 | # pass |
| 127 | |
| 128 | def __str__(self): |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 129 | return \ |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 130 | "instanceSize = " + hex(self.instance_size()) + "\n" + \ |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 131 | "namePointer = " + hex(self.namePointer) + " --> " + self.name |
| 132 | |
| 133 | def is_valid(self): |
| 134 | return self.valid |
| 135 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 136 | def instance_size(self,align=False): |
| 137 | if self.is_valid() == False: |
| 138 | return None |
| 139 | if self.instanceSize == None: |
| 140 | self.instanceSize = Utilities.read_child_of(self.valobj,8,self.sys_params.types_cache.uint32_t) |
| 141 | if align: |
| 142 | unalign = self.instance_size(False) |
| 143 | if self.sys_params.is_64_bit: |
| 144 | return ((unalign + 7) & ~7) % 0x100000000 |
| 145 | else: |
| 146 | return ((unalign + 3) & ~3) % 0x100000000 |
| 147 | else: |
| 148 | return self.instanceSize |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 149 | |
| 150 | class RwT_Data: |
| 151 | def __init__(self,rwt_pointer,params): |
| 152 | if (Utilities.is_valid_pointer(rwt_pointer.GetValueAsUnsigned(),params.pointer_size, allow_tagged=False)): |
| 153 | self.sys_params = params |
| 154 | self.valobj = rwt_pointer |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 155 | #self.flags = Utilities.read_child_of(self.valobj,0,self.sys_params.uint32_t) |
| 156 | #self.version = Utilities.read_child_of(self.valobj,4,self.sys_params.uint32_t) |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 157 | self.roPointer = Utilities.read_child_of(self.valobj,8,self.sys_params.types_cache.addr_ptr_type) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 158 | self.check_valid() |
| 159 | else: |
| 160 | self.valid = False |
| 161 | if self.valid: |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 162 | self.rot = self.valobj.CreateValueFromAddress("rot",self.roPointer,self.sys_params.types_cache.addr_ptr_type).AddressOf() |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 163 | self.data = RoT_Data(self.rot,self.sys_params) |
| 164 | |
| 165 | # perform sanity checks on the contents of this class_rw_t |
| 166 | def check_valid(self): |
| 167 | self.valid = True |
| 168 | if not(Utilities.is_valid_pointer(self.roPointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 169 | self.valid = False |
| 170 | |
| 171 | def __str__(self): |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 172 | return \ |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 173 | "roPointer = " + hex(self.roPointer) |
| 174 | |
| 175 | def is_valid(self): |
| 176 | if self.valid: |
| 177 | return self.data.is_valid() |
| 178 | return False |
| 179 | |
| 180 | class Class_Data_V2: |
| 181 | def __init__(self,isa_pointer,params): |
| 182 | if (isa_pointer != None) and (Utilities.is_valid_pointer(isa_pointer.GetValueAsUnsigned(),params.pointer_size, allow_tagged=False)): |
| 183 | self.sys_params = params |
| 184 | self.valobj = isa_pointer |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 185 | self.check_valid() |
| 186 | else: |
| 187 | self.valid = False |
| 188 | if self.valid: |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 189 | self.rwt = self.valobj.CreateValueFromAddress("rwt",self.dataPointer,self.sys_params.types_cache.addr_ptr_type).AddressOf() |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 190 | self.data = RwT_Data(self.rwt,self.sys_params) |
| 191 | |
| 192 | # perform sanity checks on the contents of this class_t |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 193 | # this call tries to minimize the amount of data fetched- as soon as we have "proven" |
| 194 | # that we have an invalid object, we stop reading |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 195 | def check_valid(self): |
| 196 | self.valid = True |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 197 | |
| 198 | self.isaPointer = Utilities.read_child_of(self.valobj,0,self.sys_params.types_cache.addr_ptr_type) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 199 | if not(Utilities.is_valid_pointer(self.isaPointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 200 | self.valid = False |
| 201 | return |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 202 | if not(Utilities.is_allowed_pointer(self.isaPointer)): |
| 203 | self.valid = False |
| 204 | return |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 205 | |
| 206 | self.cachePointer = Utilities.read_child_of(self.valobj,2*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
| 207 | if not(Utilities.is_valid_pointer(self.cachePointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 208 | self.valid = False |
| 209 | return |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 210 | if not(Utilities.is_allowed_pointer(self.cachePointer)): |
| 211 | self.valid = False |
| 212 | return |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 213 | |
| 214 | self.vtablePointer = Utilities.read_child_of(self.valobj,3*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
| 215 | if not(Utilities.is_valid_pointer(self.vtablePointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 216 | self.valid = False |
| 217 | return |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 218 | if not(Utilities.is_allowed_pointer(self.vtablePointer)): |
| 219 | self.valid = False |
| 220 | return |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 221 | |
| 222 | self.dataPointer = Utilities.read_child_of(self.valobj,4*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
| 223 | if not(Utilities.is_valid_pointer(self.dataPointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 224 | self.valid = False |
| 225 | return |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 226 | if not(Utilities.is_allowed_pointer(self.dataPointer)): |
| 227 | self.valid = False |
| 228 | return |
| 229 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 230 | self.superclassIsaPointer = Utilities.read_child_of(self.valobj,1*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
| 231 | if not(Utilities.is_valid_pointer(self.superclassIsaPointer,self.sys_params.pointer_size,allow_tagged=False, allow_NULL=True)): |
| 232 | self.valid = False |
| 233 | return |
| 234 | if not(Utilities.is_allowed_pointer(self.superclassIsaPointer)): |
| 235 | self.valid = False |
| 236 | return |
| 237 | |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 238 | # in general, KVO is implemented by transparently subclassing |
| 239 | # however, there could be exceptions where a class does something else |
| 240 | # internally to implement the feature - this method will have no clue that a class |
| 241 | # has been KVO'ed unless the standard implementation technique is used |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 242 | def is_kvo(self): |
| 243 | if self.is_valid(): |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 244 | if self.class_name().startswith("NSKVONotifying_"): |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 245 | return True |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 246 | return False |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 247 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 248 | # some CF classes have a valid ObjC isa in their CFRuntimeBase |
| 249 | # but instead of being class-specific this isa points to a match-'em-all class |
| 250 | # which is __NSCFType (the versions without __ also exists and we are matching to it |
| 251 | # just to be on the safe side) |
| 252 | def is_cftype(self): |
| 253 | if self.is_valid(): |
Enrico Granata | 3f1052b | 2012-03-13 21:52:00 +0000 | [diff] [blame^] | 254 | return self.class_name() == '__NSCFType' or self.class_name() == 'NSCFType' |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 255 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 256 | def get_superclass(self): |
| 257 | if self.is_valid(): |
| 258 | parent_isa_pointer = self.valobj.CreateChildAtOffset("parent_isa", |
| 259 | self.sys_params.pointer_size, |
| 260 | self.sys_params.addr_ptr_type) |
| 261 | return Class_Data_V2(parent_isa_pointer,self.sys_params) |
| 262 | else: |
| 263 | return None |
| 264 | |
| 265 | def class_name(self): |
| 266 | if self.is_valid(): |
| 267 | return self.data.data.name |
| 268 | else: |
| 269 | return None |
| 270 | |
| 271 | def is_valid(self): |
| 272 | if self.valid: |
| 273 | return self.data.is_valid() |
| 274 | return False |
| 275 | |
| 276 | def __str__(self): |
| 277 | return 'isaPointer = ' + hex(self.isaPointer) + "\n" + \ |
| 278 | "superclassIsaPointer = " + hex(self.superclassIsaPointer) + "\n" + \ |
| 279 | "cachePointer = " + hex(self.cachePointer) + "\n" + \ |
| 280 | "vtablePointer = " + hex(self.vtablePointer) + "\n" + \ |
| 281 | "data = " + hex(self.dataPointer) |
| 282 | |
| 283 | def is_tagged(self): |
| 284 | return False |
| 285 | |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 286 | def instance_size(self,align=False): |
| 287 | if self.is_valid() == False: |
| 288 | return None |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 289 | return self.rwt.rot.instance_size(align) |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 290 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 291 | # runtime v1 is much less intricate than v2 and stores relevant information directly in the class_t object |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 292 | class Class_Data_V1: |
| 293 | def __init__(self,isa_pointer,params): |
| 294 | if (isa_pointer != None) and (Utilities.is_valid_pointer(isa_pointer.GetValueAsUnsigned(),params.pointer_size, allow_tagged=False)): |
Enrico Granata | 0448d9f | 2012-02-29 20:46:00 +0000 | [diff] [blame] | 295 | self.valid = True |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 296 | self.sys_params = params |
| 297 | self.valobj = isa_pointer |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 298 | self.check_valid() |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 299 | else: |
| 300 | self.valid = False |
| 301 | if self.valid: |
| 302 | self.name = Utilities.read_ascii(self.valobj.GetTarget().GetProcess(),self.namePointer) |
| 303 | if not(Utilities.is_valid_identifier(self.name)): |
| 304 | self.valid = False |
| 305 | |
| 306 | # perform sanity checks on the contents of this class_t |
| 307 | def check_valid(self): |
| 308 | self.valid = True |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 309 | |
| 310 | self.isaPointer = Utilities.read_child_of(self.valobj,0,self.sys_params.types_cache.addr_ptr_type) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 311 | if not(Utilities.is_valid_pointer(self.isaPointer,self.sys_params.pointer_size,allow_tagged=False)): |
| 312 | self.valid = False |
| 313 | return |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 314 | |
| 315 | self.superclassIsaPointer = Utilities.read_child_of(self.valobj,1*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
| 316 | if not(Utilities.is_valid_pointer(self.superclassIsaPointer,self.sys_params.pointer_size,allow_tagged=False,allow_NULL=True)): |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 317 | self.valid = False |
| 318 | return |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 319 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 320 | self.namePointer = Utilities.read_child_of(self.valobj,2*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
| 321 | #if not(Utilities.is_valid_pointer(self.namePointer,self.sys_params.pointer_size,allow_tagged=False,allow_NULL=False)): |
| 322 | # self.valid = False |
| 323 | # return |
| 324 | |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 325 | # in general, KVO is implemented by transparently subclassing |
| 326 | # however, there could be exceptions where a class does something else |
| 327 | # internally to implement the feature - this method will have no clue that a class |
| 328 | # has been KVO'ed unless the standard implementation technique is used |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 329 | def is_kvo(self): |
| 330 | if self.is_valid(): |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 331 | if self.class_name().startswith("NSKVONotifying_"): |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 332 | return True |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 333 | return False |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 334 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 335 | # some CF classes have a valid ObjC isa in their CFRuntimeBase |
| 336 | # but instead of being class-specific this isa points to a match-'em-all class |
| 337 | # which is __NSCFType (the versions without __ also exists and we are matching to it |
| 338 | # just to be on the safe side) |
| 339 | def is_cftype(self): |
| 340 | if self.is_valid(): |
Enrico Granata | 3f1052b | 2012-03-13 21:52:00 +0000 | [diff] [blame^] | 341 | return self.class_name() == '__NSCFType' or self.class_name() == 'NSCFType' |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 342 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 343 | def get_superclass(self): |
| 344 | if self.is_valid(): |
| 345 | parent_isa_pointer = self.valobj.CreateChildAtOffset("parent_isa", |
| 346 | self.sys_params.pointer_size, |
| 347 | self.sys_params.addr_ptr_type) |
| 348 | return Class_Data_V1(parent_isa_pointer,self.sys_params) |
| 349 | else: |
| 350 | return None |
| 351 | |
| 352 | def class_name(self): |
| 353 | if self.is_valid(): |
| 354 | return self.name |
| 355 | else: |
| 356 | return None |
| 357 | |
| 358 | def is_valid(self): |
| 359 | return self.valid |
| 360 | |
| 361 | def __str__(self): |
| 362 | return 'isaPointer = ' + hex(self.isaPointer) + "\n" + \ |
| 363 | "superclassIsaPointer = " + hex(self.superclassIsaPointer) + "\n" + \ |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 364 | "namePointer = " + hex(self.namePointer) + " --> " + self.name + \ |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 365 | "instanceSize = " + hex(self.instanceSize()) + "\n" |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 366 | |
| 367 | def is_tagged(self): |
| 368 | return False |
| 369 | |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 370 | def instance_size(self,align=False): |
| 371 | if self.is_valid() == False: |
| 372 | return None |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 373 | if self.instanceSize == None: |
| 374 | self.instanceSize = Utilities.read_child_of(self.valobj,5*self.sys_params.pointer_size,self.sys_params.types_cache.addr_ptr_type) |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 375 | if align: |
| 376 | unalign = self.instance_size(False) |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 377 | if self.sys_params.is_64_bit: |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 378 | return ((unalign + 7) & ~7) % 0x100000000 |
| 379 | else: |
| 380 | return ((unalign + 3) & ~3) % 0x100000000 |
| 381 | else: |
| 382 | return self.instanceSize |
| 383 | |
Enrico Granata | 0448d9f | 2012-02-29 20:46:00 +0000 | [diff] [blame] | 384 | # these are the only tagged pointers values for current versions |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 385 | # of OSX - they might change in future OS releases, and no-one is |
Enrico Granata | 0448d9f | 2012-02-29 20:46:00 +0000 | [diff] [blame] | 386 | # advised to rely on these values, or any of the bitmasking formulas |
| 387 | # in TaggedClass_Data. doing otherwise is at your own risk |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 388 | TaggedClass_Values_Lion = {1 : 'NSNumber', \ |
| 389 | 5: 'NSManagedObject', \ |
| 390 | 6: 'NSDate', \ |
| 391 | 7: 'NSDateTS' }; |
| 392 | TaggedClass_Values_NMOS = {0: 'NSAtom', \ |
| 393 | 3 : 'NSNumber', \ |
| 394 | 4: 'NSDateTS', \ |
| 395 | 5: 'NSManagedObject', \ |
| 396 | 6: 'NSDate' }; |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 397 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 398 | class TaggedClass_Data: |
| 399 | def __init__(self,pointer,params): |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 400 | global TaggedClass_Values_Lion,TaggedClass_Values_NMOS |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 401 | self.valid = True |
| 402 | self.name = None |
| 403 | self.sys_params = params |
| 404 | self.valobj = pointer |
| 405 | self.val = (pointer & ~0x0000000000000000FF) >> 8 |
| 406 | self.class_bits = (pointer & 0xE) >> 1 |
| 407 | self.i_bits = (pointer & 0xF0) >> 4 |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 408 | |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 409 | if self.sys_params.is_lion: |
| 410 | if self.class_bits in TaggedClass_Values_Lion: |
| 411 | self.name = TaggedClass_Values_Lion[self.class_bits] |
| 412 | else: |
| 413 | self.valid = False |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 414 | else: |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 415 | if self.class_bits in TaggedClass_Values_NMOS: |
| 416 | self.name = TaggedClass_Values_NMOS[self.class_bits] |
| 417 | else: |
| 418 | self.valid = False |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 419 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 420 | |
| 421 | def is_valid(self): |
| 422 | return self.valid |
| 423 | |
| 424 | def class_name(self): |
| 425 | if self.is_valid(): |
| 426 | return self.name |
| 427 | else: |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 428 | return False |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 429 | |
| 430 | def value(self): |
| 431 | return self.val if self.is_valid() else None |
| 432 | |
| 433 | def info_bits(self): |
| 434 | return self.i_bits if self.is_valid() else None |
| 435 | |
| 436 | def is_kvo(self): |
| 437 | return False |
| 438 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 439 | def is_cftype(self): |
| 440 | return False |
| 441 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 442 | # we would need to go around looking for the superclass or ask the runtime |
| 443 | # for now, we seem not to require support for this operation so we will merrily |
| 444 | # pretend to be at a root point in the hierarchy |
| 445 | def get_superclass(self): |
| 446 | return None |
| 447 | |
| 448 | # anything that is handled here is tagged |
| 449 | def is_tagged(self): |
| 450 | return True |
| 451 | |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 452 | # it seems reasonable to say that a tagged pointer is the size of a pointer |
| 453 | def instance_size(self,align=False): |
| 454 | if self.is_valid() == False: |
| 455 | return None |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 456 | return self.sys_params.pointer_size |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 457 | |
| 458 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 459 | class InvalidClass_Data: |
| 460 | def __init__(self): |
| 461 | pass |
| 462 | def is_valid(self): |
| 463 | return False |
| 464 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 465 | @functools.total_ordering |
| 466 | class Version: |
| 467 | def __init__(self, major, minor, release, build_string): |
| 468 | self._major = major |
| 469 | self._minor = minor |
| 470 | self._release = release |
| 471 | self._build_string = build_string |
| 472 | |
| 473 | def get_major(self): |
| 474 | return self._major |
| 475 | def get_minor(self): |
| 476 | return self._minor |
| 477 | def get_release(self): |
| 478 | return self._release |
| 479 | def get_build_string(self): |
| 480 | return self._build_string |
| 481 | |
| 482 | major = property(get_major,None) |
| 483 | minor = property(get_minor,None) |
| 484 | release = property(get_release,None) |
| 485 | build_string = property(get_build_string,None) |
| 486 | |
| 487 | def __lt__(self,other): |
| 488 | if (self.major < other.major): |
| 489 | return True |
| 490 | if (self.minor < other.minor): |
| 491 | return True |
| 492 | if (self.release < other.release): |
| 493 | return True |
| 494 | # build strings are not compared since they are heavily platform-dependent and might not always |
| 495 | # be available |
| 496 | return False |
| 497 | |
| 498 | def __eq__(self,other): |
| 499 | return (self.major == other.major) and \ |
| 500 | (self.minor == other.minor) and \ |
| 501 | (self.release == other.release) and \ |
| 502 | (self.build_string == other.build_string) |
| 503 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 504 | runtime_version = cache.Cache() |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 505 | os_version = cache.Cache() |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 506 | types_caches = cache.Cache() |
| 507 | isa_caches = cache.Cache() |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 508 | |
| 509 | class SystemParameters: |
| 510 | def __init__(self,valobj): |
| 511 | self.adjust_for_architecture(valobj) |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 512 | self.adjust_for_process(valobj) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 513 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 514 | def adjust_for_process(self, valobj): |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 515 | global runtime_version |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 516 | global os_version |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 517 | global types_caches |
| 518 | global isa_caches |
| 519 | |
| 520 | process = valobj.GetTarget().GetProcess() |
| 521 | self.pid = process.GetProcessID() |
| 522 | |
| 523 | if runtime_version.look_for_key(self.pid): |
| 524 | self.runtime_version = runtime_version.get_value(self.pid) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 525 | else: |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 526 | self.runtime_version = ObjCRuntime.runtime_version(process) |
| 527 | runtime_version.add_item(self.pid,self.runtime_version) |
| 528 | |
| 529 | if os_version.look_for_key(self.pid): |
| 530 | self.is_lion = os_version.get_value(self.pid) |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 531 | else: |
| 532 | self.is_lion = Utilities.check_is_osx_lion(valobj.GetTarget()) |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 533 | os_version.add_item(self.pid,self.is_lion) |
| 534 | |
| 535 | if types_caches.look_for_key(self.pid): |
| 536 | self.types_cache = types_caches.get_value(self.pid) |
| 537 | else: |
| 538 | self.types_cache = attrib_fromdict.AttributesDictionary(allow_reset=False) |
| 539 | self.types_cache.addr_type = valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedLong) |
| 540 | self.types_cache.addr_ptr_type = self.types_cache.addr_type.GetPointerType() |
| 541 | self.types_cache.uint32_t = valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedInt) |
| 542 | types_caches.add_item(self.pid,self.types_cache) |
| 543 | |
| 544 | if isa_caches.look_for_key(self.pid): |
| 545 | self.isa_cache = isa_caches.get_value(self.pid) |
| 546 | else: |
| 547 | self.isa_cache = cache.Cache() |
| 548 | isa_caches.add_item(self.pid,self.isa_cache) |
| 549 | |
| 550 | def adjust_for_architecture(self,valobj): |
| 551 | process = valobj.GetTarget().GetProcess() |
| 552 | self.pointer_size = process.GetAddressByteSize() |
| 553 | self.is_64_bit = (self.pointer_size == 8) |
| 554 | self.is_little = (process.GetByteOrder() == lldb.eByteOrderLittle) |
Enrico Granata | 385ad4e | 2012-03-03 00:45:57 +0000 | [diff] [blame] | 555 | self.cfruntime_size = 16 if self.is_64_bit else 8 |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 556 | |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 557 | # a simple helper function that makes it more explicit that one is calculating |
| 558 | # an offset that is made up of X pointers and Y bytes of additional data |
| 559 | # taking into account pointer size - if you know there is going to be some padding |
| 560 | # you can pass that in and it will be taken into account (since padding may be different between |
| 561 | # 32 and 64 bit versions, you can pass padding value for both, the right one will be used) |
| 562 | def calculate_offset(self, num_pointers = 0, bytes_count = 0, padding32 = 0, padding64 = 0): |
| 563 | value = bytes_count + num_pointers*self.pointer_size |
| 564 | return value + padding64 if self.is_64_bit else value + padding32 |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 565 | |
| 566 | class ObjCRuntime: |
| 567 | |
| 568 | # the ObjC runtime has no explicit "version" field that we can use |
| 569 | # instead, we discriminate v1 from v2 by looking for the presence |
| 570 | # of a well-known section only present in v1 |
| 571 | @staticmethod |
| 572 | def runtime_version(process): |
| 573 | if process.IsValid() == False: |
| 574 | return None |
| 575 | target = process.GetTarget() |
| 576 | num_modules = target.GetNumModules() |
| 577 | module_objc = None |
| 578 | for idx in range(num_modules): |
| 579 | module = target.GetModuleAtIndex(idx) |
| 580 | if module.GetFileSpec().GetFilename() == 'libobjc.A.dylib': |
| 581 | module_objc = module |
| 582 | break |
| 583 | if module_objc == None or module_objc.IsValid() == False: |
| 584 | return None |
| 585 | num_sections = module.GetNumSections() |
| 586 | section_objc = None |
| 587 | for idx in range(num_sections): |
| 588 | section = module.GetSectionAtIndex(idx) |
| 589 | if section.GetName() == '__OBJC': |
| 590 | section_objc = section |
| 591 | break |
| 592 | if section_objc != None and section_objc.IsValid(): |
| 593 | return 1 |
| 594 | return 2 |
| 595 | |
| 596 | def __init__(self,valobj): |
| 597 | self.valobj = valobj |
| 598 | self.adjust_for_architecture() |
| 599 | self.sys_params = SystemParameters(self.valobj) |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 600 | self.unsigned_value = self.valobj.GetValueAsUnsigned() |
| 601 | self.isa_value = None |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 602 | |
| 603 | def adjust_for_architecture(self): |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 604 | pass |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 605 | |
| 606 | # an ObjC pointer can either be tagged or must be aligned |
| 607 | def is_tagged(self): |
| 608 | if self.valobj is None: |
| 609 | return False |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 610 | return (Utilities.is_valid_pointer(self.unsigned_value,self.sys_params.pointer_size, allow_tagged=True) and \ |
| 611 | not(Utilities.is_valid_pointer(self.unsigned_value,self.sys_params.pointer_size, allow_tagged=False))) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 612 | |
| 613 | def is_valid(self): |
| 614 | if self.valobj is None: |
| 615 | return False |
| 616 | if self.valobj.IsInScope() == False: |
| 617 | return False |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 618 | return Utilities.is_valid_pointer(self.unsigned_value,self.sys_params.pointer_size, allow_tagged=True) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 619 | |
Enrico Granata | 3f1052b | 2012-03-13 21:52:00 +0000 | [diff] [blame^] | 620 | def is_nil(self): |
| 621 | return self.unsigned_value == 0 |
| 622 | |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 623 | def read_isa(self): |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 624 | if self.isa_value != None: |
| 625 | return self.isa_value |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 626 | isa_pointer = self.valobj.CreateChildAtOffset("cfisa", |
| 627 | 0, |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 628 | self.sys_params.types_cache.addr_ptr_type) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 629 | if isa_pointer == None or isa_pointer.IsValid() == False: |
| 630 | return None; |
| 631 | if isa_pointer.GetValueAsUnsigned(1) == 1: |
| 632 | return None; |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 633 | self.isa_value = isa_pointer |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 634 | return isa_pointer |
| 635 | |
| 636 | def read_class_data(self): |
| 637 | global isa_cache |
| 638 | if self.is_tagged(): |
| 639 | # tagged pointers only exist in ObjC v2 |
| 640 | if self.sys_params.runtime_version == 2: |
| 641 | # not every odd-valued pointer is actually tagged. most are just plain wrong |
| 642 | # we could try and predetect this before even creating a TaggedClass_Data object |
| 643 | # but unless performance requires it, this seems a cleaner way to tackle the task |
Enrico Granata | 7bc0ec3 | 2012-02-29 03:28:49 +0000 | [diff] [blame] | 644 | tentative_tagged = TaggedClass_Data(self.unsigned_value,self.sys_params) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 645 | return tentative_tagged if tentative_tagged.is_valid() else InvalidClass_Data() |
| 646 | else: |
| 647 | return InvalidClass_Data() |
| 648 | if self.is_valid() == False: |
| 649 | return InvalidClass_Data() |
| 650 | isa = self.read_isa() |
| 651 | if isa == None: |
| 652 | return InvalidClass_Data() |
| 653 | isa_value = isa.GetValueAsUnsigned(1) |
| 654 | if isa_value == 1: |
| 655 | return InvalidClass_Data() |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 656 | data = self.sys_params.isa_cache.get_value(isa_value,default=None) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 657 | if data != None: |
| 658 | return data |
| 659 | if self.sys_params.runtime_version == 2: |
| 660 | data = Class_Data_V2(isa,self.sys_params) |
| 661 | else: |
| 662 | data = Class_Data_V1(isa,self.sys_params) |
| 663 | if data == None: |
| 664 | return InvalidClass_Data() |
| 665 | if data.is_valid(): |
Enrico Granata | cfdafa3 | 2012-03-05 19:56:33 +0000 | [diff] [blame] | 666 | self.sys_params.isa_cache.add_item(isa_value,data,ok_to_replace=True) |
Enrico Granata | eb4a479 | 2012-02-23 23:10:27 +0000 | [diff] [blame] | 667 | return data |
Enrico Granata | b8cbe9c | 2012-02-23 23:26:48 +0000 | [diff] [blame] | 668 | |
Enrico Granata | 3f1052b | 2012-03-13 21:52:00 +0000 | [diff] [blame^] | 669 | # these classes below can be used by the data formatters to provide a consistent message that describes a given runtime-generated situation |
| 670 | class SpecialSituation_Description: |
| 671 | def message(self): |
| 672 | return '' |
| 673 | |
| 674 | class InvalidPointer_Description(SpecialSituation_Description): |
| 675 | |
| 676 | def __init__(self,nil): |
| 677 | self.is_nil = nil |
| 678 | |
| 679 | def message(self): |
| 680 | if self.is_nil: |
| 681 | return '@"<nil>"' |
| 682 | else: |
| 683 | return '<invalid pointer>' |
| 684 | |
| 685 | class InvalidISA_Description(SpecialSituation_Description): |
| 686 | |
| 687 | def __init__(self): |
| 688 | pass |
| 689 | |
| 690 | def message(self): |
| 691 | return '<not an Objective-C object>' |
| 692 | |