Ejemplo n.º 1
0
void
verify_alloc_records (void)
{
	int i;
	int total = 0;
	int holes = 0;
	int max_hole = 0;
	AllocRecord *prev = NULL;

	sgen_qsort (alloc_records, next_record, sizeof (AllocRecord), comp_alloc_record);
	printf ("------------------------------------DUMP RECORDS- %d %d---------------------------\n", next_record, alloc_count);
	for (i = 0; i < next_record; ++i) {
		AllocRecord *rec = alloc_records + i;
		int hole_size = 0;
		total += rec->size;
		if (prev) {
			if (rec_end (prev) > rec->address)
				printf ("WE GOT OVERLAPPING objects %p and %p\n", prev->address, rec->address);
			if ((rec->address - rec_end (prev)) >= 8)
				++holes;
			hole_size = rec->address - rec_end (prev);
			max_hole = MAX (max_hole, hole_size);
		}
		printf ("obj [%p, %p] size %d hole to prev %d reason %s seq %d tid %zx\n", rec->address, rec_end (rec), (int)rec->size, hole_size, get_reason_name (rec), rec->seq, (size_t)rec->tid);
		prev = rec;
	}
	printf ("SUMMARY total alloc'd %d holes %d max_hole %d\n", total, holes, max_hole);
}
Ejemplo n.º 2
0
void
dump_alloc_records (void)
{
	int i;
	sgen_qsort (alloc_records, next_record, sizeof (AllocRecord), comp_alloc_record);

	printf ("------------------------------------DUMP RECORDS----------------------------\n");
	for (i = 0; i < next_record; ++i) {
		AllocRecord *rec = alloc_records + i;
		printf ("obj [%p, %p] size %d reason %s seq %d tid %x\n", rec->address, rec_end (rec), (int)rec->size, get_reason_name (rec), rec->seq, (size_t)rec->tid);
	}
}
Ejemplo n.º 3
0
static void
compare_sorts (void *base, size_t nel, size_t width, int (*compar) (const void*, const void*))
{
	size_t len = nel * width;
	void *b1 = malloc (len);
	void *b2 = malloc (len);

	memcpy (b1, base, len);
	memcpy (b2, base, len);

	qsort (b1, nel, width, compar);
	sgen_qsort (b2, nel, width, compar);

	assert (!memcmp (b1, b2, len));

	free (b1);
	free (b2);
}
Ejemplo n.º 4
0
static void
compare_sorts (void *base, size_t nel, size_t width, int (*compar) (const void*, const void*))
{
    size_t len = nel * width;
    void *b1 = malloc (len);
    void *b2 = malloc (len);

    memcpy (b1, base, len);
    memcpy (b2, base, len);

    qsort (b1, nel, width, compar);
    sgen_qsort (b2, nel, width, compar);

    /* We can't assert that qsort and sgen_qsort produce the same results
     * because qsort is not guaranteed to be stable, so they will tend to differ
     * in adjacent equal elements. Instead, we assert that the array is sorted
     * according to the comparator.
     */
    for (size_t i = 0; i < nel - 1; ++i)
        assert (compar ((char *)b2 + i * width, (char *)b2 + (i + 1) * width) <= 0);

    free (b1);
    free (b2);
}