From 64cf63475c1f90793ccd4f69a3fe70a1568d512a Mon Sep 17 00:00:00 2001 From: chao an Date: Wed, 15 Nov 2023 16:22:17 +0800 Subject: [PATCH] arch/dumponexit: unify dump on exit to common code remove arch implement and move to common code Signed-off-by: chao an --- arch/arm/src/common/arm_exit.c | 59 +------------- arch/arm64/src/common/arm64_exit.c | 57 +------------- arch/avr/src/common/avr_exit.c | 59 +------------- arch/hc/src/common/hc_exit.c | 59 +------------- arch/mips/src/common/mips_exit.c | 59 +------------- arch/misoc/src/lm32/lm32_exit.c | 51 +------------ arch/misoc/src/minerva/minerva_exit.c | 51 +------------ arch/or1k/src/common/or1k_exit.c | 59 +------------- arch/renesas/src/common/renesas_exit.c | 59 +------------- arch/risc-v/src/common/riscv_exit.c | 59 +------------- arch/sparc/src/common/sparc_exit.c | 54 +------------ arch/x86/src/common/x86_exit.c | 59 +------------- arch/x86_64/src/common/x86_64_exit.c | 59 +------------- arch/x86_64/src/common/x86_64_internal.h | 5 -- arch/xtensa/src/common/xtensa_exit.c | 59 +------------- arch/z16/src/common/z16_exit.c | 59 +------------- arch/z80/src/common/z80_exit.c | 60 +-------------- include/nuttx/sched.h | 16 ++++ sched/misc/CMakeLists.txt | 4 + sched/misc/Make.defs | 4 + sched/misc/dump.c | 97 ++++++++++++++++++++++++ 21 files changed, 152 insertions(+), 896 deletions(-) create mode 100644 sched/misc/dump.c diff --git a/arch/arm/src/common/arm_exit.c b/arch/arm/src/common/arm_exit.c index 70e5169284..2a68b93ddb 100644 --- a/arch/arm/src/common/arm_exit.c +++ b/arch/arm/src/common/arm_exit.c @@ -30,9 +30,6 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" @@ -40,55 +37,6 @@ #include "irq/irq.h" #include "arm_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -116,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/arm64/src/common/arm64_exit.c b/arch/arm64/src/common/arm64_exit.c index a25b8946c5..7b3c8d6fd0 100644 --- a/arch/arm64/src/common/arm64_exit.c +++ b/arch/arm64/src/common/arm64_exit.c @@ -29,9 +29,6 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" @@ -43,55 +40,6 @@ #include "arm64_fpu.h" #endif -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -118,10 +66,7 @@ void up_exit(int status) enter_critical_section(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif + nxsched_dumponexit(); /* Destroy the task at the head of the ready to run list. */ #ifdef CONFIG_ARCH_FPU diff --git a/arch/avr/src/common/avr_exit.c b/arch/avr/src/common/avr_exit.c index 0cb22222b2..5dd28dc7ba 100644 --- a/arch/avr/src/common/avr_exit.c +++ b/arch/avr/src/common/avr_exit.c @@ -30,64 +30,12 @@ #include #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "avr_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) -{ - FAR struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -115,15 +63,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/hc/src/common/hc_exit.c b/arch/hc/src/common/hc_exit.c index 85129e54df..447f417cde 100644 --- a/arch/hc/src/common/hc_exit.c +++ b/arch/hc/src/common/hc_exit.c @@ -29,64 +29,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "hc_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) -{ - FAR struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -114,15 +62,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/mips/src/common/mips_exit.c b/arch/mips/src/common/mips_exit.c index c516cf137a..ff95efca41 100644 --- a/arch/mips/src/common/mips_exit.c +++ b/arch/mips/src/common/mips_exit.c @@ -31,64 +31,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "mips_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -116,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/misoc/src/lm32/lm32_exit.c b/arch/misoc/src/lm32/lm32_exit.c index 08ff71cfb5..535186f416 100644 --- a/arch/misoc/src/lm32/lm32_exit.c +++ b/arch/misoc/src/lm32/lm32_exit.c @@ -29,9 +29,6 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include @@ -40,47 +37,6 @@ #include "group/group.h" #include "lm32.h" -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -108,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/misoc/src/minerva/minerva_exit.c b/arch/misoc/src/minerva/minerva_exit.c index 90fd7c61c4..36f771839d 100644 --- a/arch/misoc/src/minerva/minerva_exit.c +++ b/arch/misoc/src/minerva/minerva_exit.c @@ -29,9 +29,6 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include @@ -40,47 +37,6 @@ #include "group/group.h" #include "minerva.h" -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -108,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the head * of the list. */ diff --git a/arch/or1k/src/common/or1k_exit.c b/arch/or1k/src/common/or1k_exit.c index fbb6527575..a5360b6570 100644 --- a/arch/or1k/src/common/or1k_exit.c +++ b/arch/or1k/src/common/or1k_exit.c @@ -30,9 +30,6 @@ #include #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" @@ -40,55 +37,6 @@ #include "irq/irq.h" #include "or1k_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -116,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/renesas/src/common/renesas_exit.c b/arch/renesas/src/common/renesas_exit.c index 277b6cfd3b..35e16d1d98 100644 --- a/arch/renesas/src/common/renesas_exit.c +++ b/arch/renesas/src/common/renesas_exit.c @@ -29,64 +29,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "renesas_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - 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); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -114,15 +62,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/risc-v/src/common/riscv_exit.c b/arch/risc-v/src/common/riscv_exit.c index 143ffb438a..8260754a75 100644 --- a/arch/risc-v/src/common/riscv_exit.c +++ b/arch/risc-v/src/common/riscv_exit.c @@ -31,64 +31,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "riscv_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -116,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/sparc/src/common/sparc_exit.c b/arch/sparc/src/common/sparc_exit.c index 2d47971813..17dc6842e0 100644 --- a/arch/sparc/src/common/sparc_exit.c +++ b/arch/sparc/src/common/sparc_exit.c @@ -31,59 +31,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "sparc_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->argv[0], tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - filelist = &tcb->group->tg_filelist; - for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) - { - struct inode *inode = filelist->fl_files[i].f_inode; - if (inode) - { - sinfo(" fd=%d refcount=%d\n", - i, inode->i_crefs); - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -111,6 +64,8 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Update scheduler parameters */ nxsched_suspend_scheduler(tcb); @@ -119,11 +74,6 @@ void up_exit(int status) (void)nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - sched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/x86/src/common/x86_exit.c b/arch/x86/src/common/x86_exit.c index 64cd34d494..8b0c2a4231 100644 --- a/arch/x86/src/common/x86_exit.c +++ b/arch/x86/src/common/x86_exit.c @@ -30,64 +30,12 @@ #include #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "x86_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -115,15 +63,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/x86_64/src/common/x86_64_exit.c b/arch/x86_64/src/common/x86_64_exit.c index 613d6e15c6..916e30fd4b 100644 --- a/arch/x86_64/src/common/x86_64_exit.c +++ b/arch/x86_64/src/common/x86_64_exit.c @@ -29,64 +29,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "x86_64_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -114,15 +62,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", this_task()); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/x86_64/src/common/x86_64_internal.h b/arch/x86_64/src/common/x86_64_internal.h index 871c951933..da5a5a451e 100644 --- a/arch/x86_64/src/common/x86_64_internal.h +++ b/arch/x86_64/src/common/x86_64_internal.h @@ -47,11 +47,6 @@ #undef CONFIG_SUPPRESS_TIMER_INTS /* DEFINED: No timer */ #undef CONFIG_SUPPRESS_SERIAL_INTS /* DEFINED: Console will poll */ #undef CONFIG_SUPPRESS_UART_CONFIG /* DEFINED: Do not reconfig UART */ -#undef CONFIG_DUMP_ON_EXIT /* DEFINED: Dump task state on exit */ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT /* Needs CONFIG_DEBUG_SCHED_INFO */ -#endif /* Determine which (if any) console driver to use. If a console is enabled * and no other console device is specified, then a serial console is diff --git a/arch/xtensa/src/common/xtensa_exit.c b/arch/xtensa/src/common/xtensa_exit.c index 9a0111a279..83ddcc8d64 100644 --- a/arch/xtensa/src/common/xtensa_exit.c +++ b/arch/xtensa/src/common/xtensa_exit.c @@ -31,64 +31,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "xtensa.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _xtensa_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _xtensa_dumponexit(struct tcb_s *tcb, void *arg) -{ - struct filelist *filelist; - int i; - int j; - - sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); - sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -116,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_xtensa_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/z16/src/common/z16_exit.c b/arch/z16/src/common/z16_exit.c index c7fc4d38b5..af5fbc7f1e 100644 --- a/arch/z16/src/common/z16_exit.c +++ b/arch/z16/src/common/z16_exit.c @@ -29,64 +29,12 @@ #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif #include "chip.h" #include "task/task.h" #include "sched/sched.h" #include "z16_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _z16_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _z16_dumponexit(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); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -114,15 +62,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_z16_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/z80/src/common/z80_exit.c b/arch/z80/src/common/z80_exit.c index ffe5f77e75..a6afa43261 100644 --- a/arch/z80/src/common/z80_exit.c +++ b/arch/z80/src/common/z80_exit.c @@ -31,65 +31,12 @@ #include #include #include -#ifdef CONFIG_DUMP_ON_EXIT -# include -#endif - #include "chip.h" #include "task/task.h" #include "sched/sched.h" #include "group/group.h" #include "z80_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_DEBUG_SCHED_INFO -# undef CONFIG_DUMP_ON_EXIT -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(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); - - 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); - } - } - } -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -117,15 +64,12 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + nxsched_dumponexit(); + /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_up_dumponexit, NULL); -#endif - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 1f05ee161a..6e44489b6d 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -1573,6 +1573,22 @@ pid_t nxsched_getppid(void); size_t nxsched_collect_deadlock(FAR pid_t *pid, size_t count); +/**************************************************************************** + * Name: nxsched_dumponexit + * + * Description: + * Dump the state of all tasks whenever on task exits. This is debug + * instrumentation that was added to check file-related reference counting + * but could be useful again sometime in the future. + * + ****************************************************************************/ + +#ifdef CONFIG_DUMP_ON_EXIT +void nxsched_dumponexit(void); +#else +# define nxsched_dumponexit() +#endif /* CONFIG_DUMP_ON_EXIT */ + #ifdef CONFIG_SMP_CALL /**************************************************************************** * Name: nxsched_smp_call_handler diff --git a/sched/misc/CMakeLists.txt b/sched/misc/CMakeLists.txt index 66f7927905..a92492870c 100644 --- a/sched/misc/CMakeLists.txt +++ b/sched/misc/CMakeLists.txt @@ -24,4 +24,8 @@ if(CONFIG_ARCH_DEADLOCKDUMP) list(APPEND SRCS deadlock.c) endif() +if(CONFIG_DUMP_ON_EXIT) + list(APPEND SRCS dump.c) +endif() + target_sources(sched PRIVATE ${SRCS}) diff --git a/sched/misc/Make.defs b/sched/misc/Make.defs index 91f156655a..35291122f7 100644 --- a/sched/misc/Make.defs +++ b/sched/misc/Make.defs @@ -24,6 +24,10 @@ ifeq ($(CONFIG_ARCH_DEADLOCKDUMP),y) CSRCS += deadlock.c endif +ifeq ($(CONFIG_DUMP_ON_EXIT),y) +CSRCS += dump.c +endif + # Include init build support DEPPATH += --dep-path misc diff --git a/sched/misc/dump.c b/sched/misc/dump.c new file mode 100644 index 0000000000..d8aebbd9f0 --- /dev/null +++ b/sched/misc/dump.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * sched/misc/dump.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_DUMP_ON_EXIT + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: dumphandler + * + * Description: + * Dump the state of all tasks whenever on task exits. This is debug + * instrumentation that was added to check file-related reference counting + * but could be useful again sometime in the future. + * + ****************************************************************************/ + +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); + + 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); + } + } + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxsched_dumponexit + * + * Description: + * Dump the state of all tasks whenever on task exits. This is debug + * instrumentation that was added to check file-related reference counting + * but could be useful again sometime in the future. + * + ****************************************************************************/ + +void nxsched_dumponexit(void) +{ + sinfo("Other tasks:\n"); + nxsched_foreach(dumphandler, NULL); +} + +#endif /* CONFIG_DUMP_ON_EXIT */