From 3ca1585c4f6e8c0e1e743d8a168e65b1f5a4da65 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 23 Mar 2014 10:11:14 -0600 Subject: [PATCH] AVR assertion logic will report stack usage on crash if DEBUG_STACK is set --- arch/avr/src/avr/up_dumpstate.c | 17 ++++++++++++++++- arch/avr/src/avr32/up_dumpstate.c | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/arch/avr/src/avr/up_dumpstate.c b/arch/avr/src/avr/up_dumpstate.c index 6ba50d2381..ba81eda2e2 100644 --- a/arch/avr/src/avr/up_dumpstate.c +++ b/arch/avr/src/avr/up_dumpstate.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_dumpstate.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -58,6 +58,12 @@ * Pre-processor Definitions ****************************************************************************/ +/* Check if we can dump stack usage information */ + +#ifndef CONFIG_DEBUG +# undef CONFIG_DEBUG_STACK +#endif + /* Output debug info if stack dump is selected -- even if debug is not * selected. */ @@ -202,6 +208,9 @@ void up_dumpstate(void) lldbg("IRQ stack:\n"); lldbg(" base: %04x\n", istackbase); lldbg(" size: %04x\n", istacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg(" used: %08x\n", up_check_intstack()); +#endif /* Does the current stack pointer lie within the interrupt * stack? @@ -228,6 +237,9 @@ void up_dumpstate(void) lldbg("User stack:\n"); lldbg(" base: %04x\n", ustackbase); lldbg(" size: %04x\n", ustacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg(" used: %08x\n", up_check_tcbstack(rtcb)); +#endif /* Dump the user stack if the stack pointer lies within the allocated user * stack memory. @@ -241,6 +253,9 @@ void up_dumpstate(void) lldbg("sp: %04x\n", sp); lldbg("stack base: %04x\n", ustackbase); lldbg("stack size: %04x\n", ustacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg("stack used: %08x\n", up_check_tcbstack(rtcb)); +#endif /* Dump the user stack if the stack pointer lies within the allocated user * stack memory. diff --git a/arch/avr/src/avr32/up_dumpstate.c b/arch/avr/src/avr32/up_dumpstate.c index 90cb228377..bc74d9bb04 100644 --- a/arch/avr/src/avr32/up_dumpstate.c +++ b/arch/avr/src/avr32/up_dumpstate.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr32/up_dumpstate.c * - * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -58,6 +58,12 @@ * Pre-processor Definitions ****************************************************************************/ +/* Check if we can dump stack usage information */ + +#ifndef CONFIG_DEBUG +# undef CONFIG_DEBUG_STACK +#endif + /* Output debug info if stack dump is selected -- even if debug is not * selected. */ @@ -179,6 +185,9 @@ void up_dumpstate(void) lldbg("IRQ stack:\n"); lldbg(" base: %08x\n", istackbase); lldbg(" size: %08x\n", istacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg(" used: %08x\n", up_check_intstack()); +#endif /* Does the current stack pointer lie within the interrupt * stack? @@ -205,6 +214,9 @@ void up_dumpstate(void) lldbg("User stack:\n"); lldbg(" base: %08x\n", ustackbase); lldbg(" size: %08x\n", ustacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg(" used: %08x\n", up_check_tcbstack(rtcb)); +#endif /* Dump the user stack if the stack pointer lies within the allocated user * stack memory. @@ -218,6 +230,9 @@ void up_dumpstate(void) lldbg("sp: %08x\n", sp); lldbg("stack base: %08x\n", ustackbase); lldbg("stack size: %08x\n", ustacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg("stack used: %08x\n", up_check_tcbstack(rtcb)); +#endif /* Dump the user stack if the stack pointer lies within the allocated user * stack memory.