Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
4d93c31c
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
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,发现更多精彩内容 >>
提交
4d93c31c
编写于
6月 13, 2016
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "[finsh] Beautify all list object information command."
This reverts commit
cd3b0cff
.
上级
2296b2b8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
82 addition
and
147 deletion
+82
-147
components/finsh/cmd.c
components/finsh/cmd.c
+82
-147
未找到文件。
components/finsh/cmd.c
浏览文件 @
4d93c31c
...
...
@@ -43,7 +43,7 @@
* 2012-04-29 goprife improve the command line auto-complete feature.
* 2012-06-02 lgnq add list_memheap
* 2012-10-22 Bernard add MS VC++ patch.
* 2016-06-02 armink beautify
all list object information
command
* 2016-06-02 armink beautify
the list_thread
command
*/
#include <rtthread.h>
...
...
@@ -82,73 +82,52 @@ MSH_CMD_EXPORT(version, show RT-Thread version information);
extern
struct
rt_object_information
rt_object_container
[];
/**
* Preprocessing the object name show information
*
* @param list object list
* @param type object type e.g., thread, semaphore
* @param header object name header information
* @param split_sign the split sign is using '-' between the object name header and object name table
* @param max_len the maximum object name length in list
*/
static
void
pre_obj_name_show_info
(
struct
rt_list_node
*
list
,
const
char
*
type
,
char
*
header
,
char
*
split_sign
,
rt_size_t
*
max_len
)
{
static
long
_list_thread
(
struct
rt_list_node
*
list
)
{
struct
rt_thread
*
thread
;
struct
rt_list_node
*
node
;
struct
rt_object
*
node_obj
=
NULL
;
rt_size_t
i
,
len
,
type_len
=
rt_strlen
(
type
),
type_index
;
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
;
*
max_len
=
0
;
/* calculate the maximum object name length */
/* calculate the maximum thread name length */
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
node_obj
=
rt_list_entry
(
node
,
struct
rt_object
,
list
);
len
=
rt_strlen
(
node_obj
->
name
);
if
(
*
max_len
<
len
)
{
*
max_len
=
len
;
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
;
}
}
if
(
*
max_len
<
type
_len
)
{
*
max_len
=
type
_len
;
if
(
cur_max_name_len
<
thread_str
_len
)
{
cur_max_name_len
=
thread_str
_len
;
}
/* calculate the
object type
string in header index */
t
ype_index
=
(
*
max_len
-
type
_len
)
/
2
;
/* calculate the
"thread"
string in header index */
t
hread_str_index
=
(
cur_max_name_len
-
thread_str
_len
)
/
2
;
for
(
i
=
0
;
i
<
*
max
_len
;
i
++
)
{
split_sign
[
i
]
=
'-'
;
if
(
t
ype_len
<=
*
max
_len
)
{
if
(
i
<
t
ype
_index
)
{
header
[
i
]
=
' '
;
header
[
*
max
_len
-
i
-
1
]
=
' '
;
}
else
if
(
i
<
t
ype_index
+
type
_len
)
{
header
[
i
]
=
type
[
i
-
type
_index
];
for
(
i
=
0
;
i
<
cur_max_name
_len
;
i
++
)
{
thread_split
[
i
]
=
'-'
;
if
(
t
hread_str_len
<
cur_max_name
_len
)
{
if
(
i
<
t
hread_str
_index
)
{
thread_
header
[
i
]
=
' '
;
thread_header
[
cur_max_name
_len
-
i
-
1
]
=
' '
;
}
else
if
(
i
<
t
hread_str_index
+
thread_str
_len
)
{
thread_header
[
i
]
=
thread_str
[
i
-
thread_str
_index
];
}
else
{
header
[
i
]
=
' '
;
thread_
header
[
i
]
=
' '
;
}
}
}
header
[
*
max_len
]
=
'\0'
;
split_sign
[
*
max_len
]
=
'\0'
;
}
thread_header
[
cur_max_name_len
]
=
'\0'
;
thread_split
[
cur_max_name_len
]
=
'\0'
;
static
long
_list_thread
(
struct
rt_list_node
*
list
)
{
struct
rt_thread
*
thread
;
struct
rt_list_node
*
node
;
rt_uint8_t
*
ptr
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"thread"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"%s pri status sp stack size max used left tick error
\n
"
,
name_header
);
rt_kprintf
(
"%s -- ------- ---------- ---------- --- ---------- ---
\n
"
,
name_split_sign
);
rt_kprintf
(
"%s pri status sp stack size max used left tick error
\n
"
,
thread_header
);
rt_kprintf
(
"%s -- ------- ---------- ---------- --- ---------- ---
\n
"
,
thread_split
);
for
(
node
=
list
->
next
;
node
!=
list
;
node
=
node
->
next
)
{
thread
=
rt_list_entry
(
node
,
struct
rt_thread
,
list
);
rt_kprintf
(
"%-*.s %02d "
,
max_name_len
,
thread
->
name
,
thread
->
current_priority
);
rt_kprintf
(
"%-*.*s %02d "
,
cur_max_name_len
,
cur_max_name_len
,
thread
->
name
,
thread
->
current_priority
);
if
(
thread
->
stat
==
RT_THREAD_READY
)
rt_kprintf
(
" ready "
);
else
if
(
thread
->
stat
==
RT_THREAD_SUSPEND
)
rt_kprintf
(
" suspend"
);
...
...
@@ -197,20 +176,16 @@ static long _list_sem(struct rt_list_node *list)
{
struct
rt_semaphore
*
sem
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"semaphore"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s v suspend thread
\n
"
,
name_header
);
rt_kprintf
(
"
%s --- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
semaphore v suspend thread
\n
"
);
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
(
"%-
*.s
%03d %d:"
,
max_name_len
,
rt_kprintf
(
"%-
8.*s
%03d %d:"
,
RT_NAME_MAX
,
sem
->
parent
.
parent
.
name
,
sem
->
value
,
rt_list_len
(
&
sem
->
parent
.
suspend_thread
));
...
...
@@ -219,8 +194,8 @@ static long _list_sem(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
*.s
%03d %d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*s
%03d %d
\n
"
,
RT_NAME_MAX
,
sem
->
parent
.
parent
.
name
,
sem
->
value
,
rt_list_len
(
&
sem
->
parent
.
suspend_thread
));
...
...
@@ -243,20 +218,16 @@ static long _list_event(struct rt_list_node *list)
{
struct
rt_event
*
e
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"event"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s set suspend thread
\n
"
,
name_header
);
rt_kprintf
(
"
%s ---------- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
event set suspend thread
\n
"
);
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
(
"%-
*.s
0x%08x %03d:"
,
max_name_len
,
rt_kprintf
(
"%-
8.*s
0x%08x %03d:"
,
RT_NAME_MAX
,
e
->
parent
.
parent
.
name
,
e
->
set
,
rt_list_len
(
&
e
->
parent
.
suspend_thread
));
...
...
@@ -265,10 +236,8 @@ static long _list_event(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-*.s 0x%08x 0
\n
"
,
max_name_len
,
e
->
parent
.
parent
.
name
,
e
->
set
);
rt_kprintf
(
"%-8.*s 0x%08x 0
\n
"
,
RT_NAME_MAX
,
e
->
parent
.
parent
.
name
,
e
->
set
);
}
}
...
...
@@ -288,18 +257,14 @@ static long _list_mutex(struct rt_list_node *list)
{
struct
rt_mutex
*
m
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"mutex"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s owner hold suspend thread
\n
"
,
name_header
);
rt_kprintf
(
"
%s -------- ---- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
mutex owner hold suspend thread
\n
"
);
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
(
"%-
*.
s %-8.*s %04d %d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %-8.*s %04d %d
\n
"
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
RT_NAME_MAX
,
m
->
owner
->
name
,
...
...
@@ -323,20 +288,16 @@ static long _list_mailbox(struct rt_list_node *list)
{
struct
rt_mailbox
*
m
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"mailbox"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s entry size suspend thread
\n
"
,
name_header
);
rt_kprintf
(
"
%s ---- ---- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
mailbox entry size suspend thread
\n
"
);
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
(
"%-
*.
s %04d %04d %d:"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %04d %04d %d:"
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
m
->
size
,
...
...
@@ -346,8 +307,8 @@ static long _list_mailbox(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
*.
s %04d %04d %d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %04d %04d %d
\n
"
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
m
->
size
,
...
...
@@ -371,20 +332,16 @@ static long _list_msgqueue(struct rt_list_node *list)
{
struct
rt_messagequeue
*
m
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"msgqueue"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s entry suspend thread
\n
"
,
name_header
);
rt_kprintf
(
"
%s ---- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
msgqueue entry suspend thread
\n
"
);
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
(
"%-
*.
s %04d %d:"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %04d %d:"
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
rt_list_len
(
&
m
->
parent
.
suspend_thread
));
...
...
@@ -393,8 +350,8 @@ static long _list_msgqueue(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
*.
s %04d %d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %04d %d
\n
"
,
RT_NAME_MAX
,
m
->
parent
.
parent
.
name
,
m
->
entry
,
rt_list_len
(
&
m
->
parent
.
suspend_thread
));
...
...
@@ -417,18 +374,15 @@ static long _list_memheap(struct rt_list_node *list)
{
struct
rt_memheap
*
mh
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
mart_size_t
max_name_len
=
0
*
preprocessing
the
object
name
show
information
*/
pre_obj_name_show_info
(
list
,
"memheap"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s pool size max used size available size
\n
"
,
name_header
);
rt_kprintf
(
"
%s ---------- ------------- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
memheap pool size max used size available size
\n
"
);
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
(
"%-
*.
s %-010d %-013d %-05d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %-010d %-013d %-05d
\n
"
,
RT_NAME_MAX
,
mh
->
parent
.
name
,
mh
->
pool_size
,
mh
->
max_used_size
,
...
...
@@ -451,20 +405,16 @@ static long _list_mempool(struct rt_list_node *list)
{
struct
rt_mempool
*
mp
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"mempool"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s block total free suspend thread
\n
"
,
name_header
);
rt_kprintf
(
"
%s ---- ---- ---- --------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
mempool block total free suspend thread
\n
"
);
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
(
"%-
*.
s %04d %04d %04d %d:"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %04d %04d %04d %d:"
,
RT_NAME_MAX
,
mp
->
parent
.
name
,
mp
->
block_size
,
mp
->
block_total_count
,
...
...
@@ -475,8 +425,8 @@ static long _list_mempool(struct rt_list_node *list)
}
else
{
rt_kprintf
(
"%-
*.
s %04d %04d %04d %d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %04d %04d %04d %d
\n
"
,
RT_NAME_MAX
,
mp
->
parent
.
name
,
mp
->
block_size
,
mp
->
block_total_count
,
...
...
@@ -500,18 +450,14 @@ static long _list_timer(struct rt_list_node *list)
{
struct
rt_timer
*
timer
;
struct
rt_list_node
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"timer"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s periodic timeout flag
\n
"
,
name_header
);
rt_kprintf
(
"
%s ---------- ---------- -----------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
timer periodic timeout flag
\n
"
);
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
(
"%-
*.
s 0x%08x 0x%08x "
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s 0x%08x 0x%08x "
,
RT_NAME_MAX
,
timer
->
parent
.
name
,
timer
->
init_tick
,
timer
->
timeout_tick
);
...
...
@@ -561,18 +507,14 @@ static long _list_device(struct rt_list_node *list)
"Miscellaneous Device"
,
"Unknown"
};
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"device"
,
name_header
,
name_split_sign
,
&
max_name_len
);
rt_kprintf
(
"
%s type ref count
\n
"
,
name_header
);
rt_kprintf
(
"
%s -------------------- ----------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
device type ref count
\n
"
);
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
(
"%-
*.
s %-20s %-8d
\n
"
,
max_name_len
,
rt_kprintf
(
"%-
8.*
s %-20s %-8d
\n
"
,
RT_NAME_MAX
,
device
->
parent
.
name
,
(
device
->
type
<=
RT_Device_Class_Unknown
)
?
device_type_str
[
device
->
type
]
:
...
...
@@ -598,23 +540,16 @@ int list_module(void)
{
struct
rt_module
*
module
;
struct
rt_list_node
*
list
,
*
node
;
char
name_header
[
RT_NAME_MAX
],
name_split_sign
[
RT_NAME_MAX
];
rt_size_t
max_name_len
=
0
;
/* preprocessing the object name show information */
pre_obj_name_show_info
(
list
,
"module"
,
name_header
,
name_split_sign
,
&
max_name_len
);
list
=
&
rt_object_container
[
RT_Object_Class_Module
].
object_list
;
rt_kprintf
(
"
%s ref address
\n
"
,
name_header
);
rt_kprintf
(
"
%s -------- ------------
\n
"
,
name_split_sign
);
rt_kprintf
(
"
module name ref address
\n
"
);
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
(
"%-*.s %-04d 0x%08x
\n
"
,
max_name_len
,
module
->
parent
.
name
,
module
->
nref
,
module
->
module_space
);
rt_kprintf
(
"%-16.*s %-04d 0x%08x
\n
"
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录