This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using hooks to determine stack overflows

I've read before that you can use the "--hook-entry" and "--hook-exit" to determine a stack overflow. Does anyone have a practical example on how to achieve this?

  • Sorry for digging out this old post but i'm trying to achieve the same and can't find some useful information :(
    If i create an entry hook and place an assert in it, then the debugger can't show me what triggered it (i.e. which function called the entry hook or where in the code the msp currently is). It seems as if this totally messes up the debugger.

  • Have you looked at section 2.14 of SLAU132? It has the information about using hooks. I have yet to see a real-life example of this personally.
  • I've just implemented a small hook function to do exactly that: detect a stack overflow on an msp430:

    #define STACK_END ( 0x400 - 0x50 )
    void hook_sp_check( void ){
    uint16_t SP = _get_SP_register();
    if( SP < STACK_END ){
    while( 1 );
    }
    }

    compile with option "--entry_hook=hook_sp_check"

    Now I just need to use proper variables for STACK_END, and I'm set. :)

**Attention** This is a public forum