From 632b13fe03b98d69ffa0e8e557108bee2442ca5e Mon Sep 17 00:00:00 2001 From: anjiahao Date: Sun, 7 Apr 2024 17:56:47 +0800 Subject: [PATCH] stack recored:Fixed the problem of missing the 0th data in statistics Signed-off-by: anjiahao --- fs/procfs/fs_procfsproc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 10f4311e735..a31d9471b7a 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -1061,12 +1061,13 @@ static ssize_t proc_stack(FAR struct proc_file_s *procfile, buffer += copysize; remaining -= copysize; - for (i = tcb->level_deepest - 1; i > 0; i--) + for (i = tcb->level_deepest - 1; i >= 0; i--) { linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%-12zu%-pS\n", - tcb->stackrecord_sp_deepest[i - 1] - - tcb->stackrecord_sp_deepest[i], + (i ? tcb->stackrecord_sp_deepest[i - 1] : + tcb->stack_base_ptr + tcb->adj_stack_size) + - tcb->stackrecord_sp_deepest[i], tcb->stackrecord_pc_deepest[i]); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);