mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt: Add functions for heap memory debug
This commit is contained in:
parent
bd9fed4400
commit
5fd4cbb9d2
@ -38,6 +38,8 @@ typedef struct {
|
|||||||
static uint32_t mem_dbg_count = 0;
|
static uint32_t mem_dbg_count = 0;
|
||||||
static uint32_t mem_dbg_count2 = 0;
|
static uint32_t mem_dbg_count2 = 0;
|
||||||
static osi_mem_dbg_info_t mem_dbg_info[OSI_MEM_DBG_INFO_MAX];
|
static osi_mem_dbg_info_t mem_dbg_info[OSI_MEM_DBG_INFO_MAX];
|
||||||
|
static uint32_t mem_dbg_total_size = 0;
|
||||||
|
static uint32_t mem_dbg_max_size = 0;
|
||||||
|
|
||||||
void osi_mem_dbg_init(void)
|
void osi_mem_dbg_init(void)
|
||||||
{
|
{
|
||||||
@ -51,6 +53,8 @@ void osi_mem_dbg_init(void)
|
|||||||
}
|
}
|
||||||
mem_dbg_count = 0;
|
mem_dbg_count = 0;
|
||||||
mem_dbg_count2 = 0;
|
mem_dbg_count2 = 0;
|
||||||
|
mem_dbg_total_size = 0;
|
||||||
|
mem_dbg_max_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osi_mem_dbg_record(void *p, int size, const char *func, int line)
|
void osi_mem_dbg_record(void *p, int size, const char *func, int line)
|
||||||
@ -76,6 +80,11 @@ void osi_mem_dbg_record(void *p, int size, const char *func, int line)
|
|||||||
if (i >= OSI_MEM_DBG_INFO_MAX) {
|
if (i >= OSI_MEM_DBG_INFO_MAX) {
|
||||||
OSI_TRACE_ERROR("%s full %s %d !!\n", __func__, func, line);
|
OSI_TRACE_ERROR("%s full %s %d !!\n", __func__, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem_dbg_total_size += size;
|
||||||
|
if(mem_dbg_max_size < mem_dbg_total_size) {
|
||||||
|
mem_dbg_max_size = mem_dbg_total_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void osi_mem_dbg_clean(void *p, const char *func, int line)
|
void osi_mem_dbg_clean(void *p, const char *func, int line)
|
||||||
@ -89,6 +98,7 @@ void osi_mem_dbg_clean(void *p, const char *func, int line)
|
|||||||
|
|
||||||
for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) {
|
for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) {
|
||||||
if (mem_dbg_info[i].p == p) {
|
if (mem_dbg_info[i].p == p) {
|
||||||
|
mem_dbg_total_size -= mem_dbg_info[i].size;
|
||||||
mem_dbg_info[i].p = NULL;
|
mem_dbg_info[i].p = NULL;
|
||||||
mem_dbg_info[i].size = 0;
|
mem_dbg_info[i].size = 0;
|
||||||
mem_dbg_info[i].func = NULL;
|
mem_dbg_info[i].func = NULL;
|
||||||
@ -113,6 +123,17 @@ void osi_mem_dbg_show(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OSI_TRACE_ERROR("--> count %d\n", mem_dbg_count);
|
OSI_TRACE_ERROR("--> count %d\n", mem_dbg_count);
|
||||||
|
OSI_TRACE_ERROR("--> size %dB\n--> max size %dB\n", mem_dbg_total_size, mem_dbg_max_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t osi_mem_dbg_get_max_size(void)
|
||||||
|
{
|
||||||
|
return mem_dbg_max_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t osi_mem_dbg_get_total_size(void)
|
||||||
|
{
|
||||||
|
return mem_dbg_total_size;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ void osi_mem_dbg_init(void);
|
|||||||
void osi_mem_dbg_record(void *p, int size, const char *func, int line);
|
void osi_mem_dbg_record(void *p, int size, const char *func, int line);
|
||||||
void osi_mem_dbg_clean(void *p, const char *func, int line);
|
void osi_mem_dbg_clean(void *p, const char *func, int line);
|
||||||
void osi_mem_dbg_show(void);
|
void osi_mem_dbg_show(void);
|
||||||
|
uint32_t osi_mem_dbg_get_max_size(void);
|
||||||
|
uint32_t osi_mem_dbg_get_total_size(void);
|
||||||
|
|
||||||
#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
|
#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
|
||||||
#define osi_malloc(size) \
|
#define osi_malloc(size) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user