/** * Utilities for heap usage debugging * * Created on 2020/10/23. */ #ifndef CSPEMU_HEAP_DEBUG_H #define CSPEMU_HEAP_DEBUG_H #include #include #include extern uint32_t heapdebug_start; extern const char *heapdebug_start_name; #define HEAP_MEASURE_START(msg) \ heapdebug_start_name = msg; \ ESP_LOGD(TAG, "/-- HEAP_BEGIN: %s", msg); \ heapdebug_start = esp_get_free_heap_size(); #define HEAP_TRACE_START() ESP_LOGD(TAG, "--- Start heap tracing!"); \ ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) ); #define HEAP_MEASURE_END() \ ESP_LOGD(TAG, "\\--- HEAP_END: %s, used %d", \ heapdebug_start_name, (int32_t)heapdebug_start - (int32_t)esp_get_free_heap_size()); #define HEAP_TRACE_END() ESP_LOGD(TAG, "--- End heap tracing!"); \ ESP_ERROR_CHECK( heap_trace_stop() ); \ heap_trace_dump(); #endif //CSPEMU_HEAP_DEBUG_H