diff --git a/lib/libesp32/Berry/src/be_exec.c b/lib/libesp32/Berry/src/be_exec.c index 2d71dab0f..8ed0bc8f1 100644 --- a/lib/libesp32/Berry/src/be_exec.c +++ b/lib/libesp32/Berry/src/be_exec.c @@ -390,6 +390,10 @@ void be_stack_expansion(bvm *vm, int n) stack_resize(vm, size + 1); be_raise(vm, "runtime_error", STACK_OVER_MSG(BE_STACK_TOTAL_MAX)); } +#if BE_USE_OBSERVABILITY_HOOK + if (vm->obshook != NULL) + (*vm->obshook)(vm, BE_OBS_STACK_RESIZE_START, size * sizeof(bvalue), (size + n) * sizeof(bvalue)); +#endif stack_resize(vm, size + n); } diff --git a/lib/libesp32/Berry/src/berry.h b/lib/libesp32/Berry/src/berry.h index fb67f28af..232a92262 100644 --- a/lib/libesp32/Berry/src/berry.h +++ b/lib/libesp32/Berry/src/berry.h @@ -405,6 +405,7 @@ enum beobshookevents { BE_OBS_GC_START, /* start of GC, arg = allocated size */ BE_OBS_GC_END, /* end of GC, arg = allocated size */ BE_OBS_VM_HEARTBEAT, /* VM heartbeat called every million instructions */ + BE_OBS_STACK_RESIZE_START, /* Berry stack resized */ }; /* FFI functions */ diff --git a/tasmota/xdrv_52_9_berry.ino b/tasmota/xdrv_52_9_berry.ino index b210ac446..113866c6f 100644 --- a/tasmota/xdrv_52_9_berry.ino +++ b/tasmota/xdrv_52_9_berry.ino @@ -268,6 +268,13 @@ void BerryObservability(bvm *vm, int event...) { } } break; + case BE_OBS_STACK_RESIZE_START: + { + int32_t stack_before = va_arg(param, int32_t); + int32_t stack_after = va_arg(param, int32_t); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_BERRY "Stack resized from %i to %i bytes"), stack_before, stack_after); + } + break; case BE_OBS_VM_HEARTBEAT: { // AddLog(LOG_LEVEL_INFO, ">>>: Heartbeat now=%i timeout=%i", millis(), berry.timeout);