feat(freertos): Add memory mark to trace heap over call levels

This commit is contained in:
Dong Heng
2018-07-18 15:25:57 +08:00
parent 627452e85c
commit 48a173e358
2 changed files with 27 additions and 0 deletions

View File

@ -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
{

View File

@ -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