diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index c81df559477..824a6e5ae87 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -56,7 +56,7 @@ * to handle the longest line generated by this logic. */ -#define MEMINFO_LINELEN 80 +#define MEMINFO_LINELEN 256 /**************************************************************************** * Private Types @@ -404,7 +404,6 @@ static ssize_t memdump_read(FAR struct file *filep, FAR char *buffer, FAR struct meminfo_file_s *procfile; size_t linesize; size_t copysize; - size_t totalsize; off_t offset; finfo("buffer=%p buflen=%d\n", buffer, (int)buflen); @@ -419,41 +418,26 @@ static ssize_t memdump_read(FAR struct file *filep, FAR char *buffer, #if CONFIG_MM_BACKTRACE >= 0 linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "usage: " - " \n" + "usage: " + " \n" "on/off backtrace\n" - "pid: dump pid allocated node\n"); + "pid: dump pid allocated node\n" + "used: dump all allocated node\n" + "free: dump all free node\n" + "leak: dump all leaked node\n" + "The current sequence number %lu\n", + g_mm_seqno); #else linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "usage: \n"); + "usage: \n" + "used: dump all allocated node\n" + "free: dump all free node\n"); #endif copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, &offset); - totalsize = copysize; - buffer += copysize; - buflen -= copysize; - linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "used: dump all allocated node\n" - "free: dump all free node\n"); - - copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, - &offset); - totalsize += copysize; - -#if CONFIG_MM_BACKTRACE >= 0 - buffer += copysize; - buflen -= copysize; - linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "The current sequence number %lu\n", - g_mm_seqno); - - totalsize += procfs_memcpy(procfile->line, linesize, buffer, buflen, - &offset); -#endif - - filep->f_pos += totalsize; - return totalsize; + filep->f_pos += copysize; + return copysize; } #endif @@ -556,6 +540,16 @@ static ssize_t memdump_write(FAR struct file *filep, FAR const char *buffer, goto dump; #endif break; + + case 'l': + dump.pid = PID_MM_LEAK; + +#if CONFIG_MM_BACKTRACE >= 0 + p = (FAR char *)buffer + 4; + goto dump; +#endif + break; + #if CONFIG_MM_BACKTRACE >= 0 default: if (!isdigit(buffer[0])) diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index 47d851349cd..f97913e1a17 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -427,7 +427,7 @@ mempool_info_task(FAR struct mempool_s *pool, node) { if ((task->pid == buf->pid || task->pid == PID_MM_ALLOC || - (task->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) && + (task->pid == PID_MM_LEAK && !nxsched_get_tcb(buf->pid))) && buf->seqno >= task->seqmin && buf->seqno <= task->seqmax) { info.aordblks++; @@ -490,7 +490,7 @@ void mempool_memdump(FAR struct mempool_s *pool, struct mempool_backtrace_s, node) { if ((dump->pid == buf->pid || dump->pid == PID_MM_ALLOC || - (dump->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) && + (dump->pid == PID_MM_LEAK && !nxsched_get_tcb(buf->pid))) && buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax) { char tmp[CONFIG_MM_BACKTRACE * MM_PTR_FMT_WIDTH + 1] = ""; diff --git a/mm/mm_heap/mm_mallinfo.c b/mm/mm_heap/mm_mallinfo.c index a0f14535589..d844bd9293c 100644 --- a/mm/mm_heap/mm_mallinfo.c +++ b/mm/mm_heap/mm_mallinfo.c @@ -106,7 +106,8 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node, #else if ((task->pid == node->pid || (task->pid == PID_MM_ALLOC && node->pid != PID_MM_MEMPOOL) || - (task->pid == PID_MM_LEAK && !!nxsched_get_tcb(node->pid))) && + (task->pid == PID_MM_LEAK && node->pid >= 0 && + !nxsched_get_tcb(node->pid))) && node->seqno >= task->seqmin && node->seqno <= task->seqmax) { info->aordblks++; diff --git a/mm/mm_heap/mm_memdump.c b/mm/mm_heap/mm_memdump.c index 57b831982b6..7f45c2f419f 100644 --- a/mm/mm_heap/mm_memdump.c +++ b/mm/mm_heap/mm_memdump.c @@ -61,9 +61,9 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg) #if CONFIG_MM_BACKTRACE < 0 if (dump->pid == PID_MM_ALLOC) #else - if ((dump->pid == node->pid || - (dump->pid == PID_MM_ALLOC && node->pid != PID_MM_MEMPOOL) || - (dump->pid == PID_MM_LEAK && !!nxsched_get_tcb(node->pid))) && + if ((dump->pid == node->pid || dump->pid == PID_MM_ALLOC || + (dump->pid == PID_MM_LEAK && node->pid >= 0 && + !nxsched_get_tcb(node->pid))) && node->seqno >= dump->seqmin && node->seqno <= dump->seqmax) #endif { diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 30de861a39c..70ae02af17f 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -299,7 +299,8 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used, if ((task->pid == buf->pid || (task->pid == PID_MM_ALLOC && buf->pid != PID_MM_MEMPOOL) || - (task->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) && + (task->pid == PID_MM_LEAK && buf->pid >= 0 && + !nxsched_get_tcb(buf->pid))) && buf->seqno >= task->seqmin && buf->seqno <= task->seqmax) { info->aordblks++; @@ -412,7 +413,8 @@ static void memdump_handler(FAR void *ptr, size_t size, int used, if ((dump->pid == buf->pid || (dump->pid == PID_MM_ALLOC && buf->pid != PID_MM_MEMPOOL) || - (dump->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) && + (dump->pid == PID_MM_LEAK && buf->pid >= 0 && + !nxsched_get_tcb(buf->pid))) && buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax) #endif {