From 55d7626db75b1b5323aa5ba16b3cbc0a985462fe Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 11 Jul 2007 20:56:10 +0000 Subject: 2007-07-11 Joel Sherrill * libcsupport/src/malloc.c: Clean up Malloc debug code. * score/include/rtems/score/heap.h: Spacing. * score/inline/rtems/score/thread.inl: * score/src/heapfree.c. Clean up and add explicit check of the address being freed actually being in the heap. * score/src/heapwalk.c: Switch to printk and do not call abort. --- cpukit/score/inline/rtems/score/thread.inl | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'cpukit/score/inline') diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl index 44d626d71c..dbd95c6ca3 100644 --- a/cpukit/score/inline/rtems/score/thread.inl +++ b/cpukit/score/inline/rtems/score/thread.inl @@ -6,7 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2006. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -139,10 +139,47 @@ RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void ) * This routine prevents dispatching. */ +#if defined(RTEMS_HEAVY_STACK_DEBUG) || defined(RTEMS_HEAVY_MALLOC_DEBUG) + #include + #include + #include + #include +#endif + RTEMS_INLINE_ROUTINE void _Thread_Disable_dispatch( void ) { + extern boolean rtems_stack_checker_is_blown( void ); + extern void malloc_walk(size_t, size_t); + + /* + * This check is very brutal to system performance but is very helpful + * at finding blown stack problems. If you have a stack problem and + * need help finding it, then uncomment this code. Every system + * call will check the stack and since mutexes are used frequently + * in most systems, you might get lucky. + */ + #if defined(RTEMS_HEAVY_STACK_DEBUG) + if (_System_state_Is_up(_System_state_Get()) && (_ISR_Nest_level == 0)) { + if ( rtems_stack_checker_is_blown() ) { + printk( "Stack blown!!\n" ); + rtems_fatal_error_occurred( 99 ); + } + } + #endif + _Thread_Dispatch_disable_level += 1; RTEMS_COMPILER_MEMORY_BARRIER(); + + /* + * This check is even more brutal than the other one. This enables + * malloc heap integrity checking upon entry to every system call. + */ + #if defined(RTEMS_HEAVY_MALLOC_DEBUG) + if ( _Thread_Dispatch_disable_level == 1 ) { + extern Heap_Control RTEMS_Malloc_Heap; + _Heap_Walk( &RTEMS_Malloc_Heap,99, FALSE ); + } + #endif } /** -- cgit v1.2.3