fs: tweak backtrace for file open
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
63a1b8d5a9
commit
b0698daaa4
@ -494,17 +494,7 @@ FAR char *file_dump_backtrace(FAR struct file *filep, FAR char *buffer,
|
||||
size_t len)
|
||||
{
|
||||
#if CONFIG_FS_BACKTRACE > 0
|
||||
FAR const char *format = "%0*p ";
|
||||
int k;
|
||||
|
||||
buffer[0] = '\0';
|
||||
for (k = 0; k < CONFIG_FS_BACKTRACE && filep->f_backtrace[k]; k++)
|
||||
{
|
||||
snprintf(buffer + k * FS_BACKTRACE_WIDTH,
|
||||
len - k * FS_BACKTRACE_WIDTH,
|
||||
format, FS_BACKTRACE_WIDTH - 1,
|
||||
filep->f_backtrace[k]);
|
||||
}
|
||||
backtrace_format(buffer, len, filep->f_backtrace, CONFIG_FS_BACKTRACE);
|
||||
#else
|
||||
buffer[0] = '\0';
|
||||
#endif
|
||||
|
@ -70,12 +70,13 @@
|
||||
# define FS_ADD_BACKTRACE(filep) \
|
||||
do \
|
||||
{ \
|
||||
int n = sched_backtrace(_SCHED_GETTID(), filep->f_backtrace, \
|
||||
int n = sched_backtrace(_SCHED_GETTID(), \
|
||||
(filep)->f_backtrace, \
|
||||
CONFIG_FS_BACKTRACE, \
|
||||
CONFIG_FS_BACKTRACE_SKIP); \
|
||||
if (n < CONFIG_FS_BACKTRACE) \
|
||||
{ \
|
||||
(filep->f_backtrace)[n] = NULL; \
|
||||
(filep)->f_backtrace[n] = NULL; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
@ -1245,6 +1245,9 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||
size_t buflen, off_t offset)
|
||||
{
|
||||
FAR struct task_group_s *group = tcb->group;
|
||||
FAR struct file *filep;
|
||||
char backtrace[BACKTRACE_BUFFER_SIZE(CONFIG_FS_BACKTRACE)];
|
||||
char path[PATH_MAX];
|
||||
size_t remaining;
|
||||
size_t linesize;
|
||||
size_t copysize;
|
||||
@ -1252,10 +1255,6 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||
int count;
|
||||
int i;
|
||||
|
||||
FAR struct file *filep;
|
||||
char path[PATH_MAX];
|
||||
char backtrace[FS_BACKTRACE_BUFFER_LEN];
|
||||
|
||||
DEBUGASSERT(group != NULL);
|
||||
|
||||
count = files_countlist(&group->tg_filelist);
|
||||
|
@ -350,6 +350,11 @@ int file_open(FAR struct file *filep, FAR const char *path, int oflags, ...)
|
||||
ret = file_vopen(filep, path, oflags, 0, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (ret >= OK)
|
||||
{
|
||||
FS_ADD_BACKTRACE(filep);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user