aducrf101: Add stack pointer sampling, to help debug overflows

This commit is contained in:
Jim Paris 2014-07-29 18:07:33 -04:00
parent 3e193cca2c
commit 4aa2a8b95c

View file

@ -43,9 +43,25 @@ static volatile clock_time_t current_clock = 0;
static volatile unsigned long current_seconds = 0;
static unsigned int second_countdown = CLOCK_SECOND;
#define SAMPLE_STACK_POINTER
#ifdef SAMPLE_STACK_POINTER
volatile uint32_t *__min_sampled_sp = (uint32_t *)0xFFFFFFFF;
#endif
void
SysTick_Handler(void)
{
#ifdef SAMPLE_STACK_POINTER
/* Take note of the lowest stack pointer we ever saw.
When compiling against newlib, the total free bytes of
RAM not ever used by heap or stack can be found via GDB:
(gdb) p (char *)__min_sampled_sp - (char *)_sbrk(0)
*/
uint32_t *sp = (uint32_t *)&sp;
if (sp < __min_sampled_sp)
__min_sampled_sp = sp;
#endif
current_clock++;
if(etimer_pending()) {
etimer_request_poll();