From 63db77628eb455b1c4b9443471f7184c31330dd7 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Thu, 7 Mar 2024 11:38:51 +0800 Subject: [PATCH] stack record: fix ps can't show stack used Signed-off-by: anjiahao --- fs/procfs/fs_procfsproc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index a31d9471b7..acf8c39331 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -1040,6 +1040,24 @@ static ssize_t proc_stack(FAR struct proc_file_s *procfile, buffer += copysize; remaining -= copysize; +#ifdef CONFIG_STACK_COLORATION + if (totalsize >= buflen) + { + return totalsize; + } + + /* Show the stack size */ + + linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%-12s%ld\n", + "StackUsed:", (long)up_check_tcbstack(tcb)); + copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, + &offset); + + totalsize += copysize; + buffer += copysize; + remaining -= copysize; +#endif + #if CONFIG_SCHED_STACK_RECORD > 0 linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%-12s%zu\n", "StackMax: ", @@ -1091,24 +1109,6 @@ static ssize_t proc_stack(FAR struct proc_file_s *procfile, } #endif -#ifdef CONFIG_STACK_COLORATION - if (totalsize >= buflen) - { - return totalsize; - } - - /* Show the stack size */ - - linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%-12s%ld\n", - "StackUsed:", (long)up_check_tcbstack(tcb)); - copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, - &offset); - - totalsize += copysize; - buffer += copysize; - remaining -= copysize; -#endif - return totalsize; }