top(1): correct header, align it.
THR is always 6 digits or longer. Now that the PID/THR change is separated, use correct headers. PR: 228823 Reported by: Trond.Endrestol@ximalas.info
This commit is contained in:
parent
5ad42d0f47
commit
e3225dcf12
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334869
@ -94,17 +94,20 @@ static const char io_header[] =
|
|||||||
static const char io_Proc_format[] =
|
static const char io_Proc_format[] =
|
||||||
"%5d%*s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s";
|
"%5d%*s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s";
|
||||||
|
|
||||||
|
/* XXX: build up header instead of statically defining them.
|
||||||
|
* This will also allow for a "format string" to be supplied
|
||||||
|
* as an argument to top(1) instead of having predefined options */
|
||||||
static const char smp_header_thr_and_pid[] =
|
static const char smp_header_thr_and_pid[] =
|
||||||
" PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
|
" %s%*s %-*.*s THR PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
|
||||||
static const char smp_header_tid_only[] =
|
static const char smp_header_id_only[] =
|
||||||
" THR%*s %-*.*s " "PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
|
" %s%*s %-*.*s PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
|
||||||
static const char smp_Proc_format[] =
|
static const char smp_Proc_format[] =
|
||||||
"%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s %2d%7s %6.2f%% %.*s";
|
"%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s %2d%7s %6.2f%% %.*s";
|
||||||
|
|
||||||
static char up_header_thr_and_pid[] =
|
static char up_header_thr_and_pid[] =
|
||||||
" PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
|
" PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
|
||||||
static char up_header_tid_only[] =
|
static char up_header_id_only[] =
|
||||||
" THR%*s %-*.*s " "PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
|
" %s%*s %-*.*s PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
|
||||||
static char up_Proc_format[] =
|
static char up_Proc_format[] =
|
||||||
"%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s%.0d%7s %6.2f%% %.*s";
|
"%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s%.0d%7s %6.2f%% %.*s";
|
||||||
|
|
||||||
@ -425,19 +428,31 @@ format_header(const char *uname_field)
|
|||||||
switch (displaymode) {
|
switch (displaymode) {
|
||||||
case DISP_CPU:
|
case DISP_CPU:
|
||||||
/*
|
/*
|
||||||
* The logic of picking the right header format seems reverse
|
* The logic of picking the right header is confusing, and
|
||||||
* here because we only want to display a THR column when
|
* depends on too much. We should instead have a struct of
|
||||||
* "thread mode" is off (and threads are not listed as
|
* "header name", and "header format" which we build up.
|
||||||
* separate lines).
|
* This would also fix the duplicate of effort into up vs smp
|
||||||
|
* mode.
|
||||||
*/
|
*/
|
||||||
prehead = smpmode ?
|
if (smpmode) {
|
||||||
(ps.thread_id ? smp_header_tid_only : smp_header_thr_and_pid) :
|
prehead = ps.thread ?
|
||||||
(ps.thread_id ? up_header_tid_only : up_header_thr_and_pid);
|
smp_header_id_only : smp_header_thr_and_pid;
|
||||||
snprintf(Header, sizeof(Header), prehead,
|
snprintf(Header, sizeof(Header), prehead,
|
||||||
jidlength, ps.jail ? " JID" : "",
|
ps.thread_id ? " THR" : "PID",
|
||||||
namelength, namelength, uname_field,
|
jidlength, ps.jail ? " JID" : "",
|
||||||
swaplength, ps.swap ? " SWAP" : "",
|
namelength, namelength, uname_field,
|
||||||
ps.wcpu ? "WCPU" : "CPU");
|
swaplength, ps.swap ? " SWAP" : "",
|
||||||
|
ps.wcpu ? "WCPU" : "CPU");
|
||||||
|
} else {
|
||||||
|
prehead = ps.thread ?
|
||||||
|
up_header_id_only : up_header_thr_and_pid;
|
||||||
|
snprintf(Header, sizeof(Header), prehead,
|
||||||
|
ps.thread_id ? " THR" : "PID",
|
||||||
|
jidlength, ps.jail ? " JID" : "",
|
||||||
|
namelength, namelength, uname_field,
|
||||||
|
swaplength, ps.swap ? " SWAP" : "",
|
||||||
|
ps.wcpu ? "WCPU" : "CPU");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DISP_IO:
|
case DISP_IO:
|
||||||
prehead = io_header;
|
prehead = io_header;
|
||||||
|
Loading…
Reference in New Issue
Block a user