History log of /freebsd-current/usr.bin/top/display.c
Revision Date Author Comments
# b7f62c60 20-May-2024 Piotr Kubaj <pkubaj@FreeBSD.org>

usr.bin/top: fix displaying load average for loads of at least 100

After top registers load average of at least 100 which then gets reduced to
below 100, there are left stray digits.
Supporting load over 100 requires increasing the width only to 6, but since
we support over 1000 CPU's now, let's increase it to 7.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D45284


# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# fc8ae86a 20-Dec-2019 Philip Paeps <philip@FreeBSD.org>

top: display battery capacity remaining

Submitted by: Antranig Vartanian <antranigv@freebsd.am>
Reviewed by: imp, philip
Differential Revision: https://reviews.freebsd.org/D22871


# b1de37fa 20-Sep-2019 Daichi GOTO <daichi@FreeBSD.org>

top(1): support multibyte characters in command names (ARGV array)
depending on locale.

- add setlocale()
- remove printable() function
- add VIS_OCTAL and VIS_SAFE to the flag of strvisx() to display
non-printable characters that do not use C-style backslash sequences
in three digit octal sequence, or remove it

This change allows multibyte characters to be displayed according to
locale. If it is recognized as a non-display character according to the
locale, it is displayed in three digit octal sequence.

Reference:
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165751.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165766.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165833.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165846.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165891.html

Submitted by: hrs
Differential Revision: https://reviews.freebsd.org/D16204


# 2984a716 20-Jun-2019 Allan Jude <allanjude@FreeBSD.org>

top(1): Don't show the swap line when there are no swap devices

Submitted by: antranigv@freebsd.am
Reviewed by: bapt
MFC after: 1 month
Sponsored by: Klara Systems
Differential Revision: https://reviews.freebsd.org/D18928


# c26e2e37 02-Apr-2019 Dimitry Andric <dim@FreeBSD.org>

Fix regression in top(1) after r344381, causing informational messages
to no longer be displayed. This was because the reimplementation of
setup_buffer() did not copy the previous contents into any reallocated
buffer.

Reported by: James Wright <james.wright@jigsawdezign.com>
PR: 236947
MFC after: 3 days


# 281bdc30 20-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Fix more AddressSanitizer violations in usr.bin/top

In line_update(), set lastcol correctly after moving to any non-zero
column, so the "overwrite old stuff" part does not attempt to address
negative offsets in the current line.

Rewrite setup_buffer() to always allocate at least 80 characters,
otherwise various calls to summary_format() will overwrite the end of
the buffers, if the screen width gets small enough.

MFC after: 1 week


# 7362ea6d 10-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Fix the first couple of AddressSanitizer violations in usr.bin/top.

Avoid setting zero bytes beyond the length of the 'thisline' parameters
in i_process() and u_process(), and don't attempt to memset a negative
number of bytes.

MFC after: 1 week


# d0f687d3 10-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Fix multiple warnings in usr.bin/top about discarded qualifiers from
both clang and gcc, by either constifying variables, or when that is not
possible, using __DECONST.

MFC after: 1 week


# 17be5f23 22-Aug-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): Use warnx and errx instead of fprintf

This also makes make "-v" exit without error, since it isn't.


# 08092a9b 27-Jul-2018 Daichi GOTO <daichi@FreeBSD.org>

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


# 04354d57 10-Jul-2018 Mark Johnston <markj@FreeBSD.org>

Fix thread state summary line display after r334918.


# 74521224 09-Jul-2018 Daichi GOTO <daichi@FreeBSD.org>

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


# 5c48c1ee 09-Jul-2018 Daichi GOTO <daichi@FreeBSD.org>

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


# 9d5352cb 06-Jul-2018 Sean Bruno <sbruno@FreeBSD.org>

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


# 0a59db87 05-Jul-2018 Daichi GOTO <daichi@FreeBSD.org>

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


# 4417ed2d 30-Jun-2018 Daichi GOTO <daichi@FreeBSD.org>

top(1) - support UTF-8 display

Reviewed by: eadler
Approved by: gnn (mentor)
Differential Revision: https://reviews.freebsd.org/D16006


# 1de63842 13-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): style(9)

- split return type from function name
- Sprinkle a __pure where possible.


# 59c50d82 12-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

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


# 0ff79d81 12-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): remove trailing whitespace


# 4eef480b 10-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): use correct word when displaying threads

PR: 182204
Reported by: "Brodey Dover" <doverosx@gmail.com>


# 6e0632db 09-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): correctly reset per-cpu counters

I had changed this from a for loop to a memset during an earlier
cleanup. This change was incorrect so revert it.

While here, clean up

Reported by: flo


# d408c8f7 07-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): fix several style & const related issues

