From cd650b30bd3ddfb9f71622278ef5b6f94ae27ac8 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 19 Jan 2024 12:52:41 +1100 Subject: fix some lua stack leaks + add a console func to help debug --- src/app_console/app_console.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/app_console') diff --git a/src/app_console/app_console.cpp b/src/app_console/app_console.cpp index 2d16b60b..7347f130 100644 --- a/src/app_console/app_console.cpp +++ b/src/app_console/app_console.cpp @@ -43,6 +43,7 @@ #include "service_locator.hpp" #include "system_events.hpp" #include "track.hpp" +#include "ui_events.hpp" namespace console { @@ -326,6 +327,25 @@ void RegisterHeaps() { esp_console_cmd_register(&cmd); } +int CmdStacks(int argc, char** argv) { + static const std::pmr::string usage = "usage: stacks"; + if (argc != 1) { + std::cout << usage << std::endl; + return 1; + } + events::Ui().Dispatch(ui::DumpLuaStack{}); + return 0; +} + +void RegisterStacks() { + esp_console_cmd_t cmd{.command = "stacks", + .help = "prints contents of each lua stack", + .hint = NULL, + .func = &CmdStacks, + .argtable = NULL}; + esp_console_cmd_register(&cmd); +} + #if CONFIG_HEAP_TRACING static heap_trace_record_t* sTraceRecords = nullptr; static bool sIsTracking = false; @@ -630,6 +650,7 @@ auto AppConsole::RegisterExtraComponents() -> void { RegisterTasks(); RegisterHeaps(); + RegisterStacks(); #if CONFIG_HEAP_TRACING RegisterAllocs(); -- cgit v1.2.3