Example #1
0
    def categorize_refs(self, usage_set, level=0, detail=None):
        priv_type = caching_lookup_type('GdkImagePrivateX11').pointer()
        priv_data = WrappedPointer(self._gdbval['windowing_data'].cast(priv_type))

        usage_set.set_addr_category(priv_data.as_address(),
                                    Category('GType', 'GdkImagePrivateX11', ''),
                                    level=level+1, debug=True)

        ximage = WrappedPointer(priv_data.field('ximage'))
        dims = '%sw x %sh x %sbpp' % (ximage.field('width'),
                                      ximage.field('height'),
                                      ximage.field('depth'))
        usage_set.set_addr_category(ximage.as_address(),
                                    Category('X11', 'Image', dims),
                                    level=level+2, debug=True)

        usage_set.set_addr_category(int(ximage.field('data')),
                                    Category('X11', 'Image data', dims),
                                    level=level+2, debug=True)
Example #2
0
    def categorize_refs(self, usage_set, level=0, detail=None):
        priv_type = caching_lookup_type('GdkImagePrivateX11').pointer()
        priv_data = WrappedPointer(
            self._gdbval['windowing_data'].cast(priv_type))

        usage_set.set_addr_category(priv_data.as_address(),
                                    Category('GType', 'GdkImagePrivateX11',
                                             ''),
                                    level=level + 1,
                                    debug=True)

        ximage = WrappedPointer(priv_data.field('ximage'))
        dims = '%sw x %sh x %sbpp' % (ximage.field('width'),
                                      ximage.field('height'),
                                      ximage.field('depth'))
        usage_set.set_addr_category(ximage.as_address(),
                                    Category('X11', 'Image', dims),
                                    level=level + 2,
                                    debug=True)

        usage_set.set_addr_category(int(ximage.field('data')),
                                    Category('X11', 'Image data', dims),
                                    level=level + 2,
                                    debug=True)
Example #3
0
    def categorize_refs(self, usage_set, level=0, detail=None):
        # This gives us access to the freetype library:
        FT_Library = WrappedPointer(self._gdbval['library'])

        # This is actually a "struct  FT_LibraryRec_", in FreeType's
        #   include/freetype/internal/ftobjs.h
        # print FT_Library._gdbval.dereference()

        usage_set.set_addr_category(FT_Library.as_address(),
                                    Category('FreeType', 'Library', ''),
                                    level=level+1, debug=True)

        usage_set.set_addr_category(int(FT_Library.field('raster_pool')),
                                    Category('FreeType', 'raster_pool', ''),
                                    level=level+2, debug=True)
Example #4
0
    def categorize_refs(self, usage_set, level=0, detail=None):
        # This gives us access to the freetype library:
        FT_Library = WrappedPointer(self._gdbval['library'])

        # This is actually a "struct  FT_LibraryRec_", in FreeType's
        #   include/freetype/internal/ftobjs.h
        # print FT_Library._gdbval.dereference()

        usage_set.set_addr_category(FT_Library.as_address(),
                                    Category('FreeType', 'Library', ''),
                                    level=level + 1,
                                    debug=True)

        usage_set.set_addr_category(int(FT_Library.field('raster_pool')),
                                    Category('FreeType', 'raster_pool', ''),
                                    level=level + 2,
                                    debug=True)
Example #5
0
    def invoke(self, args, from_tty):
        from heap.glibc import iter_mappings,lookup_symbol
        from heap import WrappedPointer,caching_lookup_type
        SIZE_SZ = caching_lookup_type('size_t').sizeof
        type_size_t = gdb.lookup_type('size_t')
        type_size_t_ptr = type_size_t.pointer()

        arg_list = gdb.string_to_argv(args)
        parser = argparse.ArgumentParser(add_help=True, usage="objdump  [-v][-s SIZE] <ADDR>")
        parser.add_argument('addr', metavar='ADDR', type=str, nargs=1, help="Target address")
        parser.add_argument('-s', dest='size', default=None, help='Total dump size')
        parser.add_argument('-v', dest='verbose', action="store_true", default=False, help='Verbose')
        
        try:
            args_dict = parser.parse_args(args=arg_list)
        except:
            return

        addr_arg = args_dict.addr[0]
        if addr_arg.startswith('0x'):
            addr = int(addr_arg, 16)
        else:
            addr = int(addr_arg)

        if args_dict.size:
            if args_dict.size.startswith('0x'):
                total_size = int(args_dict.size, 16)
            else:
                total_size = int(args_dict.size)
        else:
            total_size = 10 * SIZE_SZ

        if args_dict.verbose:
            print('Searching in the following object ranges')
            print('-------------------------------------------------')
        text = [] #list of tuples (start, end, pathname, ...) of a valid memory map
        #XXX why pid would be 0?
        for pid in [ o.pid for o in gdb.inferiors() if o.pid !=0 ]:
            for r in iter_mappings(pid):
                if args_dict.verbose: print("%s - %s : %s" % (hex(r[0]), hex(r[1]), r[2]))
                text.append((r[0], r[1], r[2]))

        print('\nDumping Object at address %s' % fmt_addr(addr))
        print('-------------------------------------------------')
        
        for a in range(addr, addr + (total_size * SIZE_SZ), SIZE_SZ):
            ptr = WrappedPointer(gdb.Value(a).cast(type_size_t_ptr))
            #dereference first, at the first access denied bail out, dont go further
            try:
                val = ptr.dereference()
                found = False
                val_int = int(str(val.cast(type_size_t))) #XXX Error occurred in Python command: invalid literal for int() with base 10: '0x418'
                pathname = ""
                for t in text:
                    if val_int >= t[0] and val_int < t[1]:
                        found = True
                        pathname = t[2]
                
                if found:
                    sym = lookup_symbol(val_int)
                    if sym:
                        out_line = "%s => %s (%s in %s)" % (fmt_addr(ptr.as_address()), fmt_addr(val_int), sym, pathname )
                    else:
                        out_line = "%s => %s (%s)" % (fmt_addr(ptr.as_address()), fmt_addr(val_int), pathname )
                else:
                    out_line = "%s => %s" % (fmt_addr(ptr.as_address()), fmt_addr(val_int) )

                #if it's not a symbol, try a string
                # try just a few chars
                #if not found:

                print(out_line)
            except gdb.MemoryError:
                print("Error accessing memory at %s" % fmt_addr(ptr.as_address()))
                return