forked from Imagelibrary/rtems
Stack check now initialized as part of initial extension set.
This commit is contained in:
@@ -2,12 +2,27 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
This directory contains a stack bounds checker. It provides two
|
This directory contains a stack bounds checker. It provides two
|
||||||
primary features:
|
primary features:
|
||||||
|
|
||||||
+ check for stack overflow at each context switch
|
+ check for stack overflow at each context switch
|
||||||
+ provides an educated guess at each task's stack usage
|
+ provides an educated guess at each task's stack usage
|
||||||
|
|
||||||
|
Enabling
|
||||||
|
========
|
||||||
|
|
||||||
|
Add the stack checker extension to the initial user extension set.
|
||||||
|
If using confdefs.h to build your configuration table, this is
|
||||||
|
as simple as adding -DSTACK_CHECK_ON to the gcc command line which
|
||||||
|
compiles the file defining the configuration table. In the RTEMS
|
||||||
|
test suites and samples, this is always init.c
|
||||||
|
|
||||||
|
Background
|
||||||
|
==========
|
||||||
|
|
||||||
The stack overflow check at context switch works by looking for
|
The stack overflow check at context switch works by looking for
|
||||||
a 16 byte pattern at the logical end of the stack to be corrupted.
|
a 16 byte pattern at the logical end of the stack to be corrupted.
|
||||||
The "guesser" assumes that the entire stack was prefilled with a known
|
The "guesser" assumes that the entire stack was prefilled with a known
|
||||||
|
|||||||
@@ -175,12 +175,14 @@ void Stack_check_Initialize( void )
|
|||||||
p[3] = 0x600D0D06;
|
p[3] = 0x600D0D06;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
status = rtems_extension_create(
|
status = rtems_extension_create(
|
||||||
rtems_build_name( 'S', 'T', 'C', 'K' ),
|
rtems_build_name( 'S', 'T', 'C', 'K' ),
|
||||||
&Stack_check_Extension_table,
|
&Stack_check_Extension_table,
|
||||||
&id_ignored
|
&id_ignored
|
||||||
);
|
);
|
||||||
assert ( status == RTEMS_SUCCESSFUL );
|
assert ( status == RTEMS_SUCCESSFUL );
|
||||||
|
#endif
|
||||||
|
|
||||||
Stack_check_Blown_task = 0;
|
Stack_check_Blown_task = 0;
|
||||||
|
|
||||||
@@ -254,6 +256,9 @@ boolean Stack_check_Create_extension(
|
|||||||
Thread_Control *the_thread
|
Thread_Control *the_thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (!stack_check_initialized)
|
||||||
|
Stack_check_Initialize();
|
||||||
|
|
||||||
if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
|
if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
|
||||||
stack_check_dope_stack(&the_thread->Start.Initial_stack);
|
stack_check_dope_stack(&the_thread->Start.Initial_stack);
|
||||||
|
|
||||||
@@ -271,6 +276,9 @@ void Stack_check_Begin_extension(
|
|||||||
{
|
{
|
||||||
Stack_check_Control *the_pattern;
|
Stack_check_Control *the_pattern;
|
||||||
|
|
||||||
|
if (!stack_check_initialized)
|
||||||
|
Stack_check_Initialize();
|
||||||
|
|
||||||
if ( the_thread->Object.id == 0 ) /* skip system tasks */
|
if ( the_thread->Object.id == 0 ) /* skip system tasks */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,48 @@ void Stack_check_Initialize( void );
|
|||||||
|
|
||||||
void Stack_check_Dump_usage( void );
|
void Stack_check_Dump_usage( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Create_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean Stack_check_Create_extension(
|
||||||
|
Thread_Control *running,
|
||||||
|
Thread_Control *the_thread
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Begin_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Stack_check_Begin_extension(
|
||||||
|
Thread_Control *the_thread
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Switch_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Stack_check_Switch_extension(
|
||||||
|
Thread_Control *running,
|
||||||
|
Thread_Control *heir
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extension set definition
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define STACK_CHECKER_EXTENSION \
|
||||||
|
{ \
|
||||||
|
Stack_check_Create_extension, /* rtems_task_create */ \
|
||||||
|
0, /* rtems_task_start */ \
|
||||||
|
0, /* rtems_task_restart */ \
|
||||||
|
0, /* rtems_task_delete */ \
|
||||||
|
Stack_check_Switch_extension, /* task_switch */ \
|
||||||
|
Stack_check_Begin_extension, /* task_begin */ \
|
||||||
|
0, /* task_exitted */ \
|
||||||
|
0 /* Stack_check_Fatal_extension */, /* fatal */ \
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,12 +2,27 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
This directory contains a stack bounds checker. It provides two
|
This directory contains a stack bounds checker. It provides two
|
||||||
primary features:
|
primary features:
|
||||||
|
|
||||||
+ check for stack overflow at each context switch
|
+ check for stack overflow at each context switch
|
||||||
+ provides an educated guess at each task's stack usage
|
+ provides an educated guess at each task's stack usage
|
||||||
|
|
||||||
|
Enabling
|
||||||
|
========
|
||||||
|
|
||||||
|
Add the stack checker extension to the initial user extension set.
|
||||||
|
If using confdefs.h to build your configuration table, this is
|
||||||
|
as simple as adding -DSTACK_CHECK_ON to the gcc command line which
|
||||||
|
compiles the file defining the configuration table. In the RTEMS
|
||||||
|
test suites and samples, this is always init.c
|
||||||
|
|
||||||
|
Background
|
||||||
|
==========
|
||||||
|
|
||||||
The stack overflow check at context switch works by looking for
|
The stack overflow check at context switch works by looking for
|
||||||
a 16 byte pattern at the logical end of the stack to be corrupted.
|
a 16 byte pattern at the logical end of the stack to be corrupted.
|
||||||
The "guesser" assumes that the entire stack was prefilled with a known
|
The "guesser" assumes that the entire stack was prefilled with a known
|
||||||
|
|||||||
@@ -175,12 +175,14 @@ void Stack_check_Initialize( void )
|
|||||||
p[3] = 0x600D0D06;
|
p[3] = 0x600D0D06;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
status = rtems_extension_create(
|
status = rtems_extension_create(
|
||||||
rtems_build_name( 'S', 'T', 'C', 'K' ),
|
rtems_build_name( 'S', 'T', 'C', 'K' ),
|
||||||
&Stack_check_Extension_table,
|
&Stack_check_Extension_table,
|
||||||
&id_ignored
|
&id_ignored
|
||||||
);
|
);
|
||||||
assert ( status == RTEMS_SUCCESSFUL );
|
assert ( status == RTEMS_SUCCESSFUL );
|
||||||
|
#endif
|
||||||
|
|
||||||
Stack_check_Blown_task = 0;
|
Stack_check_Blown_task = 0;
|
||||||
|
|
||||||
@@ -254,6 +256,9 @@ boolean Stack_check_Create_extension(
|
|||||||
Thread_Control *the_thread
|
Thread_Control *the_thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (!stack_check_initialized)
|
||||||
|
Stack_check_Initialize();
|
||||||
|
|
||||||
if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
|
if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
|
||||||
stack_check_dope_stack(&the_thread->Start.Initial_stack);
|
stack_check_dope_stack(&the_thread->Start.Initial_stack);
|
||||||
|
|
||||||
@@ -271,6 +276,9 @@ void Stack_check_Begin_extension(
|
|||||||
{
|
{
|
||||||
Stack_check_Control *the_pattern;
|
Stack_check_Control *the_pattern;
|
||||||
|
|
||||||
|
if (!stack_check_initialized)
|
||||||
|
Stack_check_Initialize();
|
||||||
|
|
||||||
if ( the_thread->Object.id == 0 ) /* skip system tasks */
|
if ( the_thread->Object.id == 0 ) /* skip system tasks */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,48 @@ void Stack_check_Initialize( void );
|
|||||||
|
|
||||||
void Stack_check_Dump_usage( void );
|
void Stack_check_Dump_usage( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Create_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean Stack_check_Create_extension(
|
||||||
|
Thread_Control *running,
|
||||||
|
Thread_Control *the_thread
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Begin_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Stack_check_Begin_extension(
|
||||||
|
Thread_Control *the_thread
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Switch_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Stack_check_Switch_extension(
|
||||||
|
Thread_Control *running,
|
||||||
|
Thread_Control *heir
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extension set definition
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define STACK_CHECKER_EXTENSION \
|
||||||
|
{ \
|
||||||
|
Stack_check_Create_extension, /* rtems_task_create */ \
|
||||||
|
0, /* rtems_task_start */ \
|
||||||
|
0, /* rtems_task_restart */ \
|
||||||
|
0, /* rtems_task_delete */ \
|
||||||
|
Stack_check_Switch_extension, /* task_switch */ \
|
||||||
|
Stack_check_Begin_extension, /* task_begin */ \
|
||||||
|
0, /* task_exitted */ \
|
||||||
|
0 /* Stack_check_Fatal_extension */, /* fatal */ \
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,12 +2,27 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
This directory contains a stack bounds checker. It provides two
|
This directory contains a stack bounds checker. It provides two
|
||||||
primary features:
|
primary features:
|
||||||
|
|
||||||
+ check for stack overflow at each context switch
|
+ check for stack overflow at each context switch
|
||||||
+ provides an educated guess at each task's stack usage
|
+ provides an educated guess at each task's stack usage
|
||||||
|
|
||||||
|
Enabling
|
||||||
|
========
|
||||||
|
|
||||||
|
Add the stack checker extension to the initial user extension set.
|
||||||
|
If using confdefs.h to build your configuration table, this is
|
||||||
|
as simple as adding -DSTACK_CHECK_ON to the gcc command line which
|
||||||
|
compiles the file defining the configuration table. In the RTEMS
|
||||||
|
test suites and samples, this is always init.c
|
||||||
|
|
||||||
|
Background
|
||||||
|
==========
|
||||||
|
|
||||||
The stack overflow check at context switch works by looking for
|
The stack overflow check at context switch works by looking for
|
||||||
a 16 byte pattern at the logical end of the stack to be corrupted.
|
a 16 byte pattern at the logical end of the stack to be corrupted.
|
||||||
The "guesser" assumes that the entire stack was prefilled with a known
|
The "guesser" assumes that the entire stack was prefilled with a known
|
||||||
|
|||||||
@@ -175,12 +175,14 @@ void Stack_check_Initialize( void )
|
|||||||
p[3] = 0x600D0D06;
|
p[3] = 0x600D0D06;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
status = rtems_extension_create(
|
status = rtems_extension_create(
|
||||||
rtems_build_name( 'S', 'T', 'C', 'K' ),
|
rtems_build_name( 'S', 'T', 'C', 'K' ),
|
||||||
&Stack_check_Extension_table,
|
&Stack_check_Extension_table,
|
||||||
&id_ignored
|
&id_ignored
|
||||||
);
|
);
|
||||||
assert ( status == RTEMS_SUCCESSFUL );
|
assert ( status == RTEMS_SUCCESSFUL );
|
||||||
|
#endif
|
||||||
|
|
||||||
Stack_check_Blown_task = 0;
|
Stack_check_Blown_task = 0;
|
||||||
|
|
||||||
@@ -254,6 +256,9 @@ boolean Stack_check_Create_extension(
|
|||||||
Thread_Control *the_thread
|
Thread_Control *the_thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (!stack_check_initialized)
|
||||||
|
Stack_check_Initialize();
|
||||||
|
|
||||||
if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
|
if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
|
||||||
stack_check_dope_stack(&the_thread->Start.Initial_stack);
|
stack_check_dope_stack(&the_thread->Start.Initial_stack);
|
||||||
|
|
||||||
@@ -271,6 +276,9 @@ void Stack_check_Begin_extension(
|
|||||||
{
|
{
|
||||||
Stack_check_Control *the_pattern;
|
Stack_check_Control *the_pattern;
|
||||||
|
|
||||||
|
if (!stack_check_initialized)
|
||||||
|
Stack_check_Initialize();
|
||||||
|
|
||||||
if ( the_thread->Object.id == 0 ) /* skip system tasks */
|
if ( the_thread->Object.id == 0 ) /* skip system tasks */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,48 @@ void Stack_check_Initialize( void );
|
|||||||
|
|
||||||
void Stack_check_Dump_usage( void );
|
void Stack_check_Dump_usage( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Create_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean Stack_check_Create_extension(
|
||||||
|
Thread_Control *running,
|
||||||
|
Thread_Control *the_thread
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Begin_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Stack_check_Begin_extension(
|
||||||
|
Thread_Control *the_thread
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack_check_Switch_extension
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Stack_check_Switch_extension(
|
||||||
|
Thread_Control *running,
|
||||||
|
Thread_Control *heir
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extension set definition
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define STACK_CHECKER_EXTENSION \
|
||||||
|
{ \
|
||||||
|
Stack_check_Create_extension, /* rtems_task_create */ \
|
||||||
|
0, /* rtems_task_start */ \
|
||||||
|
0, /* rtems_task_restart */ \
|
||||||
|
0, /* rtems_task_delete */ \
|
||||||
|
Stack_check_Switch_extension, /* task_switch */ \
|
||||||
|
Stack_check_Begin_extension, /* task_begin */ \
|
||||||
|
0, /* task_exitted */ \
|
||||||
|
0 /* Stack_check_Fatal_extension */, /* fatal */ \
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user