diff --git a/arch/Kconfig b/arch/Kconfig index 79821e4fa10..c297605e084 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1041,7 +1041,6 @@ config ARCH_STACKDUMP_MAX_LENGTH config DUMP_ON_EXIT bool "Dump all tasks state on exit" default n - depends on DEBUG_SCHED_INFO ---help--- Dump all tasks state on exit() diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index 338982a7035..6d97b91d1e4 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -27,14 +27,17 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -308,6 +311,67 @@ void files_initlist(FAR struct filelist *list) list->fl_prefile = list->fl_prefiles; } +/**************************************************************************** + * Name: files_dumplist + * + * Description: + * Dump the list of files. + * + ****************************************************************************/ + +void files_dumplist(FAR struct filelist *list) +{ + int count = files_countlist(list); + int i; + + syslog(LOG_INFO, "%-4s%-4s%-8s%-5s%-10s%-14s" +#if CONFIG_FS_BACKTRACE > 0 + " BACKTRACE" +#endif + "\n", + "PID", "FD", "FLAGS", "TYPE", "POS", "PATH" + ); + + for (i = 0; i < count; i++) + { + FAR struct file *filep = files_fget(list, i); + char path[PATH_MAX]; + +#if CONFIG_FS_BACKTRACE > 0 + char buf[BACKTRACE_BUFFER_SIZE(CONFIG_FS_BACKTRACE)]; +#endif + + /* Is there an inode associated with the file descriptor? */ + + if (filep == NULL || filep->f_inode == NULL) + { + continue; + } + + if (file_ioctl(filep, FIOC_FILEPATH, path) < 0) + { + path[0] = '\0'; + } + +#if CONFIG_FS_BACKTRACE > 0 + backtrace_format(buf, sizeof(buf), filep->f_backtrace, + CONFIG_FS_BACKTRACE); +#endif + + syslog(LOG_INFO, "%-4d%-4d%-8d%-5x%-10ld%-14s" +#if CONFIG_FS_BACKTRACE > 0 + " %s" +#endif + "\n", getpid(), i, filep->f_oflags, + INODE_GET_TYPE(filep->f_inode), + (long)filep->f_pos, path +#if CONFIG_FS_BACKTRACE > 0 + , buf +#endif + ); + } +} + /**************************************************************************** * Name: files_releaselist * diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 83cc0802f2f..9a541c4d999 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -864,6 +864,16 @@ int nx_umount2(FAR const char *target, unsigned int flags); void files_initlist(FAR struct filelist *list); +/**************************************************************************** + * Name: files_dumplist + * + * Description: + * Dump the list of files. + * + ****************************************************************************/ + +void files_dumplist(FAR struct filelist *list); + /**************************************************************************** * Name: files_releaselist * diff --git a/sched/sched/sched_dumponexit.c b/sched/sched/sched_dumponexit.c index f1a07bd946a..7b7fc8d23ad 100644 --- a/sched/sched/sched_dumponexit.c +++ b/sched/sched/sched_dumponexit.c @@ -52,26 +52,14 @@ static void dumphandler(FAR struct tcb_s *tcb, FAR void *arg) { FAR struct filelist *filelist; - int i; - int j; - sinfo(" TCB=%p name=%s\n", tcb, tcb->name); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); + syslog(LOG_INFO, "tcb=%p name=%s, pid:%d, priority=%d state=%d " + "stack_alloc_ptr: %p, adj_stack_size: %zu\n", + tcb, tcb->name, tcb->pid, tcb->sched_priority, tcb->task_state, + tcb->stack_alloc_ptr, tcb->adj_stack_size); filelist = &tcb->group->tg_filelist; - for (i = 0; i < filelist->fl_rows; i++) - { - for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) - { - struct inode *inode = filelist->fl_files[i][j].f_inode; - if (inode) - { - sinfo(" fd=%d refcount=%d\n", - i * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK + j, - inode->i_crefs); - } - } - } + files_dumplist(filelist); } /****************************************************************************