Browse Source

display suspend thread when list message queue information.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@445 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong 15 years ago
parent
commit
cd793d257b
1 changed files with 33 additions and 25 deletions
  1. 33 25
      finsh/cmd.c

+ 33 - 25
finsh/cmd.c

@@ -27,25 +27,25 @@
  */
  */
 
 
 #include <rtthread.h>
 #include <rtthread.h>
-#include "finsh.h"
-
-// Copy from kservice.h because we can not use it out of the kernel.
-// Ugly. Should let kservice.h avaliable for applications?
+#include "finsh.h"
+
+// Copy from kservice.h because we can not use it out of the kernel.
+// Ugly. Should let kservice.h avaliable for applications?
 rt_inline int rt_list_isempty(const rt_list_t *l)
 rt_inline int rt_list_isempty(const rt_list_t *l)
 {
 {
 	return l->next == l;
 	return l->next == l;
-}
-
-rt_inline unsigned int rt_list_len(const rt_list_t *l)
-{
-	unsigned int len = 0;
-	const rt_list_t *p = l;
-	while( p->next != l )
-	{
-		p = p->next;
-		len++;
-	}
-	return len;
+}
+
+rt_inline unsigned int rt_list_len(const rt_list_t *l)
+{
+	unsigned int len = 0;
+	const rt_list_t *p = l;
+	while( p->next != l )
+	{
+		p = p->next;
+		len++;
+	}
+	return len;
 }
 }
 
 
 long hello()
 long hello()
@@ -54,7 +54,7 @@ long hello()
 
 
 	return 0;
 	return 0;
 }
 }
-FINSH_FUNCTION_EXPORT(hello, say hello world)
+FINSH_FUNCTION_EXPORT(hello, say hello world);
 
 
 extern void rt_show_version(void);
 extern void rt_show_version(void);
 long version()
 long version()
@@ -63,7 +63,7 @@ long version()
 
 
 	return 0;
 	return 0;
 }
 }
-FINSH_FUNCTION_EXPORT(version, show RT-Thread version information)
+FINSH_FUNCTION_EXPORT(version, show RT-Thread version information);
 
 
 #define rt_list_entry(node, type, member) \
 #define rt_list_entry(node, type, member) \
     ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))
     ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))
@@ -101,7 +101,7 @@ int list_thread()
 	}
 	}
 	return 0;
 	return 0;
 }
 }
-FINSH_FUNCTION_EXPORT(list_thread, list thread)
+FINSH_FUNCTION_EXPORT(list_thread, list thread);
 
 
 static void show_wait_queue(struct rt_list_node* list)
 static void show_wait_queue(struct rt_list_node* list)
 {
 {
@@ -128,7 +128,7 @@ int list_sem()
 	rt_kprintf("--------  --- --------------\n");
 	rt_kprintf("--------  --- --------------\n");
 	for (node = list->next; node != list; node = node->next)
 	for (node = list->next; node != list; node = node->next)
 	{
 	{
-		sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list));
+		sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list));
 		if( !rt_list_isempty(&sem->parent.suspend_thread) )
 		if( !rt_list_isempty(&sem->parent.suspend_thread) )
 		{
 		{
 			rt_kprintf("%-8s  %03d %d:", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread) );
 			rt_kprintf("%-8s  %03d %d:", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread) );
@@ -200,7 +200,7 @@ int list_mailbox()
 	rt_kprintf("-------- ----  ---- --------------\n");
 	rt_kprintf("-------- ----  ---- --------------\n");
 	for (node = list->next; node != list; node = node->next)
 	for (node = list->next; node != list; node = node->next)
 	{
 	{
-		m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list));
+		m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list));
 		if( !rt_list_isempty(&m->parent.suspend_thread) )
 		if( !rt_list_isempty(&m->parent.suspend_thread) )
 		{
 		{
 			rt_kprintf("%-8s %04d  %04d %d:", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread));
 			rt_kprintf("%-8s %04d  %04d %d:", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread));
@@ -231,7 +231,16 @@ int list_msgqueue()
 	for (node = list->next; node != list; node = node->next)
 	for (node = list->next; node != list; node = node->next)
 	{
 	{
 		m = (struct rt_messagequeue*)(rt_list_entry(node, struct rt_object, list));
 		m = (struct rt_messagequeue*)(rt_list_entry(node, struct rt_object, list));
-		rt_kprintf("%-8s %04d  %d\n", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread));
+		if( !rt_list_isempty(&m->parent.suspend_thread) )
+		{
+			rt_kprintf("%-8s %04d  %d:", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread));
+			show_wait_queue(&(m->parent.suspend_thread));
+			rt_kprintf("\n");
+		}
+		else
+		{
+			rt_kprintf("%-8s %04d  %d\n", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread));
+		}
 	}
 	}
 
 
 	return 0;
 	return 0;
@@ -243,7 +252,6 @@ FINSH_FUNCTION_EXPORT(list_msgqueue, list message queue in system)
 int list_mempool()
 int list_mempool()
 {
 {
 	struct rt_mempool *mp;
 	struct rt_mempool *mp;
-
 	struct rt_list_node *list, *node;
 	struct rt_list_node *list, *node;
 
 
 	list = &rt_object_container[RT_Object_Class_MemPool].object_list;
 	list = &rt_object_container[RT_Object_Class_MemPool].object_list;
@@ -398,8 +406,8 @@ void list_prefix(char* prefix)
 	const char* name_ptr;
 	const char* name_ptr;
 
 
 	func_cnt = 0;
 	func_cnt = 0;
-	var_cnt  = 0;
-	name_ptr = RT_NULL;
+	var_cnt  = 0;
+	name_ptr = RT_NULL;
 
 
 	{
 	{
 		struct finsh_syscall* index;
 		struct finsh_syscall* index;