2010-06-23 Joel Sherrill <joel.sherrilL@OARcorp.com>

* libmisc/stackchk/check.c: Clean up to improve coverage.
This commit is contained in:
Joel Sherrill
2010-06-23 18:18:42 +00:00
parent 0ed275ec44
commit 2d637b20f6
2 changed files with 32 additions and 22 deletions

View File

@@ -116,12 +116,13 @@ static inline bool Stack_check_Frame_pointer_in_range(
#define Stack_check_usable_stack_size(_the_stack) \
((_the_stack)->size - sizeof(Stack_check_Control))
/*
* Do we have an interrupt stack?
* XXX it would sure be nice if the interrupt stack were also
* stored in a "stack" structure!
*/
Stack_Control Stack_check_Interrupt_stack;
#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
/*
* Did RTEMS allocate the interrupt stack? If so, put it in
* Stack_Control format.
*/
Stack_Control Stack_check_Interrupt_stack;
#endif
/*
* Fill an entire stack area with BYTE_PATTERN. This will be used
@@ -381,28 +382,28 @@ void Stack_check_Dump_threads_usage(
Stack_Control *stack;
char name[5];
if ( !the_thread )
return;
if ( !print_handler )
return;
/*
* The pointer passed in for the_thread is guaranteed to be non-NULL from
* rtems_iterate_over_all_threads() so no need to check it here.
*/
/*
* Obtain interrupt stack information
*/
if (the_thread == (Thread_Control *) -1) {
if (Stack_check_Interrupt_stack.area) {
#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
if (the_thread == (Thread_Control *) -1) {
if (!Stack_check_Interrupt_stack.area)
return;
stack = &Stack_check_Interrupt_stack;
the_thread = 0;
current = 0;
} else
#else
{
stack = &the_thread->Start.Initial_stack;
current = (void *)_CPU_Context_Get_SP( &the_thread->Registers );
}
else
return;
} else {
stack = &the_thread->Start.Initial_stack;
current = (void *)_CPU_Context_Get_SP( &the_thread->Registers );
}
#endif
low = Stack_check_usable_stack_start(stack);
size = Stack_check_usable_stack_size(stack);
@@ -468,6 +469,9 @@ void rtems_stack_checker_report_usage_with_plugin(
rtems_printk_plugin_t print
)
{
if ( !print )
return;
print_context = context;
print_handler = print;
@@ -479,8 +483,10 @@ void rtems_stack_checker_report_usage_with_plugin(
/* iterate over all threads and dump the usage */
rtems_iterate_over_all_threads( Stack_check_Dump_threads_usage );
/* dump interrupt stack info if any */
Stack_check_Dump_threads_usage((Thread_Control *) -1);
#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
/* dump interrupt stack info if any */
Stack_check_Dump_threads_usage((Thread_Control *) -1);
#endif
print_context = NULL;
print_handler = NULL;