Revert "libmisc/stackchk: Change stack checker reporter function signatures"

This reverts commit c1aa06dbd2.

Extending the rtems_stack_checker_info like this breaks the existing
visitor API used by rtems_stack_checker_iterate().  After review, using
an information structure contradicts the intention of the reporter to
allow a minimal reporting.  Filling up the information structure with
all the details would pull in several dependencies, like
_Thread_Get_name().  The API should be improved to provide the user with
the necessary information from the TCB without having to access members
directly.
This commit is contained in:
Sebastian Huber
2024-10-18 02:08:22 +02:00
committed by Joel Sherrill
parent b8bd1a1ce3
commit 4c75bd88f3
4 changed files with 49 additions and 55 deletions

View File

@@ -132,23 +132,6 @@ typedef struct {
* UINTPTR_MAX.
*/
uintptr_t used;
/**
* This member points to the currently executing thread which is being
* context switched out.
*/
const rtems_tcb *running;
/**
* This member points to the next executing thread which will be
* context switched out.
*/
const rtems_tcb *heir;
/**
* This member checks if the pattern is still valid or not.
*/
bool pattern_ok;
} rtems_stack_checker_info;
/**
@@ -223,20 +206,30 @@ void rtems_stack_checker_switch_extension(
/**
* @brief A Quiet Version of Stack Checker Reporter.
*
* @param[in] info is the stack information.
* @param[in] running running points to the currently executing thread which
* is being context switched out.
*
* @param[in] pattern_ok bool variable to check if the pattern is
* still valid or not
*/
void rtems_stack_checker_reporter_quiet(
const rtems_stack_checker_info *info
const rtems_tcb *running,
bool pattern_ok
);
/**
* @brief The Default Function to Report a Blown Stack.
*
* @param[in] info is the stack information.
* @param[in] running running points to the currently executing thread which
* is being context switched out.
*
* @param[in] pattern_ok bool variable to check if the pattern is
* still valid or not
*/
void rtems_stack_checker_reporter_print_details(
const rtems_stack_checker_info *info
const rtems_tcb *running,
bool pattern_ok
);
/**
@@ -261,10 +254,15 @@ void rtems_stack_checker_reporter_print_details(
/**
* @brief The Stack Checker Reporter Initialization Handler.
*
* @param[in] info is the stack information.
* @param[in] running running points to the currently executing thread which
* is being context switched out.
*
* @param[in] pattern_ok bool variable to check if the pattern is
* still valid or not.
*/
typedef void (*Stack_checker_Reporter_handler)(
const rtems_stack_checker_info *info
const rtems_tcb *running,
bool pattern_ok
);
/**

View File

@@ -262,21 +262,22 @@ void rtems_stack_checker_begin_extension( Thread_Control *executing )
* the following message out.
*/
void rtems_stack_checker_reporter_print_details(
const rtems_stack_checker_info *info
const Thread_Control *running,
bool pattern_ok
)
{
const Stack_Control *stack = &info->running->Start.Initial_stack;
const Stack_Control *stack = &running->Start.Initial_stack;
void *pattern_area = Stack_check_Get_pattern(stack);
char name[2 * THREAD_DEFAULT_MAXIMUM_NAME_SIZE];
printk("BLOWN STACK!!!\n");
printk("task control block: 0x%08" PRIxPTR "\n", (intptr_t) info->running);
printk("task ID: 0x%08lx\n", (unsigned long) info->running->Object.id);
printk("task control block: 0x%08" PRIxPTR "\n", (intptr_t) running);
printk("task ID: 0x%08lx\n", (unsigned long) running->Object.id);
printk(
"task name: 0x%08" PRIx32 "\n",
info->running->Object.name.name_u32
running->Object.name.name_u32
);
_Thread_Get_name(info->running, name, sizeof(name));
_Thread_Get_name(running, name, sizeof(name));
printk("task name string: %s\n", name);
printk(
"task stack area (%lu Bytes): 0x%08" PRIxPTR " .. 0x%08" PRIxPTR "\n",
@@ -284,7 +285,7 @@ void rtems_stack_checker_reporter_print_details(
(intptr_t) stack->area,
(intptr_t) ((char *) stack->area + stack->size)
);
if (!info->pattern_ok) {
if (!pattern_ok) {
printk(
"damaged pattern area (%lu Bytes): 0x%08" PRIxPTR " .. 0x%08" PRIxPTR "\n",
(unsigned long) SANITY_PATTERN_SIZE_BYTES,
@@ -304,17 +305,18 @@ void rtems_stack_checker_reporter_print_details(
rtems_fatal(
RTEMS_FATAL_SOURCE_STACK_CHECKER,
info->running->Object.name.name_u32
running->Object.name.name_u32
);
}
void rtems_stack_checker_reporter_quiet(
const rtems_stack_checker_info *info
const Thread_Control *running,
bool pattern_ok
)
{
rtems_fatal(
RTEMS_FATAL_SOURCE_STACK_CHECKER,
info->running->Object.name.name_u32
running->Object.name.name_u32
);
}
@@ -327,12 +329,9 @@ void rtems_stack_checker_switch_extension(
)
{
bool sp_ok;
bool pattern_ok;
const Stack_Control *stack;
rtems_stack_checker_info info;
info.running = running;
info.heir = heir;
/*
* Check for an out of bounds stack pointer or an overwrite
*/
@@ -340,28 +339,24 @@ void rtems_stack_checker_switch_extension(
sp_ok = Stack_check_Frame_pointer_in_range( heir );
if ( !sp_ok ) {
info.pattern_ok = Stack_check_Is_sanity_pattern_valid(
pattern_ok = Stack_check_Is_sanity_pattern_valid(
&heir->Start.Initial_stack
);
Stack_checker_Reporter( &info );
Stack_checker_Reporter( heir, pattern_ok );
}
info.pattern_ok = Stack_check_Is_sanity_pattern_valid(
&running->Start.Initial_stack
);
pattern_ok = Stack_check_Is_sanity_pattern_valid( &running->Start.Initial_stack );
if ( !info.pattern_ok ) {
Stack_checker_Reporter( &info );
if ( !pattern_ok ) {
Stack_checker_Reporter( running, pattern_ok );
}
#else
sp_ok = Stack_check_Frame_pointer_in_range( running );
info.pattern_ok = Stack_check_Is_sanity_pattern_valid(
&running->Start.Initial_stack
);
pattern_ok = Stack_check_Is_sanity_pattern_valid( &running->Start.Initial_stack );
if ( !sp_ok || !info.pattern_ok ) {
Stack_checker_Reporter( &info );
if ( !sp_ok || !pattern_ok ) {
Stack_checker_Reporter( running, pattern_ok );
}
#endif

View File

@@ -37,11 +37,11 @@
#endif
#include <rtems/score/thread.h>
#include <rtems/stackchk.h>
/* functions */
void stackchk03_blown_stack_reporter(
const rtems_stack_checker_info *info
const Thread_Control *running,
bool pattern_ok
);
const char rtems_test_name[] = "STACKCHK03";

View File

@@ -37,20 +37,21 @@
#include <rtems.h>
#include <rtems/score/thread.h>
#include <rtems/bspIo.h>
#include <rtems/stackchk.h>
void stackchk03_blown_stack_reporter(
const rtems_stack_checker_info *info
const Thread_Control *running,
bool pattern_ok
);
void stackchk03_blown_stack_reporter(
const rtems_stack_checker_info *info
const Thread_Control *running,
bool pattern_ok
)
{
/* custom stack report funtion to be implemented here */
printk("RTEMS STACKCHK03 CUSTOM REPORTER !!!\n");
rtems_fatal(
RTEMS_FATAL_SOURCE_STACK_CHECKER,
info->running->Object.name.name_u32
running->Object.name.name_u32
);
}