Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逆着光、寻觅
rt-thread
提交
45c7f030
R
rt-thread
项目概览
逆着光、寻觅
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
45c7f030
编写于
6月 13, 2016
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[finsh] Fix object name issue in list_* cmd.
上级
4d93c31c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
113 addition
and
87 deletion
+113
-87
components/finsh/cmd.c
components/finsh/cmd.c
+113
-87
未找到文件。
components/finsh/cmd.c
浏览文件 @
45c7f030
...
...
@@ -82,52 +82,47 @@ MSH_CMD_EXPORT(version, show RT-Thread version information);
extern
struct
rt_object_information
rt_object_container
[];
static
long
_list_thread
(
struct
rt_list_node
*
list
)
static
int
object_name_maxlen
(
struct
rt_list_node
*
list
)
{
struct
rt_thread
*
thread
;
struct
rt_list_node
*
node
;
rt_uint8_t
*
ptr
,
cur_max_name_len
=
0
,
cur_thread_name_len
;
char
thread_header
[
RT_NAME_MAX
],
thread_split
[
RT_NAME_MAX
];
const
char
*
thread_str
=
"thread"
;
rt_size_t
i
,
thread_str_len
=
rt_strlen
(
thread_str
),
thread_str_index
;
struct
rt_object
*
object
=
NULL
;
int
max_length
=
0
,
length
;
/* calculate the maximum thread name length */
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
thread
=
rt_list_entry
(
node
,
struct
rt_thread
,
list
);
cur_thread_name_len
=
rt_strlen
(
thread
->
name
);
if
(
cur_max_name_len
<
cur_thread_name_len
)
{
cur_max_name_len
=
cur_thread_name_len
;
}
}
rt_enter_critical
();
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
object
=
rt_list_entry
(
node
,
struct
rt_object
,
list
);
if
(
cur_max_name_len
<
thread_str_len
)
{
cur_max_name_len
=
thread_str_len
;
length
=
rt_strlen
(
object
->
name
);
if
(
length
>
max_length
)
max_length
=
length
;
}
/* calculate the "thread" string in header index */
thread_str_index
=
(
cur_max_name_len
-
thread_str_len
)
/
2
;
rt_exit_critical
();
for
(
i
=
0
;
i
<
cur_max_name_len
;
i
++
)
{
thread_split
[
i
]
=
'-'
;
if
(
thread_str_len
<
cur_max_name_len
)
{
if
(
i
<
thread_str_index
)
{
thread_header
[
i
]
=
' '
;
thread_header
[
cur_max_name_len
-
i
-
1
]
=
' '
;
}
else
if
(
i
<
thread_str_index
+
thread_str_len
)
{
thread_header
[
i
]
=
thread_str
[
i
-
thread_str_index
];
}
else
{
thread_header
[
i
]
=
' '
;
}
}
}
thread_header
[
cur_max_name_len
]
=
'\0'
;
thread_split
[
cur_max_name_len
]
=
'\0'
;
if
(
max_length
>
RT_NAME_MAX
||
max_length
==
0
)
max_length
=
RT_NAME_MAX
;
return
max_length
;
}
rt_inline
void
object_split
(
int
len
)
{
while
(
len
--
)
rt_kprintf
(
"-"
);
}
static
long
_list_thread
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
rt_uint8_t
*
ptr
;
struct
rt_thread
*
thread
;
struct
rt_list_node
*
node
;
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%
s pri status sp stack size max used left tick error
\n
"
,
thread_header
);
rt_kprintf
(
"%s -- ------- ---------- ---------- --- ---------- ---
\n
"
,
thread_split
);
rt_kprintf
(
"%
-*.s pri status sp stack size max used left tick error
\n
"
,
maxlen
,
"thread"
);
object_split
(
maxlen
);
rt_kprintf
(
" -- ------- ---------- ---------- ------ ---------- ---
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
thread
=
rt_list_entry
(
node
,
struct
rt_thread
,
list
);
rt_kprintf
(
"%-*.*s %02d "
,
cur_max_name_len
,
cur_max_name_len
,
thread
->
name
,
thread
->
current_priority
);
rt_kprintf
(
"%-*.*s %02d "
,
maxlen
,
RT_NAME_MAX
,
thread
->
name
,
thread
->
current_priority
);
if
(
thread
->
stat
==
RT_THREAD_READY
)
rt_kprintf
(
" ready "
);
else
if
(
thread
->
stat
==
RT_THREAD_SUSPEND
)
rt_kprintf
(
" suspend"
);
...
...
@@ -174,18 +169,22 @@ static void show_wait_queue(struct rt_list_node *list)
#ifdef RT_USING_SEMAPHORE
static
long
_list_sem
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_semaphore
*
sem
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"semaphore v suspend thread
\n
"
);
rt_kprintf
(
"-------- --- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
if
(
maxlen
<
9
)
maxlen
=
9
;
rt_kprintf
(
"%-*.s v suspend thread
\n
"
,
maxlen
,
"semaphore"
);
object_split
(
maxlen
);
rt_kprintf
(
" --- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
sem
=
(
struct
rt_semaphore
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
if
(
!
rt_list_isempty
(
&
sem
->
parent
.
suspend_thread
))
{
rt_kprintf
(
"%-
8.*s
%03d %d:"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*.*s
%03d %d:"
,
maxlen
,
RT_NAME_MAX
,
sem
->
parent
.
parent
.
name
,
sem
->
value
,
rt_list_len
(
&
sem
->
parent
.
suspend_thread
));
...
...
@@ -194,8 +193,8 @@ static long _list_sem(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
8.*s
%03d %d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*.*s
%03d %d
\n
"
,
maxlen
,
RT_NAME_MAX
,
sem
->
parent
.
parent
.
name
,
sem
->
value
,
rt_list_len
(
&
sem
->
parent
.
suspend_thread
));
...
...
@@ -216,18 +215,21 @@ MSH_CMD_EXPORT(list_sem, list semaphore in system);
#ifdef RT_USING_EVENT
static
long
_list_event
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_event
*
e
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"event set suspend thread
\n
"
);
rt_kprintf
(
"-------- ---------- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s set suspend thread
\n
"
,
maxlen
,
"event"
);
object_split
(
maxlen
);
rt_kprintf
(
" ---------- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
e
=
(
struct
rt_event
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
if
(
!
rt_list_isempty
(
&
e
->
parent
.
suspend_thread
))
{
rt_kprintf
(
"%-
8
.*s 0x%08x %03d:"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s 0x%08x %03d:"
,
maxlen
,
RT_NAME_MAX
,
e
->
parent
.
parent
.
name
,
e
->
set
,
rt_list_len
(
&
e
->
parent
.
suspend_thread
));
...
...
@@ -236,8 +238,8 @@ static long _list_event(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
8
.*s 0x%08x 0
\n
"
,
RT_NAME_MAX
,
e
->
parent
.
parent
.
name
,
e
->
set
);
rt_kprintf
(
"%-
*
.*s 0x%08x 0
\n
"
,
maxlen
,
RT_NAME_MAX
,
e
->
parent
.
parent
.
name
,
e
->
set
);
}
}
...
...
@@ -255,16 +257,18 @@ MSH_CMD_EXPORT(list_event, list event in system);
#ifdef RT_USING_MUTEX
static
long
_list_mutex
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_mutex
*
m
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"mutex owner hold suspend thread
\n
"
);
rt_kprintf
(
"-------- -------- ---- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s owner hold suspend thread
\n
"
,
maxlen
,
"mutex"
);
object_split
(
maxlen
);
rt_kprintf
(
" -------- ---- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
m
=
(
struct
rt_mutex
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
rt_kprintf
(
"%-
8
.*s %-8.*s %04d %d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %-8.*s %04d %d
\n
"
,
maxlen
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
RT_NAME_MAX
,
m
->
owner
->
name
,
...
...
@@ -286,18 +290,21 @@ MSH_CMD_EXPORT(list_mutex, list mutex in system);
#ifdef RT_USING_MAILBOX
static
long
_list_mailbox
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_mailbox
*
m
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"mailbox entry size suspend thread
\n
"
);
rt_kprintf
(
"-------- ---- ---- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s entry size suspend thread
\n
"
,
maxlen
,
"mailbox"
);
object_split
(
maxlen
);
rt_kprintf
(
" ---- ---- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
m
=
(
struct
rt_mailbox
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
if
(
!
rt_list_isempty
(
&
m
->
parent
.
suspend_thread
))
{
rt_kprintf
(
"%-
8
.*s %04d %04d %d:"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %04d %04d %d:"
,
maxlen
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
m
->
size
,
...
...
@@ -307,8 +314,8 @@ static long _list_mailbox(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
8
.*s %04d %04d %d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %04d %04d %d
\n
"
,
maxlen
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
m
->
size
,
...
...
@@ -330,18 +337,21 @@ MSH_CMD_EXPORT(list_mailbox, list mail box in system);
#ifdef RT_USING_MESSAGEQUEUE
static
long
_list_msgqueue
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_messagequeue
*
m
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"msgqueue entry suspend thread
\n
"
);
rt_kprintf
(
"-------- ---- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s entry suspend thread
\n
"
,
maxlen
,
"msgqueue"
);
object_split
(
maxlen
);
rt_kprintf
(
" ---- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
m
=
(
struct
rt_messagequeue
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
if
(
!
rt_list_isempty
(
&
m
->
parent
.
suspend_thread
))
{
rt_kprintf
(
"%-
8
.*s %04d %d:"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %04d %d:"
,
maxlen
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
rt_list_len
(
&
m
->
parent
.
suspend_thread
));
...
...
@@ -350,8 +360,8 @@ static long _list_msgqueue(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
8
.*s %04d %d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %04d %d
\n
"
,
maxlen
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
rt_list_len
(
&
m
->
parent
.
suspend_thread
));
...
...
@@ -372,17 +382,20 @@ MSH_CMD_EXPORT(list_msgqueue, list message queue in system);
#ifdef RT_USING_MEMHEAP
static
long
_list_memheap
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_memheap
*
mh
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"memheap pool size max used size available size
\n
"
);
rt_kprintf
(
"-------- ---------- ------------- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s pool size max used size available size
\n
"
,
maxlen
,
"memheap"
);
object_split
(
maxlen
);
rt_kprintf
(
" ---------- ------------- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
mh
=
(
struct
rt_memheap
*
)
rt_list_entry
(
node
,
struct
rt_object
,
list
);
rt_kprintf
(
"%-
8
.*s %-010d %-013d %-05d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %-010d %-013d %-05d
\n
"
,
maxlen
,
RT_NAME_MAX
,
mh
->
parent
.
name
,
mh
->
pool_size
,
mh
->
max_used_size
,
...
...
@@ -403,18 +416,21 @@ MSH_CMD_EXPORT(list_memheap, list memory heap in system);
#ifdef RT_USING_MEMPOOL
static
long
_list_mempool
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_mempool
*
mp
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"mempool block total free suspend thread
\n
"
);
rt_kprintf
(
"-------- ---- ---- ---- --------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s block total free suspend thread
\n
"
,
maxlen
,
"mempool"
);
object_split
(
maxlen
);
rt_kprintf
(
" ---- ---- ---- --------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
mp
=
(
struct
rt_mempool
*
)
rt_list_entry
(
node
,
struct
rt_object
,
list
);
if
(
mp
->
suspend_thread_count
>
0
)
{
rt_kprintf
(
"%-
8
.*s %04d %04d %04d %d:"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %04d %04d %04d %d:"
,
maxlen
,
RT_NAME_MAX
,
mp
->
parent
.
name
,
mp
->
block_size
,
mp
->
block_total_count
,
...
...
@@ -425,8 +441,8 @@ static long _list_mempool(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
8
.*s %04d %04d %04d %d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %04d %04d %04d %d
\n
"
,
maxlen
,
RT_NAME_MAX
,
mp
->
parent
.
name
,
mp
->
block_size
,
mp
->
block_total_count
,
...
...
@@ -448,16 +464,19 @@ MSH_CMD_EXPORT(list_mempool, list memory pool in system);
static
long
_list_timer
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_timer
*
timer
;
struct
rt_list_node
*
node
;
rt_kprintf
(
"timer periodic timeout flag
\n
"
);
rt_kprintf
(
"-------- ---------- ---------- -----------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s periodic timeout flag
\n
"
,
maxlen
,
"timer"
);
object_split
(
maxlen
);
rt_kprintf
(
" ---------- ---------- -----------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
timer
=
(
struct
rt_timer
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
rt_kprintf
(
"%-
8
.*s 0x%08x 0x%08x "
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s 0x%08x 0x%08x "
,
maxlen
,
RT_NAME_MAX
,
timer
->
parent
.
name
,
timer
->
init_tick
,
timer
->
timeout_tick
);
...
...
@@ -482,6 +501,7 @@ MSH_CMD_EXPORT(list_timer, list timer in system);
#ifdef RT_USING_DEVICE
static
long
_list_device
(
struct
rt_list_node
*
list
)
{
int
maxlen
;
struct
rt_device
*
device
;
struct
rt_list_node
*
node
;
char
*
const
device_type_str
[]
=
...
...
@@ -508,13 +528,15 @@ static long _list_device(struct rt_list_node *list)
"Unknown"
};
rt_kprintf
(
"device type ref count
\n
"
);
rt_kprintf
(
"-------- -------------------- ----------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s type ref count
\n
"
,
maxlen
,
"device"
);
object_split
(
maxlen
);
rt_kprintf
(
" -------------------- ----------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
device
=
(
struct
rt_device
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
rt_kprintf
(
"%-
8
.*s %-20s %-8d
\n
"
,
RT_NAME_MAX
,
rt_kprintf
(
"%-
*
.*s %-20s %-8d
\n
"
,
maxlen
,
RT_NAME_MAX
,
device
->
parent
.
name
,
(
device
->
type
<=
RT_Device_Class_Unknown
)
?
device_type_str
[
device
->
type
]
:
...
...
@@ -538,18 +560,22 @@ MSH_CMD_EXPORT(list_device, list device in system);
int
list_module
(
void
)
{
int
maxlen
;
struct
rt_module
*
module
;
struct
rt_list_node
*
list
,
*
node
;
list
=
&
rt_object_container
[
RT_Object_Class_Module
].
object_list
;
rt_kprintf
(
"module name ref address
\n
"
);
rt_kprintf
(
"------------ -------- ------------
\n
"
);
maxlen
=
object_name_maxlen
(
list
);
rt_kprintf
(
"%-*.s ref address
\n
"
,
maxlen
,
"module"
);
object_split
(
maxlen
);
rt_kprintf
(
" -------- ------------
\n
"
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
module
=
(
struct
rt_module
*
)(
rt_list_entry
(
node
,
struct
rt_object
,
list
));
rt_kprintf
(
"%-16.*s %-04d 0x%08x
\n
"
,
RT_NAME_MAX
,
module
->
parent
.
name
,
module
->
nref
,
module
->
module_space
);
rt_kprintf
(
"%-*.*s %-04d 0x%08x
\n
"
,
maxlen
,
RT_NAME_MAX
,
module
->
parent
.
name
,
module
->
nref
,
module
->
module_space
);
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录