You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
908 B
33 lines
908 B
3 years ago
|
/**
|
||
|
* Utilities for heap usage debugging
|
||
|
*
|
||
|
* Created on 2020/10/23.
|
||
|
*/
|
||
|
|
||
|
#ifndef CSPEMU_HEAP_DEBUG_H
|
||
|
#define CSPEMU_HEAP_DEBUG_H
|
||
|
#include <stdint.h>
|
||
|
#include <esp_heap_trace.h>
|
||
|
#include <esp_log.h>
|
||
|
|
||
|
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
|