fs/procfs: refine file backtrace

remove backtrace arrary in stack

Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
chao an 2024-06-27 23:37:10 +08:00 committed by Xiang Xiao
parent c6d712df0e
commit f857004227
3 changed files with 13 additions and 41 deletions

View File

@ -554,17 +554,6 @@ int file_allocate(FAR struct inode *inode, int oflags, off_t pos,
pos, priv, minfd, addref); pos, priv, minfd, addref);
} }
FAR char *file_dump_backtrace(FAR struct file *filep, FAR char *buffer,
size_t len)
{
#if CONFIG_FS_BACKTRACE > 0
backtrace_format(buffer, len, filep->f_backtrace, CONFIG_FS_BACKTRACE);
#else
buffer[0] = '\0';
#endif
return buffer;
}
/**************************************************************************** /****************************************************************************
* Name: files_duplist * Name: files_duplist
* *

View File

@ -1246,7 +1246,6 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
{ {
FAR struct task_group_s *group = tcb->group; FAR struct task_group_s *group = tcb->group;
FAR struct file *filep; FAR struct file *filep;
char backtrace[BACKTRACE_BUFFER_SIZE(CONFIG_FS_BACKTRACE)];
char path[PATH_MAX]; char path[PATH_MAX];
size_t remaining; size_t remaining;
size_t linesize; size_t linesize;
@ -1306,22 +1305,23 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
} }
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
"%-3d %-7d %-4x %-9ld %-14s %s\n", "%-3d %-7d %-4x %-9ld %-14s ",
i, filep->f_oflags, i, filep->f_oflags,
INODE_GET_TYPE(filep->f_inode), INODE_GET_TYPE(filep->f_inode),
(long)filep->f_pos, path, (long)filep->f_pos, path);
file_dump_backtrace(filep, if (linesize < STATUS_LINELEN)
backtrace, {
sizeof(backtrace) #if CONFIG_FS_BACKTRACE > 0
) linesize += backtrace_format(procfile->line + linesize,
); STATUS_LINELEN - linesize,
filep->f_backtrace,
CONFIG_FS_BACKTRACE);
#endif
procfile->line[linesize - 2] = '\n';
}
copysize = procfs_memcpy(procfile->line, linesize, copysize = procfs_memcpy(procfile->line, linesize,
buffer, remaining, &offset); buffer, remaining, &offset);
if (linesize + 1 == STATUS_LINELEN)
{
procfile->line[STATUS_LINELEN - 2] = '\n';
linesize = STATUS_LINELEN;
}
totalsize += copysize; totalsize += copysize;
buffer += copysize; buffer += copysize;

View File

@ -164,9 +164,6 @@
#define CH_STAT_ATIME (1 << 3) #define CH_STAT_ATIME (1 << 3)
#define CH_STAT_MTIME (1 << 4) #define CH_STAT_MTIME (1 << 4)
#define FS_BACKTRACE_WIDTH (sizeof(uintptr_t) * 2 + 3) /* 3: ' 0x' prefix */
#define FS_BACKTRACE_BUFFER_LEN (CONFIG_FS_BACKTRACE * FS_BACKTRACE_WIDTH + 1)
/**************************************************************************** /****************************************************************************
* Public Type Definitions * Public Type Definitions
****************************************************************************/ ****************************************************************************/
@ -963,20 +960,6 @@ int file_allocate_from_tcb(FAR struct tcb_s *tcb, FAR struct inode *inode,
int file_allocate(FAR struct inode *inode, int oflags, off_t pos, int file_allocate(FAR struct inode *inode, int oflags, off_t pos,
FAR void *priv, int minfd, bool addref); FAR void *priv, int minfd, bool addref);
/****************************************************************************
* Name: file_dump_backtrace
*
* Description:
* Dump the backtrace of the file open to given buffer.
*
* Returned Value:
* Returns the backtrace string, it could be empty.
*
****************************************************************************/
FAR char *file_dump_backtrace(FAR struct file *filep, FAR char *buffer,
size_t len);
/**************************************************************************** /****************************************************************************
* Name: file_dup * Name: file_dup
* *