diff --git a/components/freertos/port/esp8266/heap_5.c b/components/freertos/port/esp8266/heap_5.c index 7f43e8d5..0e94d843 100644 --- a/components/freertos/port/esp8266/heap_5.c +++ b/components/freertos/port/esp8266/heap_5.c @@ -332,6 +332,17 @@ size_t xPortWantedSizeAlign(size_t xWantedSize) return xWantedSize; } +/* + * @brief add trace information to allocated memory + */ +void esp_mem_trace(const void *ptr, const char *trace, int no) +{ + BlockLink_t *pxLink = (BlockLink_t *)((uint8_t *)ptr - uxHeapStructSize); + + pxLink->file = trace; + pxLink->line = (unsigned)no; +} + void *pvPortMalloc( size_t xWantedSize ) #ifdef MEMLEAK_DEBUG { diff --git a/components/freertos/port/esp8266/include/freertos/portmacro.h b/components/freertos/port/esp8266/include/freertos/portmacro.h index 6e830a18..27ea1f7f 100644 --- a/components/freertos/port/esp8266/include/freertos/portmacro.h +++ b/components/freertos/port/esp8266/include/freertos/portmacro.h @@ -208,6 +208,22 @@ typedef struct _xt_isr_entry_ { void show_critical_info(void); +/* + * @brief add trace information to allocated memory + * + * @param ptr memory pointer allocated by "os_maloc", "malloc" and so on + * @param trace trace information, file name(__FILE__) or "__builtin_return_address(0)" is OK + * @param no number of trace information, file line(__LINE__) or -1(using "__builtin_return_address(0)") + */ +void esp_mem_trace(const void *ptr, const char *trace, int no); + +/* + * @brief add file trace information to allocated memory + * + * @param ptr memory pointer allocated by "os_maloc", "malloc" and so on + */ +#define esp_mem_mark_file(ptr) esp_mem_trace((ptr), __FILE__, LINE__) + #ifdef __cplusplus } #endif