mm: Simplify memdump_handler logic a little bit
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
590e968c5f
commit
07b0cd1cba
@ -485,31 +485,29 @@ void mempool_memdump(FAR struct mempool_s *pool,
|
||||
{
|
||||
FAR struct mempool_backtrace_s *buf;
|
||||
|
||||
list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s,
|
||||
node)
|
||||
list_for_every_entry(&pool->alist, buf,
|
||||
struct mempool_backtrace_s, node)
|
||||
{
|
||||
if ((dump->pid == PID_MM_ALLOC || dump->pid == buf->pid) &&
|
||||
buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax)
|
||||
{
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
int i;
|
||||
FAR const char *format = " %0*p";
|
||||
# endif
|
||||
char bt[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1];
|
||||
char tmp[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1] = "";
|
||||
|
||||
bt[0] = '\0';
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
FAR const char *format = " %0*p";
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_MM_BACKTRACE && buf->backtrace[i]; i++)
|
||||
{
|
||||
snprintf(bt + i * MM_PTR_FMT_WIDTH,
|
||||
sizeof(bt) - i * MM_PTR_FMT_WIDTH,
|
||||
snprintf(tmp + i * MM_PTR_FMT_WIDTH,
|
||||
sizeof(tmp) - i * MM_PTR_FMT_WIDTH,
|
||||
format, MM_PTR_FMT_WIDTH - 1, buf->backtrace[i]);
|
||||
}
|
||||
# endif
|
||||
|
||||
syslog(LOG_INFO, "%6d%12zu%12lu%*p%s\n",
|
||||
(int)buf->pid, blocksize, buf->seqno,
|
||||
MM_PTR_FMT_WIDTH, ((FAR char *)buf - blocksize), bt);
|
||||
MM_PTR_FMT_WIDTH, ((FAR char *)buf - blocksize), tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,14 +70,12 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
|
||||
nodesize, MM_PTR_FMT_WIDTH,
|
||||
((FAR char *)node + SIZEOF_MM_ALLOCNODE));
|
||||
#else
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
int i;
|
||||
FAR const char *format = " %0*p";
|
||||
# endif
|
||||
char buf[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1];
|
||||
char buf[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1] = "";
|
||||
|
||||
buf[0] = '\0';
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
FAR const char *format = " %0*p";
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_MM_BACKTRACE && node->backtrace[i]; i++)
|
||||
{
|
||||
snprintf(buf + i * MM_PTR_FMT_WIDTH,
|
||||
|
@ -415,14 +415,12 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
syslog(LOG_INFO, "%12zu%*p\n", size, MM_PTR_FMT_WIDTH, ptr);
|
||||
#else
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
int i;
|
||||
FAR const char *format = " %0*p";
|
||||
# endif
|
||||
char tmp[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1];
|
||||
char tmp[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1] = "";
|
||||
|
||||
tmp[0] = '\0';
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
FAR const char *format = " %0*p";
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_MM_BACKTRACE && buf->backtrace[i]; i++)
|
||||
{
|
||||
snprintf(tmp + i * MM_PTR_FMT_WIDTH,
|
||||
|
Loading…
Reference in New Issue
Block a user