diff --git a/pwndbg/dt_backup.txt b/pwndbg/dt_backup.txt deleted file mode 100644 index e9ed1c0eb..000000000 --- a/pwndbg/dt_backup.txt +++ /dev/null @@ -1,122 +0,0 @@ - - -def get_type(v): - t = v.type - while not t.name: - if t.code == gdb.TYPE_CODE_PTR: - t = t.target() - return t.name - -def get_typename(t): - n = '' - o = t - p = '' - if t.code == gdb.TYPE_CODE_ARRAY: - t = t.target() - while t.code == gdb.TYPE_CODE_PTR: - t = t.target() - p += '*' - name = t.name - if not p: - return name - return name + ' ' + p - -def get_arrsize(f): - t = f.type - if t.code != gdb.TYPE_CODE_ARRAY: - return 0 - t2 = t.target() - s = t2.sizeof - return int(t.sizeof / t2.sizeof) - -def get_field_by_name(obj, field): - # Dereference once - if obj.type.code == gdb.TYPE_CODE_PTR: - obj = obj.dereference() - for f in re.split('(->|\.|\[\d+\])', field): - if not f: continue - if f == '->': - obj = obj.dereference() - elif f == '.': - pass - elif f.startswith('['): - n = int(f.strip('[]')) - obj = obj.cast(obj.dereference().type.pointer()) - obj += n - obj = obj.dereference() - else: - obj = obj[f] - return obj - - - -def happy(typename): - prefix = '' - if 'unsigned' in typename: - prefix = 'u' - typename = typename.replace('unsigned ', '') - return prefix + { - 'char': 'char', - 'short int': 'short', - 'long int': 'long', - 'int': 'int', - 'long long': 'longlong', - 'float': 'float', - 'double': 'double' - }[typename] - -def dt(name, addr=None, obj = None, field=None): - """ - Dump out a structure type Windbg style. - """ - # Return value is a list of strings.of - # We concatenate at the end. - rv = [] - - # Lookup the type name specified by the user - t = gdb.lookup_type(name) - - # If it's not a struct (e.g. int or char*), bail - if t.code not in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_TYPEDEF): - raise Exception("Not a structure: %s" % t) - - # If an address was specified, create a Value of the - # specified type at that address. - if addr is not None: - obj = gdb.Value(addr).cast(t.pointer()).dereference() - - # Header, optionally include the name - header = name - if obj: header = "%s @ %s" (header, str(obj.address)) - rv.append(name) - - for name, field in t.items(): - # Get the actual name of the type, e.g. char*** - t = get_typename(field.type.strip_typedefs()) - - # How many entries are in the array, if any - n = get_arrsize(field) or '' - if n: n = '[%i]' % n - - # Offset into the parent structure - o = field.bitpos/8 - - line = " +0x%04x %-20s" (o, name) - - if obj is None: - line ='%s: %s' % (line, str(field.type)) - if obj: - # Get the actual field Value out of the object - v = obj[name] - - # Strip off whatever typedef crap it has - vt = v.type - if vt.code == gdb.TYPE_CODE_TYPEDEF: - vt = vt.strip_typedefs() - if vt.code == gdb.TYPE_CODE_INT: - v = hex(int(v)) - print(" +0x%04x %-20s : %s" % (o, name, v)) - - rv.append(field) - if obj is None: print("}") - diff --git a/pwndbg/string.pu b/pwndbg/string.pu deleted file mode 100644 index e69de29bb..000000000