arm: move trace dump to crash handler
This commit is contained in:
parent
ec024adfff
commit
02fbb1c671
@ -3,6 +3,7 @@
|
||||
#include "gpio.h"
|
||||
#include "itoa.h"
|
||||
#include "sleep.h"
|
||||
#include "trace.h"
|
||||
#include "uart.h"
|
||||
|
||||
extern "C" uint32_t _initial_stack_pointer, _text_begin, _text_end;
|
||||
@ -80,6 +81,8 @@ void CrashHandler(Armv6mRegs* regs) {
|
||||
UartWriteCrash("- Stack trace:\r\n");
|
||||
StackTrace(reinterpret_cast<uint32_t*>(regs->sp));
|
||||
|
||||
tracing::dump();
|
||||
|
||||
while (1) {
|
||||
gpio0->data = 0x55;
|
||||
sleep(100);
|
||||
|
@ -18,10 +18,7 @@ void Uart0Isr() {
|
||||
HandleUartIsr();
|
||||
}
|
||||
|
||||
void Timer0Isr() {
|
||||
tracing::dump();
|
||||
__builtin_trap();
|
||||
}
|
||||
void Timer0Isr() { __builtin_trap(); }
|
||||
|
||||
void SetupUart() {
|
||||
InitUarts();
|
||||
|
@ -7,14 +7,19 @@
|
||||
#include "timer.h"
|
||||
#include "uart.h"
|
||||
|
||||
#ifndef SBRK_STATS
|
||||
#define SBRK_STATS 0
|
||||
#endif
|
||||
|
||||
extern unsigned char _heap_begin, _heap_end;
|
||||
|
||||
namespace {
|
||||
[[maybe_unused]]
|
||||
void LogStats(unsigned char* heap) {
|
||||
char number[] = "00000000\r\n";
|
||||
UartWriteBlocking("Program break now at 0x");
|
||||
UartWriteCrash("Program break now at 0x");
|
||||
itoa(reinterpret_cast<int>(heap), number);
|
||||
UartWriteBlocking(number);
|
||||
UartWriteCrash(number);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -22,11 +27,13 @@ extern "C" void* _sbrk(int increment) {
|
||||
static unsigned char* heap = &_heap_begin;
|
||||
unsigned char* prev_heap = heap;
|
||||
if (heap + increment >= &_heap_end) {
|
||||
UartWriteBlocking("Heap overflow!\r\n");
|
||||
UartWriteCrash("Heap overflow!\r\n");
|
||||
return reinterpret_cast<void*>(-1);
|
||||
}
|
||||
heap += increment;
|
||||
#if SBRK_STATS
|
||||
LogStats(heap);
|
||||
#endif
|
||||
return prev_heap;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user