Skip to content

Commit

Permalink
arch/dumponexit: unify dump on exit to common code
Browse files Browse the repository at this point in the history
remove arch implement and move to common code

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Nov 15, 2023
1 parent 6dabcd5 commit 80709b7
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 896 deletions.
59 changes: 2 additions & 57 deletions arch/arm/src/common/arm_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,13 @@

#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
# include <nuttx/fs/fs.h>
#endif

#include "task/task.h"
#include "sched/sched.h"
#include "group/group.h"
#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
****************************************************************************/
Expand Down Expand Up @@ -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.
*/
Expand Down
57 changes: 1 addition & 56 deletions arch/arm64/src/common/arm64_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
# include <nuttx/fs/fs.h>
#endif

#include "task/task.h"
#include "sched/sched.h"
Expand All @@ -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
****************************************************************************/
Expand All @@ -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
Expand Down
59 changes: 2 additions & 57 deletions arch/avr/src/common/avr_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,64 +30,12 @@
#include <nuttx/addrenv.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
# include <nuttx/fs/fs.h>
#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
****************************************************************************/
Expand Down Expand Up @@ -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.
*/
Expand Down
59 changes: 2 additions & 57 deletions arch/hc/src/common/hc_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,12 @@

#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
# include <nuttx/fs/fs.h>
#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
****************************************************************************/
Expand Down Expand Up @@ -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.
*/
Expand Down
Loading

0 comments on commit 80709b7

Please sign in to comment.