Add random number stack filling option. (#257)

Co-authored-by: TiejunZhou <50469179+TiejunMS@users.noreply.github.com>
This commit is contained in:
Xiuwen Cai
2023-05-12 10:13:42 +08:00
committed by GitHub
parent 6d9f25fac9
commit 6b8ece0ff2
13 changed files with 179 additions and 12 deletions

View File

@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* tx_api.h PORTABLE SMP */
/* 6.2.1 */
/* 6.x */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -85,6 +85,10 @@
/* 03-08-2023 Tiejun Zhou Modified comment(s), */
/* update patch number, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Xiuwen Cai Modified comment(s), */
/* added option for random */
/* number stack filling, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -172,7 +176,11 @@ extern "C" {
#define TX_NO_MESSAGES ((UINT) 0)
#define TX_EMPTY ((ULONG) 0)
#define TX_CLEAR_ID ((ULONG) 0)
#if defined(TX_ENABLE_RANDOM_NUMBER_STACK_FILLING) && defined(TX_ENABLE_STACK_CHECKING)
#define TX_STACK_FILL (thread_ptr -> tx_thread_stack_fill_value)
#else
#define TX_STACK_FILL ((ULONG) 0xEFEFEFEFUL)
#endif
/* Thread execution state values. */
@@ -639,6 +647,12 @@ typedef struct TX_THREAD_STRUCT
cleanup routine executes. */
ULONG tx_thread_suspension_sequence;
#if defined(TX_ENABLE_RANDOM_NUMBER_STACK_FILLING) && defined(TX_ENABLE_STACK_CHECKING)
/* Define the random stack fill number. This can be used to detect stack overflow. */
ULONG tx_thread_stack_fill_value;
#endif
/* Define the user extension field. This typically is defined
to white space, but some ports of ThreadX may need to have
additional fields in the thread control block. This is
@@ -1886,6 +1900,21 @@ UINT _tx_trace_interrupt_control(UINT new_posture);
#endif
/* Add a default macro that can be re-defined in tx_port.h to add processing to the initialize random number generator.
By default, this is simply defined as whitespace. */
#ifndef TX_INITIALIZE_RANDOM_GENERATOR_INITIALIZATION
#define TX_INITIALIZE_RANDOM_GENERATOR_INITIALIZATION
#endif
/* Define the TX_RAND macro to the standard library function, if not already defined. */
#ifndef TX_RAND
#define TX_RAND() rand()
#endif
/* Check for MISRA compliance requirements. */
#ifdef TX_MISRA_ENABLE

View File

@@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* tx_user.h PORTABLE C */
/* 6.1.11 */
/* 6.x */
/* */
/* AUTHOR */
/* */
@@ -62,6 +62,10 @@
/* optimized the definition of */
/* TX_TIMER_TICKS_PER_SECOND, */
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Xiuwen Cai Modified comment(s), */
/* added option for random */
/* number stack filling, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -170,6 +174,14 @@
#define TX_ENABLE_STACK_CHECKING
*/
/* Determine if random number is used for stack filling. By default, ThreadX uses a fixed
pattern for stack filling. When the following is defined, ThreadX uses a random number
for stack filling. This is effective only when TX_ENABLE_STACK_CHECKING is defined. */
/*
#define TX_ENABLE_RANDOM_NUMBER_STACK_FILLING
*/
/* Determine if preemption-threshold should be disabled. By default, preemption-threshold is
enabled. If the application does not use preemption-threshold, it may be disabled to reduce
code size and improve performance. */