44#define LIST_DFS_OPT_ID 0x100
45#define LIST_FIND_OBJ_NR 8
47static long clear(
void)
55static long version(
void)
103 if (!arg->nr || !arg->type)
162 list_get_next_t find_arg;
166 const char *item_title =
"thread";
167 const size_t tcb_strlen =
sizeof(
void *) * 2 + 2;
173 maxlen = RT_NAME_MAX;
176 rt_kprintf(
"%-*.*s cpu bind pri status sp stack size max used left tick error tcb addr\n", maxlen, maxlen, item_title);
178 rt_kprintf(
" --- ---- --- ------- ---------- ---------- ------ ---------- -------");
183 rt_kprintf(
"%-*.*s pri status sp stack size max used left tick error tcb addr\n", maxlen, maxlen, item_title);
185 rt_kprintf(
" --- ------- ---------- ---------- ------ ---------- -------");
193 next = list_get_next(next, &find_arg);
196 for (i = 0; i < find_arg.nr_out; i++)
210 rt_memcpy(&thread_info, obj,
sizeof thread_info);
221 rt_kprintf(
"%-*.*s %3d %3d %4d ", maxlen, RT_NAME_MAX,
226 rt_kprintf(
"%-*.*s N/A %3d %4d ", maxlen, RT_NAME_MAX,
242#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
244 while (*ptr ==
'#')ptr --;
246 rt_kprintf(
" 0x%08x 0x%08x %02d%% 0x%08x %s %p\n",
250 thread->remaining_tick,
251 rt_strerror(thread->
error),
255 while (*ptr ==
'#') ptr ++;
256 rt_kprintf(
" 0x%08x 0x%08x %02d%% 0x%08x %s %p\n",
262 rt_strerror(thread->
error),
274#ifdef RT_USING_SEMAPHORE
278 list_get_next_t find_arg;
284 const char *item_title =
"semaphore";
289 maxlen = RT_NAME_MAX;
291 rt_kprintf(
"%-*.*s v suspend thread\n", maxlen, maxlen, item_title);
297 next = list_get_next(next, &find_arg);
300 for (i = 0; i < find_arg.nr_out; i++)
346 list_get_next_t find_arg;
352 const char *item_title =
"event";
357 maxlen = RT_NAME_MAX;
359 rt_kprintf(
"%-*.*s set suspend thread\n", maxlen, maxlen, item_title);
365 next = list_get_next(next, &find_arg);
368 for (i = 0; i < find_arg.nr_out; i++)
412 list_get_next_t find_arg;
418 const char *item_title =
"mutex";
423 maxlen = RT_NAME_MAX;
425 rt_kprintf(
"%-*.*s owner hold priority suspend thread \n", maxlen, maxlen, item_title);
427 rt_kprintf(
" -------- ---- -------- --------------\n");
431 next = list_get_next(next, &find_arg);
434 for (i = 0; i < find_arg.nr_out; i++)
483#ifdef RT_USING_MAILBOX
487 list_get_next_t find_arg;
493 const char *item_title =
"mailbox";
498 maxlen = RT_NAME_MAX;
500 rt_kprintf(
"%-*.*s entry size suspend thread\n", maxlen, maxlen, item_title);
506 next = list_get_next(next, &find_arg);
509 for (i = 0; i < find_arg.nr_out; i++)
555#ifdef RT_USING_MESSAGEQUEUE
559 list_get_next_t find_arg;
565 const char *item_title =
"msgqueue";
570 maxlen = RT_NAME_MAX;
572 rt_kprintf(
"%-*.*s entry suspend thread\n", maxlen, maxlen, item_title);
577 next = list_get_next(next, &find_arg);
580 for (i = 0; i < find_arg.nr_out; i++)
623#ifdef RT_USING_MEMHEAP
624long list_memheap(
void)
627 list_get_next_t find_arg;
633 const char *item_title =
"memheap";
638 maxlen = RT_NAME_MAX;
640 rt_kprintf(
"%-*.*s pool size max used size available size\n", maxlen, maxlen, item_title);
642 rt_kprintf(
" ---------- ------------- --------------\n");
645 next = list_get_next(next, &find_arg);
648 for (i = 0; i < find_arg.nr_out; i++)
651 struct rt_memheap *mh;
663 mh = (
struct rt_memheap *)obj;
681#ifdef RT_USING_MEMPOOL
685 list_get_next_t find_arg;
691 const char *item_title =
"mempool";
696 maxlen = RT_NAME_MAX;
698 rt_kprintf(
"%-*.*s block total free suspend thread\n", maxlen, maxlen, item_title);
700 rt_kprintf(
" ---- ---- ---- --------------\n");
703 next = list_get_next(next, &find_arg);
706 for (i = 0; i < find_arg.nr_out; i++)
710 int suspend_thread_count;
725 suspend_thread_count = 0;
728 suspend_thread_count++;
731 if (suspend_thread_count > 0)
739 suspend_thread_count);
751 suspend_thread_count);
765 list_get_next_t find_arg;
771 const char *item_title =
"timer";
776 maxlen = RT_NAME_MAX;
778 rt_kprintf(
"%-*.*s periodic timeout activated mode\n", maxlen, maxlen, item_title);
780 rt_kprintf(
" ---------- ---------- ----------- ---------\n");
783 next = list_get_next(next, &find_arg);
786 for (i = 0; i < find_arg.nr_out; i++)
826#ifdef RT_USING_DEVICE
848 "Miscellaneous Device",
865 list_get_next_t find_arg;
869 const char *device_type;
872 const char *item_title =
"device";
877 maxlen = RT_NAME_MAX;
879 rt_kprintf(
"%-*.*s type ref count\n", maxlen, maxlen, item_title);
881 rt_kprintf(
" -------------------- ----------\n");
884 next = list_get_next(next, &find_arg);
887 for (i = 0; i < find_arg.nr_out; i++)
903 device_type =
"Unknown";
907 device_type = device_type_str[device->
type];
924#ifndef FINSH_USING_OPTION_COMPLETION
925static int cmd_list(
int argc,
char **argv)
929 if(strcmp(argv[1],
"thread") == 0)
933 else if(strcmp(argv[1],
"timer") == 0)
937#ifdef RT_USING_SEMAPHORE
938 else if(strcmp(argv[1],
"sem") == 0)
944 else if(strcmp(argv[1],
"event") == 0)
950 else if(strcmp(argv[1],
"mutex") == 0)
955#ifdef RT_USING_MAILBOX
956 else if(strcmp(argv[1],
"mailbox") == 0)
961#ifdef RT_USING_MESSAGEQUEUE
962 else if(strcmp(argv[1],
"msgqueue") == 0)
967#ifdef RT_USING_MEMHEAP
968 else if(strcmp(argv[1],
"memheap") == 0)
973#ifdef RT_USING_MEMPOOL
974 else if(strcmp(argv[1],
"mempool") == 0)
979#ifdef RT_USING_DEVICE
980 else if(strcmp(argv[1],
"device") == 0)
986 else if(strcmp(argv[1],
"fd") == 0)
1003 rt_kprintf(
" %-12s - list threads\n",
"thread");
1004 rt_kprintf(
" %-12s - list timers\n",
"timer");
1005#ifdef RT_USING_SEMAPHORE
1006 rt_kprintf(
" %-12s - list semaphores\n",
"sem");
1008#ifdef RT_USING_MUTEX
1009 rt_kprintf(
" %-12s - list mutexs\n",
"mutex");
1011#ifdef RT_USING_EVENT
1012 rt_kprintf(
" %-12s - list events\n",
"event");
1014#ifdef RT_USING_MAILBOX
1015 rt_kprintf(
" %-12s - list mailboxs\n",
"mailbox");
1017#ifdef RT_USING_MESSAGEQUEUE
1018 rt_kprintf(
" %-12s - list message queues\n",
"msgqueue");
1020#ifdef RT_USING_MEMHEAP
1021 rt_kprintf(
" %-12s - list memory heaps\n",
"memheap");
1023#ifdef RT_USING_MEMPOOL
1024 rt_kprintf(
" %-12s - list memory pools\n",
"mempool");
1026#ifdef RT_USING_DEVICE
1027 rt_kprintf(
" %-12s - list devices\n",
"device");
1030 rt_kprintf(
" %-12s - list file descriptors\n",
"fd");
1038static int cmd_list(
int argc,
char **argv)
1046#ifdef RT_USING_SEMAPHORE
1049#ifdef RT_USING_EVENT
1052#ifdef RT_USING_MUTEX
1055#ifdef RT_USING_MAILBOX
1058#ifdef RT_USING_MESSAGEQUEUE
1061#ifdef RT_USING_MEMHEAP
1064#ifdef RT_USING_MEMPOOL
1067#ifdef RT_USING_DEVICE
1094#ifdef RT_USING_SEMAPHORE
1097#ifdef RT_USING_EVENT
1100#ifdef RT_USING_MUTEX
1103#ifdef RT_USING_MAILBOX
1106#ifdef RT_USING_MESSAGEQUEUE
1109#ifdef RT_USING_MEMHEAP
1112#ifdef RT_USING_MEMPOOL
1115#ifdef RT_USING_DEVICE
rt_inline void object_split(int len)
#define CMD_OPTIONS_NODE(_id, _name, _des)
#define MSH_OPT_ID_GET(fun)
#define CMD_OPTIONS_NODE_END
#define MSH_OPT_DUMP(fun)
#define CMD_OPTIONS_STATEMENT(command)
#define CMD_OPTIONS_NODE_START(command)
#define RT_TIMER_FLAG_ACTIVATED
#define RT_TIMER_FLAG_PERIODIC
rt_tick_t rt_tick_get(void)
This function will return current tick from operating system startup.
@ RT_Device_Class_Unknown
int stat(const char *file, struct stat *buf)
rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock)
This function will disable the local interrupt and then lock the spinlock, will lock the thread sched...
void rt_susp_list_print(rt_list_t *list)
Print thread on suspend list to system console
void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level)
This function will unlock the spinlock and then restore current cpu interrupt status,...
struct rt_object_information * rt_object_get_information(enum rt_object_class_type type)
This function will return the specified type of object information.
@ RT_Object_Class_MemHeap
@ RT_Object_Class_MessageQueue
@ RT_Object_Class_MemPool
@ RT_Object_Class_MailBox
@ RT_Object_Class_Semaphore
#define rt_list_for_each(pos, head)
void rt_show_version(void)
This function will show the version of rt-thread rtos
rt_inline int rt_list_isempty(const rt_list_t *l)
tests whether a list is empty
#define rt_list_entry(node, type, member)
get the struct for this entry
rt_inline unsigned int rt_list_len(const rt_list_t *l)
get the list length
#define RT_THREAD_STAT_MASK
#define RT_THREAD_RUNNING
#define RT_THREAD_SUSPEND_MASK
#define MSH_CMD_EXPORT_ALIAS(...)
#define MSH_CMD_EXPORT(...)
#define RT_SCHED_CTX(thread)
#define RT_SCHED_PRIV(thread)
struct rt_list_node rt_list_t
enum rt_device_class_type type
struct rt_ipc_object parent
struct rt_list_node * next
struct rt_ipc_object parent
rt_size_t block_total_count
rt_size_t block_free_count
struct rt_ipc_object parent
struct rt_ipc_object parent
struct rt_ipc_object parent