*** empty log message ***

This commit is contained in:
Joel Sherrill
2009-09-16 22:14:11 +00:00
parent e0b664382e
commit 8a2944aba4

View File

@@ -28,26 +28,36 @@
#include <rtems/score/interr.h>
#include <rtems/bspIo.h>
static void _Heap_Walk_printk( int source, bool dump, bool error, const char *fmt, ... )
typedef (*Heap_Walk_printer)(int, bool, const char*, ...);
static void _Heap_Walk_print_nothing(
int source,
bool error,
const char *fmt,
...
)
{
if ( dump ) {
va_list ap;
/* Do nothing */
}
if ( error ) {
printk( "FAIL[%d]: ", source );
} else {
printk( "PASS[%d]: ", source );
}
static void _Heap_Walk_print( int source, bool error, const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
vprintk( fmt, ap );
va_end( ap );
if ( error ) {
printk( "FAIL[%d]: ", source );
} else {
printk( "PASS[%d]: ", source );
}
va_start( ap, fmt );
vprintk( fmt, ap );
va_end( ap );
}
static bool _Heap_Walk_check_free_list(
int source,
bool dump,
Heap_Walk_printer printer,
Heap_Control *heap
)
{
@@ -59,9 +69,8 @@ static bool _Heap_Walk_check_free_list(
while ( free_block != free_list_tail ) {
if ( !_Heap_Is_block_in_heap( heap, free_block ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"free block 0x%08x: not in heap\n",
free_block
@@ -73,9 +82,8 @@ static bool _Heap_Walk_check_free_list(
if (
!_Heap_Is_aligned( _Heap_Alloc_area_of_block( free_block ), page_size )
) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"free block 0x%08x: alloc area not page aligned\n",
free_block
@@ -85,9 +93,8 @@ static bool _Heap_Walk_check_free_list(
}
if ( _Heap_Is_used( free_block ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"free block 0x%08x: is used\n",
free_block
@@ -97,9 +104,8 @@ static bool _Heap_Walk_check_free_list(
}
if ( free_block->prev != prev_block ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"free block 0x%08x: invalid previous block 0x%08x\n",
free_block,
@@ -136,7 +142,7 @@ static bool _Heap_Walk_is_in_free_list(
static bool _Heap_Walk_check_control(
int source,
bool dump,
Heap_Walk_printer printer,
Heap_Control *heap
)
{
@@ -147,9 +153,8 @@ static bool _Heap_Walk_check_control(
Heap_Block *const first_block = heap->first_block;
Heap_Block *const last_block = heap->last_block;
_Heap_Walk_printk(
(*printer)(
source,
dump,
false,
"page size %u, min block size %u\n"
"\tarea begin 0x%08x, area end 0x%08x\n"
@@ -162,15 +167,14 @@ static bool _Heap_Walk_check_control(
);
if ( page_size == 0 ) {
_Heap_Walk_printk( source, dump, true, "page size is zero\n" );
(*printer)( source, true, "page size is zero\n" );
return false;
}
if ( !_Addresses_Is_aligned( (void *) page_size ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"page size %u not CPU aligned\n",
page_size
@@ -180,9 +184,8 @@ static bool _Heap_Walk_check_control(
}
if ( !_Heap_Is_aligned( min_block_size, page_size ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"min block size %u not page aligned\n",
min_block_size
@@ -194,9 +197,8 @@ static bool _Heap_Walk_check_control(
if (
!_Heap_Is_aligned( _Heap_Alloc_area_of_block( first_block ), page_size )
) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"first block 0x%08x: alloc area not page aligned\n",
first_block
@@ -206,9 +208,8 @@ static bool _Heap_Walk_check_control(
}
if ( !_Heap_Is_prev_used( first_block ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"first block: HEAP_PREV_BLOCK_USED is cleared\n"
);
@@ -217,9 +218,8 @@ static bool _Heap_Walk_check_control(
}
if ( first_block->prev_size != page_size ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"first block: prev size %u != page size %u\n",
first_block->prev_size,
@@ -230,9 +230,8 @@ static bool _Heap_Walk_check_control(
}
if ( _Heap_Is_free( last_block ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"last block: is free\n"
);
@@ -240,12 +239,12 @@ static bool _Heap_Walk_check_control(
return false;
}
return _Heap_Walk_check_free_list( source, dump, heap );
return _Heap_Walk_check_free_list( source, printer, heap );
}
static bool _Heap_Walk_check_free_block(
int source,
bool dump,
Heap_Walk_printer printer,
Heap_Control *heap,
Heap_Block *block
)
@@ -258,9 +257,8 @@ static bool _Heap_Walk_check_free_block(
uintptr_t const block_size = _Heap_Block_size( block );
Heap_Block *const next_block = _Heap_Block_at( block, block_size );
_Heap_Walk_printk(
(*printer)(
source,
dump,
false,
"block 0x%08x: prev 0x%08x%s, next 0x%08x%s\n",
block,
@@ -275,9 +273,8 @@ static bool _Heap_Walk_check_free_block(
);
if ( block_size != next_block->prev_size ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: size %u != size %u (in next block 0x%08x)\n",
block,
@@ -290,9 +287,8 @@ static bool _Heap_Walk_check_free_block(
}
if ( !prev_used ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: two consecutive blocks are free\n",
block
@@ -302,9 +298,8 @@ static bool _Heap_Walk_check_free_block(
}
if ( !_Heap_Walk_is_in_free_list( heap, block ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: free block not in free list\n",
block
@@ -326,12 +321,14 @@ bool _Heap_Walk(
uintptr_t const min_block_size = heap->min_block_size;
Heap_Block *const last_block = heap->last_block;
Heap_Block *block = heap->first_block;
Heap_Walk_printer printer = dump ?
_Heap_Walk_print : _Heap_Walk_print_nothing;
if ( !_System_state_Is_up( _System_state_Get() ) ) {
return true;
}
if ( !_Heap_Walk_check_control( source, dump, heap ) ) {
if ( !_Heap_Walk_check_control( source, printer, heap ) ) {
return false;
}
@@ -343,18 +340,16 @@ bool _Heap_Walk(
uintptr_t const next_block_begin = (uintptr_t) next_block;
if ( prev_used ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
false,
"block 0x%08x: size %u\n",
block,
block_size
);
} else {
_Heap_Walk_printk(
(*printer)(
source,
dump,
false,
"block 0x%08x: size %u, prev_size %u\n",
block,
@@ -364,9 +359,8 @@ bool _Heap_Walk(
}
if ( !_Heap_Is_block_in_heap( heap, next_block ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: next block 0x%08x not in heap\n",
block,
@@ -377,9 +371,8 @@ bool _Heap_Walk(
}
if ( !_Heap_Is_aligned( block_size, page_size ) ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: block size %u not page aligned\n",
block,
@@ -390,9 +383,8 @@ bool _Heap_Walk(
}
if ( block_size < min_block_size ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: size %u < min block size %u\n",
block,
@@ -404,9 +396,8 @@ bool _Heap_Walk(
}
if ( next_block_begin <= block_begin ) {
_Heap_Walk_printk(
(*printer)(
source,
dump,
true,
"block 0x%08x: next block 0x%08x is not a successor\n",
block,
@@ -417,7 +408,7 @@ bool _Heap_Walk(
}
if ( !_Heap_Is_prev_used( next_block ) ) {
if ( !_Heap_Walk_check_free_block( source, dump, heap, block ) ) {
if ( !_Heap_Walk_check_free_block( source, printer, heap, block ) ) {
return false;
}
}