Improve pvPortMalloc() and family.

fix(esp8266): If MEMLEAK_DEBUG is defined, create an alternate function
called `.._trace` that for each of `pvPortMalloc`, `pvPortZalloc`,
`pvPortCalloc` and `vPortFree`. The original function delegates to this new
tracing function but uses NULL and 0 for the file and line number. This ensures
that the pvPortMalloc exists as a symbol that can be used by the binary blobs
without any problems.

Example output from earlier usage:

~~~
--------Show Malloc--------
F:ppT	L:512	malloc 2064	@ 0x3ffefd08
F:pmT	L:256	malloc 1040	@ 0x3fff0518
F:tiT	L:512	malloc 2064	@ 0x3fff0928
F:uiT	L:640	malloc 2576	@ 0x3fff1138
F:IDLE	L:176	malloc 720	@ 0x3fff1b48
F:Tmr Svc	L:512	malloc 2064	@ 0x3fff1e18
~~~

fix(lwip): Remove declarations of `pvPortMalloc()` and family.

This fixes some of the issues in espressif/ESP8266_RTOS_SDK#189 but some of the
example applications fails. Not ready for merge but comments on my approach
will be appreciated.
This commit is contained in:
Trygve Laugstøl
2018-05-20 20:54:07 +02:00
committed by Wu Jian Gang
parent 9daf22b07b
commit 24ef94f811
5 changed files with 64 additions and 34 deletions

View File

@ -118,7 +118,7 @@ bool ICACHE_FLASH_ATTR check_memleak_debug_enable(void)
#define os_free(s) \
do{\
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
vPortFree(s, mem_debug_file, __LINE__);\
vPortFree_trace(s, mem_debug_file, __LINE__);\
}while(0)
#endif
@ -126,7 +126,7 @@ do{\
#define os_malloc(s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortMalloc(s, mem_debug_file, __LINE__, false); \
pvPortMalloc_trace(s, mem_debug_file, __LINE__, false); \
})
#endif
@ -134,7 +134,7 @@ do{\
#define os_malloc_iram(s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortMalloc(s, mem_debug_file, __LINE__, true); \
pvPortMalloc_trace(s, mem_debug_file, __LINE__, true); \
})
#endif
@ -142,7 +142,7 @@ do{\
#define os_calloc(p, s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortCalloc(p, s, mem_debug_file, __LINE__); \
pvPortCalloc_trace(p, s, mem_debug_file, __LINE__); \
})
#endif
@ -150,7 +150,7 @@ do{\
#define os_realloc(p, s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortRealloc(p, s, mem_debug_file, __LINE__); \
pvPortRealloc_trace(p, s, mem_debug_file, __LINE__); \
})
#endif
@ -158,7 +158,7 @@ do{\
#define os_zalloc(s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortZalloc(s, mem_debug_file, __LINE__); \
pvPortZalloc_trace(s, mem_debug_file, __LINE__); \
})
#endif