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 */
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief User Extensions Configuration Options Evaluator
|
||||||
*
|
|
||||||
* @ingroup RTEMSImplApplConfig
|
|
||||||
*
|
|
||||||
* @brief This header file evaluates configuration options related to the user
|
|
||||||
* extensions configuration.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 embedded brains GmbH & Co. KG
|
* 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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -93,6 +89,22 @@
|
|||||||
#include <rtems/stackchk.h>
|
#include <rtems/stackchk.h>
|
||||||
#endif
|
#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
|
#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING
|
||||||
#include <rtems/score/exception.h>
|
#include <rtems/score/exception.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief Stack Checker Mechanism Details
|
||||||
*
|
*
|
||||||
* @ingroup libmisc_stackchk
|
* This file contains the information necessary to install the stack
|
||||||
*
|
* checker mechanism.
|
||||||
* @brief Stack Checker Information
|
|
||||||
*
|
|
||||||
* This include file contains information necessary to utilize
|
|
||||||
* and install the stack checker mechanism.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 1989-2009.
|
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||||
* 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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -42,6 +38,7 @@
|
|||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/print.h>
|
#include <rtems/print.h>
|
||||||
|
#include <rtems/score/threadimpl.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup libmisc_stackchk Stack Checker Mechanism
|
* @defgroup libmisc_stackchk Stack Checker Mechanism
|
||||||
@@ -61,7 +58,6 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @retval This method returns true if the currently executing task
|
* @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 );
|
bool rtems_stack_checker_is_blown( void );
|
||||||
|
|
||||||
@@ -82,6 +78,7 @@ void rtems_stack_checker_report_usage( void );
|
|||||||
* task.
|
* task.
|
||||||
*
|
*
|
||||||
* @param[in] context is the context to pass to the print handler
|
* @param[in] context is the context to pass to the print handler
|
||||||
|
*
|
||||||
* @param[in] print is the print handler
|
* @param[in] print is the print handler
|
||||||
*
|
*
|
||||||
* @note It uses the caller's routine to print the report.
|
* @note It uses the caller's routine to print the report.
|
||||||
@@ -91,12 +88,11 @@ void rtems_stack_checker_report_usage_with_plugin(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This structure contains the stack information provided by the stack
|
* @brief Stack information provided by the stack checker.
|
||||||
* checker for a stack.
|
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/**
|
/**
|
||||||
* @brief This member contains the object identifier associated with the
|
* This member contains the object identifier associated with the
|
||||||
* object using the stack.
|
* object using the stack.
|
||||||
*
|
*
|
||||||
* For interrupt stacks, the object identifier is the processor index.
|
* For interrupt stacks, the object identifier is the processor index.
|
||||||
@@ -104,7 +100,7 @@ typedef struct {
|
|||||||
rtems_id id;
|
rtems_id id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This member provides the object name associated with the
|
* This member provides the object name associated with the
|
||||||
* object using the stack.
|
* object using the stack.
|
||||||
*
|
*
|
||||||
* For interrupt stacks, the object name is "Interrupt Stack".
|
* For interrupt stacks, the object name is "Interrupt Stack".
|
||||||
@@ -112,25 +108,25 @@ typedef struct {
|
|||||||
const char *name;
|
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;
|
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;
|
uintptr_t size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This member provides the current stack pointer of the stack.
|
* This member provides the current stack pointer of the stack.
|
||||||
*
|
*
|
||||||
* If the current stack pointer is not available, then the value is set to
|
* If the current stack pointer is not available, then the value is
|
||||||
* NULL.
|
* set to NULL.
|
||||||
*/
|
*/
|
||||||
const void *current;
|
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
|
* If the stack checker is not initialized, then the value is set to
|
||||||
* UINTPTR_MAX.
|
* UINTPTR_MAX.
|
||||||
@@ -139,12 +135,12 @@ typedef struct {
|
|||||||
} rtems_stack_checker_info;
|
} rtems_stack_checker_info;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Visitor routines invoked by rtems_stack_checker_iterate() shall have
|
* @brief Visitor routines invoked by rtems_stack_checker_iterate() shall
|
||||||
* this type.
|
* 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 )(
|
typedef void ( *rtems_stack_checker_visitor )(
|
||||||
const rtems_stack_checker_info *info,
|
const rtems_stack_checker_info *info,
|
||||||
@@ -158,10 +154,10 @@ typedef void ( *rtems_stack_checker_visitor )(
|
|||||||
* This method prints a stack usage report for the curently executing
|
* This method prints a stack usage report for the curently executing
|
||||||
* task.
|
* 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
|
* @param[in] arg is the argument passed to each visitor routine invocation
|
||||||
* the iteration.
|
* during the iteration.
|
||||||
*/
|
*/
|
||||||
void rtems_stack_checker_iterate( rtems_stack_checker_visitor visit, void *arg );
|
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.
|
* This method is the task create extension for the stack checker.
|
||||||
*
|
*
|
||||||
* @param[in] running points to the currently executing task
|
* @param[in] running points to the currently executing task
|
||||||
|
*
|
||||||
* @param[in] the_thread points to the newly created task
|
* @param[in] the_thread points to the newly created task
|
||||||
*
|
*
|
||||||
* @note If this this the first task created, the stack checker
|
* @note If this this the first task created, the stack checker
|
||||||
@@ -196,7 +193,8 @@ void rtems_stack_checker_begin_extension( rtems_tcb *executing );
|
|||||||
*
|
*
|
||||||
* @param[in] running points to the currently executing task which
|
* @param[in] running points to the currently executing task which
|
||||||
* is being context switched out
|
* is being context switched out
|
||||||
* @param[in] running points to the heir task which we are switching to
|
*
|
||||||
|
* @param[in] heir points to the heir task which we are switching to
|
||||||
*
|
*
|
||||||
* @note This is called from the internal method _Thread_Dispatch.
|
* @note This is called from the internal method _Thread_Dispatch.
|
||||||
*/
|
*/
|
||||||
@@ -205,6 +203,35 @@ void rtems_stack_checker_switch_extension(
|
|||||||
rtems_tcb *heir
|
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
|
* @brief Stack Checker Extension Set Definition
|
||||||
*
|
*
|
||||||
@@ -224,6 +251,27 @@ void rtems_stack_checker_switch_extension(
|
|||||||
0 /* terminate */ \
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* @ingroup libmisc_stackchk Stack Checker Mechanism
|
|
||||||
*
|
|
||||||
* @brief Stack Overflow Check User Extension Set
|
* @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.
|
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||||
* 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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -255,7 +246,7 @@ 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.
|
* so that interrupt handlers can use this too.
|
||||||
@@ -263,7 +254,7 @@ void rtems_stack_checker_begin_extension( Thread_Control *executing )
|
|||||||
* NOTE: The system is in a questionable state... we may not get
|
* NOTE: The system is in a questionable state... we may not get
|
||||||
* the following message out.
|
* the following message out.
|
||||||
*/
|
*/
|
||||||
static void Stack_check_report_blown_task(
|
void rtems_stack_checker_reporter_print_details(
|
||||||
const Thread_Control *running,
|
const Thread_Control *running,
|
||||||
bool pattern_ok
|
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
|
* rtems_stack_checker_switch_extension
|
||||||
*/
|
*/
|
||||||
@@ -333,13 +335,13 @@ void rtems_stack_checker_switch_extension(
|
|||||||
pattern_ok = Stack_check_Is_sanity_pattern_valid(
|
pattern_ok = Stack_check_Is_sanity_pattern_valid(
|
||||||
&heir->Start.Initial_stack
|
&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 );
|
pattern_ok = Stack_check_Is_sanity_pattern_valid( &running->Start.Initial_stack );
|
||||||
|
|
||||||
if ( !pattern_ok ) {
|
if ( !pattern_ok ) {
|
||||||
Stack_check_report_blown_task( running, pattern_ok );
|
Stack_checker_Reporter( running, pattern_ok );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sp_ok = Stack_check_Frame_pointer_in_range( running );
|
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 );
|
pattern_ok = Stack_check_Is_sanity_pattern_valid( &running->Start.Initial_stack );
|
||||||
|
|
||||||
if ( !sp_ok || !pattern_ok ) {
|
if ( !sp_ok || !pattern_ok ) {
|
||||||
Stack_check_report_blown_task( running, pattern_ok );
|
Stack_checker_Reporter( running, pattern_ok );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,8 @@ links:
|
|||||||
uid: stackchk01
|
uid: stackchk01
|
||||||
- role: build-dependency
|
- role: build-dependency
|
||||||
uid: stackchk02
|
uid: stackchk02
|
||||||
|
- role: build-dependency
|
||||||
|
uid: stackchk03
|
||||||
- role: build-dependency
|
- role: build-dependency
|
||||||
uid: stat
|
uid: stat
|
||||||
- role: build-dependency
|
- role: build-dependency
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ build-type: test-program
|
|||||||
cflags: []
|
cflags: []
|
||||||
copyrights:
|
copyrights:
|
||||||
- Copyright (C) 2020 embedded brains GmbH & Co. KG
|
- Copyright (C) 2020 embedded brains GmbH & Co. KG
|
||||||
|
- Copyright (C) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||||
cppflags: []
|
cppflags: []
|
||||||
cxxflags: []
|
cxxflags: []
|
||||||
enabled-by: true
|
enabled-by: true
|
||||||
@@ -12,6 +13,7 @@ ldflags: []
|
|||||||
links: []
|
links: []
|
||||||
source:
|
source:
|
||||||
- testsuites/libtests/stackchk/blow.c
|
- testsuites/libtests/stackchk/blow.c
|
||||||
|
- testsuites/libtests/stackchk/config.c
|
||||||
- testsuites/libtests/stackchk/init.c
|
- testsuites/libtests/stackchk/init.c
|
||||||
- testsuites/libtests/stackchk/task1.c
|
- testsuites/libtests/stackchk/task1.c
|
||||||
stlib: []
|
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 */
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
/* Init
|
/**
|
||||||
*
|
* @brief Stack Checker Test Initialization File
|
||||||
* 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
|
* COPYRIGHT (c) 1989-2024 On-Line Applications Research Corporation (OAR).
|
||||||
* value by this function.
|
* COPYRIGHT (c) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
|
||||||
*
|
|
||||||
* Input parameters:
|
|
||||||
* argument - task argument
|
|
||||||
*
|
|
||||||
* Output parameters: NONE
|
|
||||||
*
|
|
||||||
* COPYRIGHT (c) 1989-1999.
|
|
||||||
* On-Line Applications Research Corporation (OAR).
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -42,12 +34,11 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
|
|
||||||
const char rtems_test_name[] = "STACKCHK";
|
extern const char rtems_test_name[];
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
@@ -122,5 +113,6 @@ void Fatal_extension(
|
|||||||
printk( "unexpected fatal error\n" );
|
printk( "unexpected fatal error\n" );
|
||||||
} else {
|
} else {
|
||||||
TEST_END();
|
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