Add DEBUG_RELOCATOR parts

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-08-28 11:34:33 +02:00
parent 4aa5499064
commit d1dce5d356

View file

@ -1283,6 +1283,25 @@ grub_relocator_alloc_chunk_addr (struct grub_relocator *rel,
chunk->srcv = grub_map_memory (chunk->src, chunk->size); chunk->srcv = grub_map_memory (chunk->src, chunk->size);
*out = chunk; *out = chunk;
#ifdef DEBUG_RELOCATOR
{
grub_mm_region_t r;
grub_mm_header_t p;
grub_memset (chunk->srcv, 0xfa, chunk->size);
for (r = grub_mm_base; r; r = r->next)
{
p = r->first;
do
{
if ((grub_addr_t) p < (grub_addr_t) (r + 1)
|| (grub_addr_t) p >= (grub_addr_t) (r + 1) + r->size)
grub_fatal (__FILE__ ":%d: out of range pointer: %p\n", __LINE__, p);
p = p->next;
}
while (p != r->first);
}
}
#endif
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
@ -1416,6 +1435,26 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
rel->chunks->next); rel->chunks->next);
chunk->srcv = grub_map_memory (chunk->src, chunk->size); chunk->srcv = grub_map_memory (chunk->src, chunk->size);
*out = chunk; *out = chunk;
#ifdef DEBUG_RELOCATOR
{
grub_mm_region_t r;
grub_mm_header_t p;
grub_memset (chunk->srcv, 0xfa, chunk->size);
for (r = grub_mm_base; r; r = r->next)
{
p = r->first;
do
{
if ((grub_addr_t) p < (grub_addr_t) (r + 1)
|| (grub_addr_t) p >= (grub_addr_t) (r + 1) + r->size)
grub_fatal (__FILE__ "%d: out of range pointer: %p\n", __LINE__, p);
p = p->next;
}
while (p != r->first);
}
}
#endif
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }