Back to home page

LXR

 
 

    


Warning, /cpukit/libmisc/stackchk/README.md is written in an unsupported language. File is not indexed.

0001 Introduction
0002 ============
0003 
0004 This directory contains a stack bounds checker.  It provides two
0005 primary features:
0006 
0007    + check for stack overflow at each context switch
0008    + provides an educated guess at each task's stack usage
0009 
0010 Enabling
0011 ========
0012 
0013 Add the stack checker extension to the initial user extension set.
0014 If using confdefs.h to build your configuration table, this is
0015 as simple as adding -DSTACK_CHECK_ON to the gcc command line which
0016 compiles the file defining the configuration table.  In the RTEMS
0017 test suites and samples, this is always init.c
0018 
0019 Background
0020 ==========
0021 
0022 The stack overflow check at context switch works by looking for
0023 a 16 byte pattern at the logical end of the stack to be corrupted.
0024 The "guesser" assumes that the entire stack was prefilled with a known
0025 pattern and assumes that the pattern is still in place if the memory
0026 has not been used as a stack.
0027 
0028 Both of these can be fooled by pushing large holes onto the stack
0029 and not writing to them... or (much more unlikely) writing the
0030 magic patterns into memory.
0031 
0032 This code has not been extensively tested.  It is provided as a tool
0033 for RTEMS users to catch the most common mistake in multitasking
0034 systems ... too little stack space.  Suggestions and comments are appreciated.
0035 
0036 NOTES:
0037 
0038 1.  Stack usage information is questionable on CPUs which push
0039     large holes on stack.
0040 
0041 2.  The stack checker has a tendency to generate a fault when
0042     trying to print the helpful diagnostic message.  If it comes
0043     out, congratulations. If not, then the variable Stack_check_Blown_task
0044     contains a pointer to the TCB of the offending task.  This
0045     is usually enough to go on.
0046 
0047 FUTURE:
0048 
0049 1.  Determine how/if gcc will generate stack probe calls and support that.