1
0
Fork 0
forked from len0rd/rockbox

Arm stack unwinder

Simplified stack unwinder for ARM. This is port of
http://www.mcternan.me.uk/ArmStackUnwinding/
backtrace() is called from UIE() on native targets
and from panicf() on both native and ARM RaaA.

Change-Id: I8e4b3c02490dd60b30aa372fe842d193b8929ce0
This commit is contained in:
Marcin Bukat 2012-01-25 09:57:59 +01:00
parent 680c6fcde1
commit b4eab59951
23 changed files with 2630 additions and 18 deletions

View file

@ -31,14 +31,42 @@
#include "power.h"
#include "system.h"
#if defined(CPU_ARM)
#include "gcc_extensions.h"
#include <backtrace.h>
#endif
static char panic_buf[128];
#define LINECHARS (LCD_WIDTH/SYSFONT_WIDTH) - 2
#if defined(CPU_ARM)
void panicf_f( const char *fmt, ...);
/* we wrap panicf() here with naked function to catch SP value */
void panicf( const char *fmt, ...)
{
(void)fmt;
asm volatile ("mov r4, sp \n"
"b panicf_f \n"
);
}
/*
* "Dude. This is pretty fucked-up, right here."
*/
void panicf_f( const char *fmt, ...)
{
int sp;
asm volatile ("mov %[SP],r4 \n"
: [SP] "=r" (sp)
);
int pc = (int)__builtin_return_address(0);
#else
void panicf( const char *fmt, ...)
{
#endif
va_list ap;
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
@ -82,6 +110,10 @@ void panicf( const char *fmt, ...)
panic_buf[i+LINECHARS] = c;
}
}
#if defined(CPU_ARM)
backtrace(pc, sp, &y);
#endif
#else
/* no LCD */
#endif