From cb4bc1a2f49306879ecee08f0644300f0037d92c Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 9 Mar 2007 15:27:47 +0000 Subject: Debug instrumentation git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@47 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/c5471/src/up_exit.c | 60 ++++++++++++++++++++++++++++++++++++++ nuttx/arch/c5471/src/up_internal.h | 1 + 2 files changed, 61 insertions(+) (limited to 'nuttx/arch') diff --git a/nuttx/arch/c5471/src/up_exit.c b/nuttx/arch/c5471/src/up_exit.c index 8e211e0c2..606ea097b 100644 --- a/nuttx/arch/c5471/src/up_exit.c +++ b/nuttx/arch/c5471/src/up_exit.c @@ -45,6 +45,10 @@ #include "os_internal.h" #include "up_internal.h" +#ifdef CONFIG_DUMP_ON_EXIT +#include +#endif + /************************************************************ * Private Definitions ************************************************************/ @@ -57,6 +61,57 @@ * Private Funtions ************************************************************/ +/************************************************************ + * 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. + * + ************************************************************/ + +#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) +static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg) +{ + int i; + dbg(" TCB=%p name=%s\n", tcb, tcb->name); + if (tcb->filelist) + { + dbg(" filelist refcount=%d\n", + tcb->filelist->fl_crefs); + + for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) + { + struct inode *inode = tcb->filelist->fl_files[i].f_inode; + if (inode) + { + dbg(" fd=%d refcount=%d\n", + i, inode->i_crefs); + } + } + } + + if (tcb->streams) + { + dbg(" streamlist refcount=%d\n", + tcb->streams->sl_crefs); + + for (i = 0; i < CONFIG_NFILE_STREAMS; i++) + { + struct file_struct *filep = &tcb->streams->sl_streams[i]; + if (filep->fs_filedes >= 0) + { + dbg(" fd=%d nbytes=%d\n", + filep->fs_filedes, + filep->fs_bufpos - filep->fs_bufstart); + } + } + } +} +#endif + /************************************************************ * Public Funtions ************************************************************/ @@ -76,6 +131,11 @@ void _exit(int status) dbg("TCB=%p exitting\n", tcb); +#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) + dbg("Other tasks:\n"); + sched_foreach(_up_dumponexit, NULL); +#endif + /* Remove the tcb task from the ready-to-run list. We can * ignore the return value because we know that a context * switch is needed. diff --git a/nuttx/arch/c5471/src/up_internal.h b/nuttx/arch/c5471/src/up_internal.h index ef08d36a7..6f6f82c83 100644 --- a/nuttx/arch/c5471/src/up_internal.h +++ b/nuttx/arch/c5471/src/up_internal.h @@ -53,6 +53,7 @@ #undef CONFIG_SUPPRESS_TIMER_INTS /* No timer */ #define CONFIG_SUPPRESS_SERIAL_INTS 1 /* Console will poll */ #undef CONFIG_SUPPRESS_UART_CONFIG /* Do not reconfig UART */ +#undef CONFIG_DUMP_ON_EXIT /* Dumpt task state on exit */ /* LED definitions */ -- cgit v1.2.3