- use parens for return
- put function names on newline
- sprinkle const where possible


# 8d0d2676 03-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): include what you use

- Change headers to more closely match what we use
- use more standard functions instead of bzero, bcmp, bcopy
- Add myself to authors.

Tested with: base clang (amd64), gcc 9 (amd64), base clang (i386), base
gcc (mips)


# eae589f1 03-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): another pass of cleanup

- avoid the need to call a function to get size of known array. I'll
likely re-arrange some of the indirect in a later to avoid the magic
constants.
- use correct type
- add const
- replace caddr_t with void*. This corrects an alignment warning.
- remove duplicated include from immediately prior commit

Under base clang we're now down to:
- 3 warning in top.c, 1 warning in mahcine.c, 4 warning in display.c,
- 1 warning in utils.c

Tested with base clang, gcc7, gcc9, base gcc (mips)


# 9f8096e3 03-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): top warnings and cleanup

- Add const where helpful
- add missing 'static' for file-local functions
- use nitems where possible
- convert manual abort() to assert
- use strndup instead of homegrown version

Tested with clang, gcc7, and gcc9


# 4fedcd49 02-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): cleanup memory allocation and warnings

- Prefer calloc over malloc. This is more predicable and we're not in a
performance sensitive context. [1]
- Remove bogus comment (obsolete from prior commit). [2]
- Remove void casts and type casts of NULL
- Remove redundant declaration of 'quit'
- Add additional const

Reported by: kib [1], vangyzen [2]


# b274c68a 02-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

Use stpcpy instead of home grown solution


# 960a7f39 02-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): const poison part 2

Further reduce the number of warnings emitted by gcc.


# cffee2bc 01-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): help scan-build along a bit

Teach scan-build that some arrays are larger than zero, and thus not to
warn.


# 3798694c 01-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): avoid casting malloc


# 0b2f6ed1 01-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): Use standard boolean rather than homegrown alternative


# f6234b51 01-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): ansify, style(9). and nits

- Prefer using ansi prototypes rather than C prototypes
- Keep type on separate line from name of function
- Try to keep things const where possible. This will help get to WARNS=6
- switch to "bool" where it makes sense


# bc875b45 21-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): unbreak build with gcc7; fix varargs

- use correct function for varargs argument
- allow build to complete with gcc7 at current WARNS

Reported by: jhibbits, ian


# 6ffc72df 21-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): fix build

Remove 'top.local.hs'. This was not noticed since
/srv/obj/fbsd/srv/src/freebsd/svn/head/amd64.amd64/usr.bin/top/top.local.h
existed locally on my machine despite "make clean". Only fully removing
the objdir allowed me to observe the error directly.

Pointyhat to: me


# 1b7645c6 21-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): modernize a bit; reduce warnings

- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible

This leaves at WARNS=6:
35 warnings in top.c
88 warnings in machine.c
7 warnings in commands.c

all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"


# dfa5eb70 21-May-2018 Eitan Adler <eadler@FreeBSD.org>

Add missing va_end

Reported by: andrew


# 00157b4c 21-May-2018 Eitan Adler <eadler@FreeBSD.org>

Revert r333969 which contained one too many changes


# bfb79c2c 21-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): modernize a bit; reduce warnings

- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible

This leaves at WARNS=6:
35 warnings in top.c
72 warnings in machine.c
5 warnings in commands.c

all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"


# 47ffa267 20-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): further unconditionally assume we're on FreeBSD


# 1d6a4ba3 20-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): build with WARNS=3

This fixes everything but
-Wincompatible-pointer-types-discards-qualifiers


# a5ca08ed 20-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): fix several more warnings


# 666cf873 20-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): clean much of WARNS=3 issues

There is still one glaring issue: new_message is not a protoype, but
can't be trivially converted since it uses K&R style var-args.


# 98c299e0 19-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): remove use of 'register' keyword

This keyword is meaningless is obscures future diffs that help clear up
warnings in top.


# caee4883 19-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): unconditionally assume we are running on FreeBSD

This allows us to remove a special header and more specifically just the
system headers we want.


# 946e91ab 19-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): assume that we're building on FreeBSD

This allows us to avoid the ifdefs that we set unconditionally.


# 3be6ef06 19-May-2018 Eitan Adler <eadler@FreeBSD.org>

top(1): Migrate top to usr.bin

We've been maintaining top(1) for a long time, and the upstream
hasn't existed/been used in similarly as long. Make it clear that we own
top(1)

Tested with 'make universe'. Everything passed except MIPS which failed
for unrelated reasons. Install also tested for amd64.

Reviewed by: sbruno
No objections: imp, mmacy
Differential Revision: https://reviews.freebsd.org/D15387