Commit Graph

315 Commits

Author SHA1 Message Date
Mateusz Piotrowski
fab44dc358 top(1): Rework DESCRIPTION OF MEMORY section.
Due to markup issues, the DESCRIPTION OF MEMORY section is rather
unreadable; rework it a bit, using subsections for different lines of the
top output, and move it closer to description.

While here, pet manlint ordering other sections as expected.

Submitted by:	Yuri Pankov <yuripv@yuripv.net>
Reviewed by:	eadler
Approved by:	re (gjb), krion (mentor)
Differential Revision:	https://reviews.freebsd.org/D17369
2018-10-02 08:13:54 +00:00
Mark Johnston
fedded8d04 Fix column alignment in per-thread mode.
PR:		230872
Approved by:	re (marius)
MFC after:	1 week
2018-08-25 15:59:51 +00:00
Eitan Adler
17be5f230a top(1): Use warnx and errx instead of fprintf
This also makes make "-v" exit without error, since it isn't.
2018-08-22 10:07:15 +00:00
Eitan Adler
eeb147d528 top(1): issue warning on invalid delay
When top -sH is run it continually updates. It should issue an warning
instead.

Reported by:	jmg
PR:		230803
2018-08-22 09:49:38 +00:00
Matt Macy
ef8e2d2d01 fix top after arc accounting change 2018-08-11 22:11:12 +00:00
Eitan Adler
550ddd16ed top(1): hide THR column in separate-thread mode.
It does not make sense to show a "thread count" column when displaying
threads separately. In fact we don't, but do show the header for this
column. Fix this.
2018-08-08 06:31:46 +00:00
Daichi GOTO
08092a9b8f top(1): fix a buffer overflow copying states to display while they were incremented
- fix an AddressSanitizer error

Submitted by:	devnexen@gmail.com
Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16183
2018-07-27 07:05:50 +00:00
Daichi GOTO
324976739f top(1): fixed the empty output problem in non-interactive mode (-n, -b) regressed in r336028
PR:		229842
Reported by:	Ali Abdallah <aliovx@gmail.com>
Reviewed by:	eadler, cy
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16455
2018-07-27 01:20:34 +00:00
Daichi GOTO
cfb27362b1 top(1): forgot in r336160
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16452
2018-07-26 13:53:22 +00:00
Eitan Adler
10550f0b0a top(1): increase number of columns for memory
The original intention was 4 columns but with a usable a result. In
practice this was not the case. Increase the number of columns to 5
until humanize_number learns alternative ways of presenting the number.

Requested by:	many
Ref D15801
2018-07-25 14:05:17 +00:00
Mark Johnston
04354d577d Fix thread state summary line display after r334918. 2018-07-10 17:20:27 +00:00
Daichi GOTO
7452122499 top(1): rollback r335836
Encoding-specific processing introduced in r335836 is not recommended.
And doing getenv("LANG") and assuming an encoding based on it is a
very bad practice to internationalize software.

Submitted by:	hrs
Differential Revision:	https://reviews.freebsd.org/D16203
2018-07-10 03:49:48 +00:00
Daichi GOTO
5c48c1ee57 top(1): Fix the prompt bug and core dump problem in o / p mode that occurred by r336028
Reviewed by:	cy
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16174
2018-07-10 00:19:52 +00:00
Sean Bruno
9d5352cb63 r336028 changed next_msg to a char * from char [] of fixed size. Change
2nd argument of vsnprintf() to get the strlen of next_msg so that the
appropriate size is used.

Found with gcc.

/usr.bin/top/display.c: In function 'new_message':
/usr.bin/top/display.c:963:31: error:
argument to 'sizeof' in 'vsnprintf' call is the same expression as the
destination; did you mean to provide an explicit length?
[-Werror=sizeof-pointer-memaccess]
     vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);

Reviewed by:	daichi
2018-07-06 13:22:44 +00:00
Daichi GOTO
0a59db87e3 Changed to eliminate the upper limit of command length displayed
by "-a" and expand to match terminal width

Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16083
2018-07-06 12:07:06 +00:00
Konstantin Belousov
f87a5f036b top: do not fall to the thread name if kernel cache of the process
args is empty.

Instead, use kvm_getargv() unconditionally to obtain the process
arguments.  It means that one additional sysctl(2) is performed there.

