Merge pull request #13227 from s-hadinger/berry_stacktrace

Berry print stack trace when exception, more detailed with line numbers if `#define USE_BERRY_DEBUG`
This commit is contained in:
s-hadinger 2021-09-27 14:03:48 +02:00 committed by GitHub
commit bd49586715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Support for Sensirion SCD40/SCD41 CO2 sensor (#13139)
- Support for BL0939 energy monitor as used in ESP32 based Sonoff Dual R3 V2 Pow (#13195)
- Command ``WebQuery <url> GET|POST|PUT|PATCH [<headers>] <body>`` to extent HTTP requests (#13209)
- Berry print stack trace when exception, more detailed with line numbers if `#define USE_BERRY_DEBUG`
### Changed
- M5 Stack Core2 uses UNIVERSAL_DISPLAY with enabled LVGL as default now

View File

@ -216,4 +216,10 @@ extern "C" {
**/
#define be_assert(expr) assert(expr)
/* Tasmota debug specific */
#ifdef USE_BERRY_DEBUG
#undef BE_DEBUG_RUNTIME_INFO
#define BE_DEBUG_RUNTIME_INFO 2 /* record line information in 16 bits */
#endif // USE_BERRY_DEBUG
#endif

View File

@ -982,6 +982,7 @@
#define USE_BERRY // Enable Berry scripting language
#define USE_BERRY_PSRAM // Allocate Berry memory in PSRAM if PSRAM is connected - this might be slightly slower but leaves main memory intact
// #define USE_BERRY_DEBUG // Compile Berry bytecode with line number information, makes exceptions easier to debug. Adds +8% of memory consumption for compiled code
#define USE_WEBCLIENT // Enable `webclient` to make HTTP/HTTPS requests. Can be disabled for security reasons.
// #define USE_WEBCLIENT_HTTPS // Enable HTTPS outgoing requests based on BearSSL (much ligher then mbedTLS, 42KB vs 150KB) in insecure mode (no verification of server's certificate)
// Note that only one cipher is enabled: ECDHE_RSA_WITH_AES_128_GCM_SHA256 which is very commonly used and highly secure

View File

@ -27,6 +27,7 @@
extern "C" {
extern void be_load_custom_libs(bvm *vm);
extern void be_tracestack(bvm *vm);
}
const char kBrCommands[] PROGMEM = D_PRFX_BR "|" // prefix
@ -115,6 +116,8 @@ void BerryDumpErrorAndClear(bvm *vm, bool berry_console) {
if (top >= 2 && be_isstring(vm, -1) && be_isstring(vm, -2)) {
if (berry_console) {
berry_log_C(PSTR(D_LOG_BERRY "Exception> '%s' - %s"), be_tostring(berry.vm, -2), be_tostring(berry.vm, -1));
be_tracestack(vm);
top = be_top(vm); // update top after dump
} else {
AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_BERRY "Exception> '%s' - %s"), be_tostring(berry.vm, -2), be_tostring(berry.vm, -1));
}