Added detection of case when no unwind tables are available

This commit is contained in:
etagle
2018-03-23 05:22:45 -03:00
parent b210bdf032
commit c3b23974bd
3 changed files with 228 additions and 72 deletions

View File

@ -114,7 +114,9 @@ static void TXDec(uint32_t v) {
// Dump a backtrace entry
static void backtrace_dump_fn(int idx, const backtrace_t* bte, void* ctx) {
TX('#'); TXDec(idx); TX(' '); TX(bte->name); TX(" @ ");TXHex((uint32_t)bte->address); TX('\n');
TX('#'); TXDec(idx); TX(' ');
TX(bte->name); TX('@');TXHex((uint32_t)bte->function); TX('+'); TXDec((uint32_t)bte->address - (uint32_t)bte->function);
TX(" PC:");TXHex((uint32_t)bte->address); TX('\n');
}
/**
@ -176,6 +178,19 @@ void HardFault_HandlerC(unsigned long *hardfault_args, unsigned long cause) {
btf.pc = ((unsigned long)hardfault_args[6]);
backtrace_dump(&btf, backtrace_dump_fn, nullptr);
// Disable all NVIC interrupts
NVIC->ICER[0] = 0xFFFFFFFF;
NVIC->ICER[1] = 0xFFFFFFFF;
// Relocate VTOR table to default position
SCB->VTOR = 0;
// Disable USB
otg_disable();
// Restart watchdog
WDT_Restart(WDT);
// Reset controller
NVIC_SystemReset();
while(1) { WDT_Restart(WDT); }