top: ensure collapsed children cpu reported accurately

Parent tasks with collapsed children should have their
cpu reflect any unseen tasks only under the following:

1) When built without TREE_VCPUOFF having been defined

2) Exclusively when 'Show_FOREST' display mode was set

3) And only under the current window when in alternate
display mode (except if TREE_VWINALL has been defined)

So, this commit just ensures these objectives are met.

Reference(s):
. issue that began odyssey
https://gitlab.com/procps-ng/procps/issues/99
. original cpu implementation
commit 7c7903e50d

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2018-07-18 00:00:00 -05:00 committed by Craig Small
parent beea4e0f20
commit 11b87c73ed

View File

@ -5590,8 +5590,10 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
{ float u = (float)rSv(EU_CPU, s_int);
int n = rSv(EU_THD, s_int);
#ifndef TREE_VCPUOFF
// this eu_TREE_ADD is always zero, unless we're a collapsed parent
u += rSv(eu_TREE_ADD, u_int);
#ifndef TREE_VWINALL
if (q == Curwin) // note: the following is NOT indented
#endif
if (CHKw(q, Show_FOREST)) u += rSv(eu_TREE_ADD, u_int);
u *= Frame_etscale;
if (rSv(eu_TREE_HID, s_ch) != 'x' && u > 100.0 * n) u = 100.0 * n;
#else