Exemplo n.º 1
0
 def invoke(self, args, from_tty):
     args = args.split()
     if args:
         only_size = int(args[0])
         only_cat = args[1]
         only_str = args[2]
     else:
         only_size = None
         only_cat = None
         only_str = None
     print('Used chunks of memory on heap')
     print('-----------------------------')
     ms = glibc_arenas.get_ms()
     for i, u in enumerate(lazily_get_usage_list()):
         # if not chunk.is_inuse():
         #     continue
         # size = chunk.chunksize()
         # mem = chunk.as_mem()
         # u = Usage(mem, size)
         size = u.size
         if only_size and size != only_size:
             continue
         category = categorize(u, None)
         if only_cat and category.kind != only_cat:
             continue
         hd = hexdump_as_bytes(u.start, min(size, 64))
         if only_str and  only_str not in hd:
             continue
         print ('%6i: %s -> %s %8i bytes %20s |%s'
                % (i,
                   fmt_addr(u.start),
                   fmt_addr(u.start + size),
                   size, category, hd))
     print()
Exemplo n.º 2
0
 def invoke(self, args, from_tty):
     print('Used chunks of memory on heap')
     print('-----------------------------')
     ms = glibc_arenas.get_ms()
     for i, chunk in enumerate(ms.iter_chunks()):
         if not chunk.is_inuse():
             continue
         size = chunk.chunksize()
         mem = chunk.as_mem()
         u = Usage(mem, size)
         category = categorize(u, None)
         hd = hexdump_as_bytes(mem, 32)
         print('%6i: %s -> %s %8i bytes %20s |%s' %
               (i, fmt_addr(chunk.as_mem()),
                fmt_addr(chunk.as_mem() + size - 1), size, category, hd))
     print()
Exemplo n.º 3
0
    def invoke(self, args, from_tty):
        print 'Free chunks of memory on heap'
        print '-----------------------------'
        ms = glibc_arenas.get_ms()
        total_size = 0
        for i, chunk in enumerate(ms.iter_free_chunks()):
            size = chunk.chunksize()
            total_size += size
            mem = chunk.as_mem()
            u = Usage(mem, size)
            category = categorize(u, None)
            hd = hexdump_as_bytes(mem, 32)

            print('%6i: %s -> %s %8i bytes %20s |%s' %
                  (i, fmt_addr(chunk.as_mem()),
                   fmt_addr(chunk.as_mem() + size - 1), size, category, hd))
        print "Total size: %s" % total_size
Exemplo n.º 4
0
 def invoke(self, args, from_tty):
     print('Used chunks of memory on heap')
     print('-----------------------------')
     ms = glibc_arenas.get_ms()
     for i, chunk in enumerate(ms.iter_chunks()):
         if not chunk.is_inuse():
             continue
         size = chunk.chunksize()
         mem = chunk.as_mem()
         u = Usage(mem, size)
         category = categorize(u, None)
         hd = hexdump_as_bytes(mem, 32)
         print ('%6i: %s -> %s %8i bytes %20s |%s'
                % (i,
                   fmt_addr(chunk.as_mem()),
                   fmt_addr(chunk.as_mem()+size-1),
                   size, category, hd))
     print()
Exemplo n.º 5
0
    def invoke(self, args, from_tty):
        print 'Free chunks of memory on heap'
        print '-----------------------------'
        ms = glibc_arenas.get_ms()
        total_size = 0
        for i, chunk in enumerate(ms.iter_free_chunks()):
            size = chunk.chunksize()
            total_size += size
            mem = chunk.as_mem()
            u = Usage(mem, size)
            category = categorize(u, None)
            hd = hexdump_as_bytes(mem, 32)

            print ('%6i: %s -> %s %8i bytes %20s |%s'
                   % (i,
                      fmt_addr(chunk.as_mem()),
                      fmt_addr(chunk.as_mem()+size-1),
                      size, category, hd))
        print "Total size: %s" % total_size
Exemplo n.º 6
0
    def invoke(self, args, from_tty):
        print(repr(args))
        arg_list = gdb.string_to_argv(args)

        chars_only = True

        if len(arg_list) == 2:
            addr_arg = arg_list[0]
            chars_only = True if args[1] == '-c' else False
        else:
            addr_arg = args

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

        # assume that paging will cut in and the user will quit at some point:
        size = 32
        while True:
            hd = hexdump_as_bytes(addr, size, chars_only=chars_only)
            print ('%s -> %s %s' % (fmt_addr(addr), fmt_addr(addr + size -1), hd))
            addr += size
Exemplo n.º 7
0
    def invoke(self, args, from_tty):
        print(repr(args))
        arg_list = gdb.string_to_argv(args)

        chars_only = True

        if len(arg_list) == 2:
            addr_arg = arg_list[0]
            chars_only = True if args[1] == '-c' else False
        else:
            addr_arg = args

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

        # assume that paging will cut in and the user will quit at some point:
        size = 32
        while True:
            hd = hexdump_as_bytes(addr, size, chars_only=chars_only)
            print ('%s -> %s %s' % (fmt_addr(addr), fmt_addr(addr + size -1), hd))
            addr += size