Question
gdb backtrace/ exception handlers
Posted on May 24, 2012 at 20:20
Very occasionally, my code takes an unexpected exception and ends up in a default handler :)
I'd like to write such a handler so that GDB can successfully unwind the stack. For example,default_handler (void) { asm(''ldr lr, [sp, #28]''); while(1); }loads the link register from the value stored when the exception was taken (actually, it should be 24, but this is a quick hack because gcc does an extra push). With that I can at least see the call chain, but of course the register values aren't right and I don't see the frame that caused the exception. I'm thinking there's a magic incantation that would set things up so that gdb could properly unwind the stack (e.g. make it look a call to a signal handler ??)Any thoughts ?Geoffrey