Submitted by:	Thomas Munro
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D16111
2018-07-04 13:28:16 +00:00
Ruslan Bukin
c6dc704e84 Fix build: utf8strvisx() does signed data comparisons, but 'char' type
is unsigned in riscv GCC, so use guaranted signed char type.

Sponsored by:	DARPA, AFRL
2018-07-03 14:32:15 +00:00
Cy Schubert
4ee90e6e20 When toggling the display using the "m" command to toggle from 'cpu'
mode to 'io' mode, an artifact remains because the buffer is not
"finished" with a NULL terminator using sbuf_finish().

An example of this is, when the "m" command is entered, the title line
will contain COMMANDND instead of COMMAND. This commit fixes this.
2018-07-03 02:54:32 +00:00
Eitan Adler
39d2eb75fc top(1): permit infinite length for command
There isn't any need to limit the size of the screen. Utilities like
'less -S' don't have a (meaningful) limit anyways.  This also makes the
way to dynamically changing the column widths based on the screen width.
2018-07-01 19:44:29 +00:00
Daichi GOTO
4417ed2dbf top(1) - support UTF-8 display
Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16006
2018-07-01 05:32:03 +00:00
Daichi GOTO
612e0030b6 top(1): increased the maximum length of command shown by "-a"
Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16006
2018-06-27 02:55:30 +00:00
Eitan Adler
8d3f65e767 top(1): increase field with width for W/CPU column
This allows 3 digit CPU columns to look nice

Reported by:	feld
2018-06-24 13:14:04 +00:00
Eitan Adler
db36566345 top(1): Restructure printing of process states
This avoids the need to have separate buffers and calls to sprintf for
various calls.
2018-06-23 22:45:22 +00:00
Eitan Adler
0515b88e77 top(1): Convert process listing to sbuf too
This also fixes -mio with 'T' set (thread-id instead of process-id).

This can go further by removing the existing sprintf, and using sbuf
directly. This will be done in a followup commit.
2018-06-23 22:45:20 +00:00
Eitan Adler
ac8f40ea78 top(1): Use basename instead of a homegrown alternative 2018-06-23 22:45:18 +00:00
Eitan Adler
becfb1625c top(1): show CPU state breakdown on first run
There is no documented reason for this not to be shown on the first run.
I can't find any good reason, and it breaks batch mode.

PR:		218889
Submitted by:	"Jeremy C. Reed" <reed@reedmedia.net>
2018-06-23 03:17:11 +00:00
Eitan Adler
00abcb6acd top(1): increase warnings
top(1) now builds without cast-qual warnings, so remove the exemption
for that.

Tested with clang, gcc7, gcc9
2018-06-22 10:20:21 +00:00
Eitan Adler
8caf462ef6 top(1): garbage collect
- remove a now-unused function
- remove needless indirection of handle type
2018-06-22 10:17:12 +00:00
Eitan Adler
d9cf8a13ca top(1): increase size of 'C' column
On machines with more than 99 CPUs make room to display the entire
number.

Requested by:	cperciva
2018-06-22 10:17:10 +00:00
Eitan Adler
5c66dcc072 top(1): remove special handling of load > 5
When the load is "high" (an arbitrary value) top(1) previously moved the
cursor to the top-left of the screen as an acknowledgment. In practice,
on modern machines, even relatively slow ones, it looked more like a
glitch. Remove the logic.
2018-06-22 09:45:18 +00:00
Eitan Adler
51c834c490 top(1): reimplement header formatting as sbuf
The current header formatting is a giant format string that changes
global state during the format process.

Make the following changes:
- use sbuf to build up the header rather than use the above
pseudo-dynamic one
- Change name length to 10
- Reduce size of RES and SIZE by making humanize more aggressive
- Restore a version number line to the copyright. This may be required
by the copyright (and may not be; its unclear)

This is also a pre-req to implementing TOPCOLOR from newer versions of
top(1)

Discussed with:	allanjude, rpolka, danfe, rgrimes
Differential Revision: https://reviews.freebsd.org/D15801
2018-06-22 09:21:01 +00:00
Eitan Adler
57ad79afd6 top(1): behave as documented for -t
Show top itself by default, unless -t is specified.
2018-06-22 00:02:36 +00:00
Eitan Adler
3edda95c9d top(1): fix top -mio 2018-06-19 23:30:55 +00:00
Alan Somers
aa9d9bfa90 top(1): Fix Coverity warning
Don't call strerror on negative errnos

