dd8c6c064c
Instead of having to guess the PC where the SP was sampled, always take both. This allows "seamless" stack decoding for both serial and xflash dumps, since we don't have to guess which function generated the dump. Make the core functions (doing the sampling) be ``noinline`` as well, so that they always have valid frame.
28 lines
458 B
C
28 lines
458 B
C
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#ifdef __AVR_ATmega2560__
|
|
|
|
// return the current PC (on AVRs with 22bit PC)
|
|
static inline void GETPC(uint32_t* v)
|
|
{
|
|
uint8_t a, b, c;
|
|
asm
|
|
(
|
|
"rcall .\n"
|
|
"pop %2\n"
|
|
"pop %1\n"
|
|
"pop %0\n"
|
|
: "=r" (a), "=r" (b), "=r" (c)
|
|
);
|
|
((uint8_t*)v)[0] = a;
|
|
((uint8_t*)v)[1] = b;
|
|
((uint8_t*)v)[2] = c;
|
|
((uint8_t*)v)[3] = 0;
|
|
|
|
// go back 1 instruction before rcall
|
|
*v = (*v - 2) * 2;
|
|
}
|
|
|
|
#endif
|