def summary(self): group = get_header_ptr(self.value['headerAndGroup_'], self.otc.ObjectGroup_ptr_t) classp = get_header_ptr(group['headerAndClasp_'], self.otc.JSClass_ptr_t) non_native = classp['flags'] & self.otc.class_NON_NATIVE # Use GDB to format the class name, but then strip off the address # and the quotes. class_name = str(classp['name']) m = gdb_string_regexp.match(class_name) if m: class_name = m.group(1) if non_native: return '[object {}]'.format(class_name) else: native = self.value.cast(self.otc.NativeObject_ptr_t) shape = deref(native['shape_']) baseshape = get_header_ptr(shape['headerAndBase_'], self.otc.BaseShape_ptr_t) flags = baseshape['flags'] is_delegate = bool(flags & self.otc.flag_DELEGATE) name = None if class_name == 'Function': function = self.value concrete_type = function.type.strip_typedefs() if concrete_type.code == gdb.TYPE_CODE_REF: function = function.address function = function.cast(self.otc.func_ptr_type) atom = deref(function['atom_']) name = str(atom) if atom else '<unnamed>' return '[object {}{}]{}'.format(class_name, ' ' + name if name else '', ' delegate' if is_delegate else '')
def summary(self): shape = get_header_ptr(self.value, self.otc.Shape_ptr_t) baseshape = get_header_ptr(shape, self.otc.BaseShape_ptr_t) classp = get_header_ptr(baseshape, self.otc.JSClass_ptr_t) non_native = classp["flags"] & self.otc.class_NON_NATIVE # Use GDB to format the class name, but then strip off the address # and the quotes. class_name = str(classp["name"]) m = gdb_string_regexp.match(class_name) if m: class_name = m.group(1) if non_native: return "[object {}]".format(class_name) else: flags = shape["objectFlags_"]["flags_"] used_as_prototype = bool(flags & self.otc.objectflag_IsUsedAsPrototype) name = None if class_name == "Function": function = self.value concrete_type = function.type.strip_typedefs() if concrete_type.code == gdb.TYPE_CODE_REF: function = function.address function = function.cast(self.otc.func_ptr_type) atom = deref(function["atom_"]) name = str(atom) if atom else "<unnamed>" return "[object {}{}]{}".format( class_name, " " + name if name else "", " used_as_prototype" if used_as_prototype else "", )
def summary(self): group = get_header_ptr(self.value, self.otc.ObjectGroup_ptr_t) classp = get_header_ptr(group, self.otc.JSClass_ptr_t) non_native = classp["flags"] & self.otc.class_NON_NATIVE # Use GDB to format the class name, but then strip off the address # and the quotes. class_name = str(classp["name"]) m = gdb_string_regexp.match(class_name) if m: class_name = m.group(1) if non_native: return "[object {}]".format(class_name) else: native = self.value.cast(self.otc.NativeObject_ptr_t) shape = deref(native["shape_"]) baseshape = get_header_ptr(shape, self.otc.BaseShape_ptr_t) flags = baseshape["flags"] is_delegate = bool(flags & self.otc.flag_DELEGATE) name = None if class_name == "Function": function = self.value concrete_type = function.type.strip_typedefs() if concrete_type.code == gdb.TYPE_CODE_REF: function = function.address function = function.cast(self.otc.func_ptr_type) atom = deref(function["atom_"]) name = str(atom) if atom else "<unnamed>" return "[object {}{}]{}".format( class_name, " " + name if name else "", " delegate" if is_delegate else "", )
def to_string(self): code = int(self.value['code_']) & 0xffffffff desc = str(get_header_ptr(self.value, self.cache.JSString_ptr_t)) if code == InSymbolRegistry: return "Symbol.for({})".format(desc) elif code == UniqueSymbol: return "Symbol({})".format(desc) elif code == PrivateNameSymbol: return "#{}".format(desc) else: # Well-known symbol. Strip off the quotes added by the JSString * # pretty-printer. assert desc[0] == '"' assert desc[-1] == '"' return desc[1:-1]