Reported by:	Coverity
CID:		976708
Reviewed by:	eadler
Differential Revision:	https://reviews.freebsd.org/D15909
2018-06-19 18:32:06 +00:00
Eitan Adler
cc11473037 top(1): correct assertion 2018-06-19 05:01:07 +00:00
Eitan Adler
e59ba74961 top(1): correct header in UP mode
Fix an oversight from r334869 which made the same change, but only for
SMP systems. This avoids a segfault while D15801 is being reviewed.

Reviewed by:	kevans
2018-06-19 04:18:23 +00:00
Eitan Adler
6bb0d5cf77 top(1): use more modern signal code
Rather than manually build signal masks use functions designed for that
reason. Also use sigprocmask instead of sigblock.
2018-06-18 02:06:16 +00:00
Eitan Adler
ef8dcce3c2 top(1): remove myself from top.1
I wrote some, but not enough for the man page.
2018-06-14 12:14:51 +00:00
Allan Jude
21e289d49b Fix top(1) support for displaying ZFS Compressed ARC statistics
Broken in r334514

sysctlbyname("vfs.zfs.compressed_arc_enabled", ...) would return ENOMEM
while trying to read the sysctl (a boolean_t) into a bool, which is too small.

Reviewed by:	jhb (on irc)
Sponsored by:	Klara Systems
2018-06-14 00:10:16 +00:00
Eitan Adler
f764243341 top(1): remove unneeded logic
- remove __pure annotations I added earlier for some functions. One
writes to the the arguments as "out" pointers. The
other reads from an array, which while const within the function might
be mutated externally.
- total_change is modified to be at 1, if previously 0, so no if check
is needed.
2018-06-13 11:12:52 +00:00
Eitan Adler
1de6384221 top(1): style(9)
- split return type from function name
- Sprinkle a __pure where possible.
2018-06-13 08:52:22 +00:00
Eitan Adler
d18626664a top(1): add myself to authors
At this point I've mucked enough with top(1) that all bugs should be
blamed on me rather than William LeFebvre.
2018-06-13 08:52:19 +00:00
Eitan Adler
c655e639c2 top(1): shift from atoi to non-deprecated function 2018-06-13 08:52:14 +00:00
Eitan Adler
704daa9b87 top(1): replace homegrown itoa with sprintf
Much of this should be inlined to the callsite, but leave it here for
now to make it easier to make it easier bisect later.
2018-06-13 08:52:12 +00:00
Eitan Adler
8e4b205ea5 top(1): format_time, format_k, etc.
- Use humanize_number for format_k and format_k2
- Fix some style nits in format_time
2018-06-13 08:52:09 +00:00
Eitan Adler
e7cb1c0776 top(1): format help more nicely
For entries that are duplicates present them nicely rather than showing
two identical help entries. For ' ' present it as SPC
2018-06-13 08:52:06 +00:00
Eitan Adler
59c50d8277 top(1): several small bugfixes and nits
- initialize all maybe uninitialized vars with bogus values. This shuts
up the compiler, and causes crashes if it changes later.
- mark noreturn as noreturn
- removed unused macro
- handle x_procstate as runtime rather than pre-processor
- avoid using void functions in condtionals

Tested with clang, gcc 7, gcc 9
2018-06-13 00:45:38 +00:00
Eitan Adler
0ff79d817c top(1): remove trailing whitespace 2018-06-12 07:31:59 +00:00
Eitan Adler
ccf22059e0 top(1): style and related
- style(9)
- remove now-defunct comments
- remove getuid check for low delay
- expand range of format_k
2018-06-12 07:14:12 +00:00
Eitan Adler
c8aa5e526f top(1): move command mapping to commands.c
This eliminates the difficult to follow mapping of a string list. It
moves numbers from "#define" into (more) debuggable enums. More
generally, it follows the trend of moving more data into a more central
mechanism.

The help output is a little worse: " " is not rendered well, and there
are duplicate entries, but that will be fixed in a followup.
2018-06-12 06:53:31 +00:00