1#include "main-header.h"
4#include "function-instr.h"
6static byte pc_listing_enabled = 0;
8void __cyg_profile_func_enter(
void *func,
void *callsite) __attribute__((no_instrument_function));
9void __cyg_profile_func_exit(
void *func,
void *callsite) __attribute__((no_instrument_function));
10volatile byte overflow_check_active;
11extern void *_Stack_Limit;
13void stack_overflow(
void *sp) __attribute__((no_instrument_function));
28void __cyg_profile_func_enter(
void *func,
void *callsite) {
31 if (!pc_listing_enabled) {
35 constants()->last_return_address = __builtin_return_address(0);
36 if (!overflow_check_active) {
40 if (((
void *)(&spb)) < ((
void *)(&_Stack_Limit))) {
44void __cyg_profile_func_exit(
void *func,
void *callsite) {
47void stack_overflow(
void *sp) {
48 overflow_check_active = 0;
49 printf(
"A stack overflow has been detected (sp=%p, limit=%p).\r\n", sp, &_Stack_Limit);
50 printf(
"Return Address: %p\r\n", constants()->last_return_address);
51 long l = mculib_get_seconds_since_boot();
53 while ((mculib_get_seconds_since_boot() - l) < 3) {
56 printf(
"Reseting application\r\n");
60void enable_pc_tracing() {
61 pc_listing_enabled = 1;