Пример #1
0
def main(argv):

    # Initialize new external memory list.
    util.msg('Populating external memory list')

    t1 = time.time()

    dirname = util.make_temp_name('em_list')

    em_list = pyrsistence.EMList(dirname)
    for i in xrange(0x1000):
        em_list.append(random.randrange(0x100000))

    t2 = time.time()
    util.msg('Done in %d sec.' % (t2 - t1))

    # Request several iterator objects to locate possible memory leaks.
    util.msg('Testing iterator')
    for i in xrange(0x1000):
        for item in em_list:
            pass

    t3 = time.time()
    util.msg('Done in %d sec.' % (t3 - t2))

    # Close and remove external memory list from disk.
    em_list.close()
    shutil.rmtree(dirname)

    return 0
Пример #2
0
def main(argv):

    # Initialize new external memory list.
    util.msg('Populating normal and external memory list')

    t1 = time.time()

    dirname = util.make_temp_name('em_list')

    l = []
    em_list = pyrsistence.EMList(dirname)
    for i in util.xrange(0x1000000):
        v = random.randrange(0x1000000)
        em_list.append(v)
        l.append(v)

    t2 = time.time()
    util.msg('Done in %d sec.' % (t2 - t1))

    util.msg('Verifying external memory list contents')

    for i in util.xrange(0x1000000):
        if em_list[i] != l[i]:
            util.msg(
                'FATAL! Mismatch in element %d: Got %#x but expected %#x' %
                (i, em_list[i], l[i]))

    t3 = time.time()
    util.msg('Done in %d sec.' % (t3 - t2))

    # Close and remove external memory list from disk.
    em_list.close()
    shutil.rmtree(dirname)

    return 0
Пример #3
0
def main(argv):

    # Initialize new external memory list.
    util.msg('Populating external memory list')

    t1 = time.time()

    dirname = util.make_temp_name('em_list')

    em_list = pyrsistence.EMList(dirname)
    for i in xrange(0x1000000):
        em_list.append(i)

    t2 = time.time()
    util.msg('Done in %d sec.' % (t2 - t1))

    # Close and remove external memory list from disk.
    em_list.close()
    shutil.rmtree(dirname)

    return 0
Пример #4
0
    def __init__(self, dirname, start_address, end_address):
        '''
        :param dirname: Directory where the shadow memory will be stored.
        :param start_address: Address of first byte in shadow memory.
        :param end_address: Address of last byte in shadow memory.
        '''

        # Compute size of shadow memory.
        size = end_address - start_address + 1

        # Initialize external memory list holding the shadow memory contents and
        # mark all elements as unanalyzed.
        shadow = pyrsistence.EMList(dirname)
        while len(shadow) < size:
            shadow.append(M_NONE)

        self.start_address = start_address
        self.end_address = end_address
        self.size = end_address - start_address + 1
        self.dirname = dirname
        self.shadow = shadow
Пример #5
0
    def _make_shadow_memory(self, dirname, memory_range):
        '''
        Make shadow memory for the given memory range.

        :param dirname: Directory where external memory list will be stored. The
            directory is created if it does not exist.
        :param memory_range: Memory range to be shadowed.
        :returns: External memory list holding *memory_range*'s shadow bytes.
        :rtype: ``pyrsistence.EMList``

        .. warning:: This is a private function, don't use it directly.
        '''

        start_address, end_address = memory_range
        filename = '%s/%#x-%#x' % (dirname, start_address, end_address)

        shadow = pyrsistence.EMList(filename)
        size = end_address - start_address + 1
        while len(shadow) < size:
            shadow.append(M_NONE)

        return shadow