forked from Imagelibrary/rtems
libmisc/stackchk: Add configurability to the stack checker reporting function
This commit is contained in:
committed by
Amar Takhar
parent
a0eecb52bc
commit
dc123bb828
@@ -1,16 +1,12 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSImplApplConfig
|
||||
*
|
||||
* @brief This header file evaluates configuration options related to the user
|
||||
* extensions configuration.
|
||||
* @brief User Extensions Configuration Options Evaluator
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH & Co. KG
|
||||
* Copyright (C) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -93,6 +89,22 @@
|
||||
#include <rtems/stackchk.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIGURE_STACK_CHECKER_ENABLED
|
||||
#ifdef CONFIGURE_STACK_CHECKER_REPORTER
|
||||
const Stack_checker_Reporter_handler Stack_checker_Reporter =
|
||||
CONFIGURE_STACK_CHECKER_REPORTER;
|
||||
|
||||
#else
|
||||
const Stack_checker_Reporter_handler Stack_checker_Reporter =
|
||||
rtems_stack_checker_reporter_print_details;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIGURE_STACK_CHECKER_ENABLED) && defined(CONFIGURE_STACK_CHECKER_REPORTER)
|
||||
#error "Stack checker is disabled but a custom reporter is configured"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING
|
||||
#include <rtems/score/exception.h>
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup libmisc_stackchk
|
||||
*
|
||||
* @brief Stack Checker Information
|
||||
*
|
||||
* This include file contains information necessary to utilize
|
||||
* and install the stack checker mechanism.
|
||||
* @brief Stack Checker Mechanism Details
|
||||
*
|
||||
* This file contains the information necessary to install the stack
|
||||
* checker mechanism.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -42,6 +38,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/print.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
|
||||
/**
|
||||
* @defgroup libmisc_stackchk Stack Checker Mechanism
|
||||
@@ -60,8 +57,7 @@ extern "C" {
|
||||
* of the currently executing task is within bounds.
|
||||
*
|
||||
* @retval This method returns true if the currently executing task
|
||||
* has blown its stack.
|
||||
*
|
||||
* has blown its stack.
|
||||
*/
|
||||
bool rtems_stack_checker_is_blown( void );
|
||||
|
||||
@@ -82,6 +78,7 @@ void rtems_stack_checker_report_usage( void );
|
||||
* task.
|
||||
*
|
||||
* @param[in] context is the context to pass to the print handler
|
||||
*
|
||||
* @param[in] print is the print handler
|
||||
*
|
||||
* @note It uses the caller's routine to print the report.
|
||||
@@ -91,46 +88,45 @@ void rtems_stack_checker_report_usage_with_plugin(
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief This structure contains the stack information provided by the stack
|
||||
* checker for a stack.
|
||||
* @brief Stack information provided by the stack checker.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief This member contains the object identifier associated with the
|
||||
* object using the stack.
|
||||
*
|
||||
* This member contains the object identifier associated with the
|
||||
* object using the stack.
|
||||
*
|
||||
* For interrupt stacks, the object identifier is the processor index.
|
||||
*/
|
||||
rtems_id id;
|
||||
|
||||
/**
|
||||
* @brief This member provides the object name associated with the
|
||||
* object using the stack.
|
||||
*
|
||||
* This member provides the object name associated with the
|
||||
* object using the stack.
|
||||
*
|
||||
* For interrupt stacks, the object name is "Interrupt Stack".
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* @brief This member provides the begin address of the stack area.
|
||||
* This member provides the begin address of the stack area.
|
||||
*/
|
||||
const void *begin;
|
||||
|
||||
/**
|
||||
* @brief This member contains the size in byes of the stack area.
|
||||
* This member contains the size in bytes of the stack area.
|
||||
*/
|
||||
uintptr_t size;
|
||||
|
||||
/**
|
||||
* @brief This member provides the current stack pointer of the stack.
|
||||
*
|
||||
* If the current stack pointer is not available, then the value is set to
|
||||
* NULL.
|
||||
* This member provides the current stack pointer of the stack.
|
||||
*
|
||||
* If the current stack pointer is not available, then the value is
|
||||
* set to NULL.
|
||||
*/
|
||||
const void *current;
|
||||
|
||||
/**
|
||||
* @brief This member contains the size in byes of the used stack area.
|
||||
* This member contains the size in bytes of the used stack area.
|
||||
*
|
||||
* If the stack checker is not initialized, then the value is set to
|
||||
* UINTPTR_MAX.
|
||||
@@ -139,12 +135,12 @@ typedef struct {
|
||||
} rtems_stack_checker_info;
|
||||
|
||||
/**
|
||||
* @brief Visitor routines invoked by rtems_stack_checker_iterate() shall have
|
||||
* this type.
|
||||
* @brief Visitor routines invoked by rtems_stack_checker_iterate() shall
|
||||
* have this type.
|
||||
*
|
||||
* @param info is the stack information.
|
||||
* @param[in] info is the stack information.
|
||||
*
|
||||
* @param arg is the argument passed to rtems_stack_checker_iterate().
|
||||
* @param[in] arg is the argument passed to rtems_stack_checker_iterate().
|
||||
*/
|
||||
typedef void ( *rtems_stack_checker_visitor )(
|
||||
const rtems_stack_checker_info *info,
|
||||
@@ -153,15 +149,15 @@ typedef void ( *rtems_stack_checker_visitor )(
|
||||
|
||||
/**
|
||||
* @brief Iterates over all stacks used by the system and invokes the visitor
|
||||
* routine for each stack.
|
||||
* routine for each stack.
|
||||
*
|
||||
* This method prints a stack usage report for the curently executing
|
||||
* task.
|
||||
*
|
||||
* @param visitor is the visitor routine invoked for each stack.
|
||||
* @param[in] visitor is the visitor routine invoked for each stack.
|
||||
*
|
||||
* @param arg is the argument passed to each visitor routine invocation during
|
||||
* the iteration.
|
||||
* @param[in] arg is the argument passed to each visitor routine invocation
|
||||
* during the iteration.
|
||||
*/
|
||||
void rtems_stack_checker_iterate( rtems_stack_checker_visitor visit, void *arg );
|
||||
|
||||
@@ -177,6 +173,7 @@ void rtems_stack_checker_iterate( rtems_stack_checker_visitor visit, void *arg )
|
||||
* This method is the task create extension for the stack checker.
|
||||
*
|
||||
* @param[in] running points to the currently executing task
|
||||
*
|
||||
* @param[in] the_thread points to the newly created task
|
||||
*
|
||||
* @note If this this the first task created, the stack checker
|
||||
@@ -195,8 +192,9 @@ void rtems_stack_checker_begin_extension( rtems_tcb *executing );
|
||||
* This method is the task context switch extension for the stack checker.
|
||||
*
|
||||
* @param[in] running points to the currently executing task which
|
||||
* is being context switched out
|
||||
* @param[in] running points to the heir task which we are switching to
|
||||
* is being context switched out
|
||||
*
|
||||
* @param[in] heir points to the heir task which we are switching to
|
||||
*
|
||||
* @note This is called from the internal method _Thread_Dispatch.
|
||||
*/
|
||||
@@ -205,11 +203,40 @@ void rtems_stack_checker_switch_extension(
|
||||
rtems_tcb *heir
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief A Quiet Version of Stack Checker Reporter.
|
||||
*
|
||||
* @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 Thread_Control *running,
|
||||
bool pattern_ok
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief The Default Function to Report a Blown Stack.
|
||||
*
|
||||
* @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 Thread_Control *running,
|
||||
bool pattern_ok
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Stack Checker Extension Set Definition
|
||||
*
|
||||
* This macro defines the user extension handler set for the stack
|
||||
* checker. This macro is normally only used by confdefs.h.
|
||||
* checker. This macro is normally only used by confdefs.h.
|
||||
*/
|
||||
#define RTEMS_STACK_CHECKER_EXTENSION \
|
||||
{ \
|
||||
@@ -224,6 +251,27 @@ void rtems_stack_checker_switch_extension(
|
||||
0 /* terminate */ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The Stack Checker Reporter Initialization Handler.
|
||||
*
|
||||
* @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 Thread_Control *running,
|
||||
bool pattern_ok
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief The Stack Checker Reporter Initialization Handler.
|
||||
*
|
||||
* Application provided via <rtems/confdefs.h>
|
||||
*/
|
||||
extern const Stack_checker_Reporter_handler Stack_checker_Reporter;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup libmisc_stackchk Stack Checker Mechanism
|
||||
*
|
||||
* @brief Stack Overflow Check User Extension Set
|
||||
*
|
||||
* NOTE: This extension set automatically determines at
|
||||
* initialization time whether the stack for this
|
||||
* CPU grows up or down and installs the correct
|
||||
* extension routines for that direction.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2010.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -149,7 +140,7 @@ static inline bool Stack_check_Frame_pointer_in_range(
|
||||
|
||||
/*
|
||||
* The assumption is that if the pattern gets overwritten, the task
|
||||
* is too close. This defines the usable stack memory.
|
||||
* is too close. This defines the usable stack memory.
|
||||
*/
|
||||
#define Stack_check_Usable_stack_size(_the_stack) \
|
||||
((_the_stack)->size - SANITY_PATTERN_SIZE_BYTES)
|
||||
@@ -161,7 +152,7 @@ static Stack_Control Stack_check_Interrupt_stack[ 1 ];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fill an entire stack area with BYTE_PATTERN. This will be used
|
||||
* Fill an entire stack area with BYTE_PATTERN. This will be used
|
||||
* to check for amount of actual stack used.
|
||||
*/
|
||||
static void Stack_check_Dope_stack( Stack_Control *stack )
|
||||
@@ -215,8 +206,8 @@ void rtems_stack_checker_begin_extension( Thread_Control *executing )
|
||||
|
||||
/*
|
||||
* If appropriate, set up the interrupt stack of the current processor for
|
||||
* high water testing also. This must be done after multi-threading started,
|
||||
* since the initialization stacks may reuse the interrupt stacks. Disable
|
||||
* high water testing also. This must be done after multi-threading started,
|
||||
* since the initialization stacks may reuse the interrupt stacks. Disable
|
||||
* thread dispatching in SMP configurations to prevent thread migration.
|
||||
* Writing to the interrupt stack is only safe if done from the corresponding
|
||||
* processor in thread context.
|
||||
@@ -255,15 +246,15 @@ void rtems_stack_checker_begin_extension( Thread_Control *executing )
|
||||
}
|
||||
|
||||
/*
|
||||
* Stack_check_report_blown_task
|
||||
* rtems_stack_checker_reporter_print_details
|
||||
*
|
||||
* Report a blown stack. Needs to be a separate routine
|
||||
* Report a blown stack. Needs to be a separate routine
|
||||
* so that interrupt handlers can use this too.
|
||||
*
|
||||
* NOTE: The system is in a questionable state... we may not get
|
||||
* the following message out.
|
||||
*/
|
||||
static void Stack_check_report_blown_task(
|
||||
void rtems_stack_checker_reporter_print_details(
|
||||
const Thread_Control *running,
|
||||
bool pattern_ok
|
||||
)
|
||||
@@ -311,6 +302,17 @@ static void Stack_check_report_blown_task(
|
||||
);
|
||||
}
|
||||
|
||||
void rtems_stack_checker_reporter_quiet(
|
||||
const Thread_Control *running,
|
||||
bool pattern_ok
|
||||
)
|
||||
{
|
||||
rtems_fatal(
|
||||
RTEMS_FATAL_SOURCE_STACK_CHECKER,
|
||||
running->Object.name.name_u32
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* rtems_stack_checker_switch_extension
|
||||
*/
|
||||
@@ -333,13 +335,13 @@ void rtems_stack_checker_switch_extension(
|
||||
pattern_ok = Stack_check_Is_sanity_pattern_valid(
|
||||
&heir->Start.Initial_stack
|
||||
);
|
||||
Stack_check_report_blown_task( heir, pattern_ok );
|
||||
Stack_checker_Reporter( heir, pattern_ok );
|
||||
}
|
||||
|
||||
pattern_ok = Stack_check_Is_sanity_pattern_valid( &running->Start.Initial_stack );
|
||||
|
||||
if ( !pattern_ok ) {
|
||||
Stack_check_report_blown_task( running, pattern_ok );
|
||||
Stack_checker_Reporter( running, pattern_ok );
|
||||
}
|
||||
#else
|
||||
sp_ok = Stack_check_Frame_pointer_in_range( running );
|
||||
@@ -347,7 +349,7 @@ void rtems_stack_checker_switch_extension(
|
||||
pattern_ok = Stack_check_Is_sanity_pattern_valid( &running->Start.Initial_stack );
|
||||
|
||||
if ( !sp_ok || !pattern_ok ) {
|
||||
Stack_check_report_blown_task( running, pattern_ok );
|
||||
Stack_checker_Reporter( running, pattern_ok );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -264,6 +264,8 @@ links:
|
||||
uid: stackchk01
|
||||
- role: build-dependency
|
||||
uid: stackchk02
|
||||
- role: build-dependency
|
||||
uid: stackchk03
|
||||
- role: build-dependency
|
||||
uid: stat
|
||||
- role: build-dependency
|
||||
|
||||
@@ -3,6 +3,7 @@ build-type: test-program
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2020 embedded brains GmbH & Co. KG
|
||||
- Copyright (C) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: true
|
||||
@@ -12,6 +13,7 @@ ldflags: []
|
||||
links: []
|
||||
source:
|
||||
- testsuites/libtests/stackchk/blow.c
|
||||
- testsuites/libtests/stackchk/config.c
|
||||
- testsuites/libtests/stackchk/init.c
|
||||
- testsuites/libtests/stackchk/task1.c
|
||||
stlib: []
|
||||
|
||||
23
spec/build/testsuites/libtests/stackchk03.yml
Normal file
23
spec/build/testsuites/libtests/stackchk03.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
|
||||
build-type: test-program
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: true
|
||||
features: c cprogram
|
||||
includes: []
|
||||
ldflags: []
|
||||
links: []
|
||||
source:
|
||||
- testsuites/libtests/stackchk/blow.c
|
||||
- testsuites/libtests/stackchk/init.c
|
||||
- testsuites/libtests/stackchk/task1.c
|
||||
- testsuites/libtests/stackchk03/config.c
|
||||
- testsuites/libtests/stackchk03/reporter.c
|
||||
stlib: []
|
||||
target: testsuites/libtests/stackchk03.exe
|
||||
type: build
|
||||
use-after: []
|
||||
use-before: []
|
||||
43
testsuites/libtests/stackchk/config.c
Normal file
43
testsuites/libtests/stackchk/config.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @brief Configuration File for stackchk testsuite
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
const char rtems_test_name[] = "STACKCHK";
|
||||
|
||||
#define CONFIGURE_STACK_CHECKER_ENABLED
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include "system.h"
|
||||
@@ -1,20 +1,12 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/* Init
|
||||
*
|
||||
* This routine is the initialization task for this test program.
|
||||
* It is a user initialization task and has the responsibility for creating
|
||||
* and starting the tasks that make up the test. If the time of day
|
||||
* clock is required for the test, it should also be set to a known
|
||||
* value by this function.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* COPYRIGHT (c) 1989-1999.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
/**
|
||||
* @brief Stack Checker Test Initialization File
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -42,12 +34,11 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include "system.h"
|
||||
|
||||
#include <rtems/bspIo.h>
|
||||
|
||||
const char rtems_test_name[] = "STACKCHK";
|
||||
extern const char rtems_test_name[];
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
@@ -122,5 +113,6 @@ void Fatal_extension(
|
||||
printk( "unexpected fatal error\n" );
|
||||
} else {
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
55
testsuites/libtests/stackchk03/config.c
Normal file
55
testsuites/libtests/stackchk03/config.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @brief Stack Checker Reporter Configuration File
|
||||
*
|
||||
* This file contains the stack checker reporter function.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2024 On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/score/thread.h>
|
||||
|
||||
/* functions */
|
||||
void stackchk03_blown_stack_reporter(
|
||||
const Thread_Control *running,
|
||||
bool pattern_ok
|
||||
);
|
||||
|
||||
const char rtems_test_name[] = "STACKCHK03";
|
||||
|
||||
/* configuration information */
|
||||
#define CONFIGURE_STACK_CHECKER_ENABLED
|
||||
#define CONFIGURE_STACK_CHECKER_REPORTER stackchk03_blown_stack_reporter
|
||||
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include "../stackchk/system.h"
|
||||
57
testsuites/libtests/stackchk03/reporter.c
Normal file
57
testsuites/libtests/stackchk03/reporter.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @brief Example for a User-Defined Stack Checker Reporter
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2024 On-Line Applications Research Corporation (OAR).
|
||||
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/bspIo.h>
|
||||
|
||||
void stackchk03_blown_stack_reporter(
|
||||
const Thread_Control *running,
|
||||
bool pattern_ok
|
||||
);
|
||||
|
||||
void stackchk03_blown_stack_reporter(
|
||||
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,
|
||||
running->Object.name.name_u32
|
||||
);
|
||||
}
|
||||
37
testsuites/libtests/stackchk03/stackchk03.doc
Normal file
37
testsuites/libtests/stackchk03/stackchk03.doc
Normal file
@@ -0,0 +1,37 @@
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
# COPYRIGHT (c) 2024 On-Line Applications Research Corporation (OAR).
|
||||
# COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: stackchk03
|
||||
|
||||
directives:
|
||||
+ rtems_stack_checker_switch_extension
|
||||
|
||||
concepts:
|
||||
+ This task verifies that the stack checker will call the defined reporter
|
||||
based on user configuration.
|
||||
3
testsuites/libtests/stackchk03/stackchk03.scn
Normal file
3
testsuites/libtests/stackchk03/stackchk03.scn
Normal file
@@ -0,0 +1,3 @@
|
||||
*** TEST STACKCHK03 ***
|
||||
custom stack check report!
|
||||
*** END OF TEST STACKCHK03 ***
|
||||
Reference in New Issue
Block a user