116 lines
5.7 KiB
Diff
116 lines
5.7 KiB
Diff
diff --git a/top/top.c b/top/top.c
|
||
index 39c8545..ce63508 100644
|
||
--- a/top/top.c
|
||
+++ b/top/top.c
|
||
@@ -3524,8 +3524,9 @@ static void configs_read (void) {
|
||
case 'g': // from 3.3.4 thru 3.3.8
|
||
scat(w->rc.fieldscur, RCF_PLUS_H);
|
||
case 'h': // this is release 3.3.9
|
||
- /* w->rc.graph_cpus = 0; */// for documentation only, since
|
||
- /* w->rc.graph_mems = 0; */// DEF_RCFILE zeroes them for us
|
||
+ w->rc.graph_cpus = w->rc.graph_mems = 0;
|
||
+ // these next 2 are really global, but best documented here
|
||
+ Rc.summ_mscale = Rc.task_mscale = SK_Kb;
|
||
case 'i': // actual RCF_VERSION_ID
|
||
default: // and a future version?
|
||
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
|
||
@@ -4894,27 +4895,36 @@ static void keys_xtra (int ch) {
|
||
* ( plus, maintain alphabetical order with carefully chosen )
|
||
* ( function names: forest_a, forest_b, forest_c & forest_d )
|
||
* ( each with exactly one letter more than its predecessor! ) */
|
||
-static proc_t **Seed_ppt; // temporary window ppt ptr
|
||
-static proc_t **Tree_ppt; // resized by forest_create
|
||
-static int Tree_idx; // frame_make initializes
|
||
+static proc_t **Seed_ppt; // temporary win ppt pointer
|
||
+static proc_t **Tree_ppt; // forest_create will resize
|
||
+static int Tree_idx; // frame_make resets to zero
|
||
|
||
/*
|
||
* This little recursive guy is the real forest view workhorse.
|
||
* He fills in the Tree_ppt array and also sets the child indent
|
||
* level which is stored in an unused proc_t padding byte. */
|
||
-static void forest_adds (const int self, const int level) {
|
||
+static void forest_adds (const int self, int level) {
|
||
int i;
|
||
|
||
- Tree_ppt[Tree_idx] = Seed_ppt[self]; // add this as root or child
|
||
- Tree_ppt[Tree_idx++]->pad_3 = level; // borrow 1 byte, 127 levels
|
||
- for (i = self + 1; i < Frame_maxtask; i++) {
|
||
- if (Seed_ppt[self]->tid == Seed_ppt[i]->tgid
|
||
- || (Seed_ppt[self]->tid == Seed_ppt[i]->ppid && Seed_ppt[i]->tid == Seed_ppt[i]->tgid))
|
||
- forest_adds(i, level + 1); // got one child any others?
|
||
+ if (Tree_idx < Frame_maxtask) { // immunize against insanity
|
||
+ if (level > 100) level = 101; // our arbitrary nests limit
|
||
+ Tree_ppt[Tree_idx] = Seed_ppt[self]; // add this as root or child
|
||
+ Tree_ppt[Tree_idx++]->pad_3 = level; // borrow 1 byte, 127 levels
|
||
+#ifdef TREE_SCANALL
|
||
+ for (i = 0; i < Frame_maxtask; i++) {
|
||
+ if (i == self) continue;
|
||
+#else
|
||
+ for (i = self + 1; i < Frame_maxtask; i++) {
|
||
+#endif
|
||
+ if (Seed_ppt[self]->tid == Seed_ppt[i]->tgid
|
||
+ || (Seed_ppt[self]->tid == Seed_ppt[i]->ppid && Seed_ppt[i]->tid == Seed_ppt[i]->tgid))
|
||
+ forest_adds(i, level + 1); // got one child any others?
|
||
+ }
|
||
}
|
||
} // end: forest_adds
|
||
|
||
|
||
+#ifndef TREE_SCANALL
|
||
/*
|
||
* Our qsort callback to order a ppt by the non-display start_time
|
||
* which will make us immune from any pid, ppid or tgid anomalies
|
||
@@ -4924,6 +4934,7 @@ static int forest_based (const proc_t **x, const proc_t **y) {
|
||
if ( (*x)->start_time < (*y)->start_time ) return -1;
|
||
return 0;
|
||
} // end: forest_based
|
||
+#endif
|
||
|
||
|
||
/*
|
||
@@ -4941,7 +4952,9 @@ static void forest_create (WIN_t *q) {
|
||
hwmsav = Frame_maxtask;
|
||
Tree_ppt = alloc_r(Tree_ppt, sizeof(proc_t*) * hwmsav);
|
||
}
|
||
+#ifndef TREE_SCANALL
|
||
qsort(Seed_ppt, Frame_maxtask, sizeof(proc_t*), (QFP_t)forest_based);
|
||
+#endif
|
||
for (i = 0; i < Frame_maxtask; i++) // avoid any hidepid distortions
|
||
if (!Seed_ppt[i]->pad_3) // identify real or pretend trees
|
||
forest_adds(i, 1); // add as parent plus its children
|
||
@@ -4962,7 +4975,8 @@ static inline const char *forest_display (const WIN_t *q, const proc_t *p) {
|
||
const char *which = (CHKw(q, Show_CMDLIN)) ? *p->cmdline : p->cmd;
|
||
|
||
if (!CHKw(q, Show_FOREST) || 1 == p->pad_3) return which;
|
||
- snprintf(buf, sizeof(buf), "%*s%s", 4 * (p->pad_3 - 1), " `- ", which);
|
||
+ if (p->pad_3 > 100) snprintf(buf, sizeof(buf), "%400s%s", " + ", which);
|
||
+ else snprintf(buf, sizeof(buf), "%*s%s", 4 * (p->pad_3 - 1), " `- ", which);
|
||
return buf;
|
||
} // end: forest_display
|
||
|
||
diff --git a/top/top.h b/top/top.h
|
||
index 8f61d82..1b1b1a1 100644
|
||
--- a/top/top.h
|
||
+++ b/top/top.h
|
||
@@ -59,6 +59,7 @@
|
||
//#define STRINGCASENO /* case insenstive compare/locate versions */
|
||
//#define TERMIOS_ONLY /* just limp along with native input only */
|
||
//#define TREE_NORESET /* sort keys do NOT force forest view OFF */
|
||
+//#define TREE_SCANALL /* rescan array w/ forest view, avoid sort */
|
||
//#define USE_X_COLHDR /* emphasize header vs. whole col, for 'x' */
|
||
//#define VALIDATE_NLS /* validate the integrity of all nls tbls */
|
||
|
||
@@ -780,8 +781,10 @@ typedef struct WIN_t {
|
||
//atic void keys_window (int ch);
|
||
//atic void keys_xtra (int ch);
|
||
/*------ Forest View support -------------------------------------------*/
|
||
-//atic void forest_adds (const int self, const int level);
|
||
+//atic void forest_adds (const int self, int level);
|
||
+#ifndef TREE_SCANALL
|
||
//atic int forest_based (const proc_t **x, const proc_t **y);
|
||
+#endif
|
||
//atic void forest_create (WIN_t *q);
|
||
//atic inline const char *forest_display (const WIN_t *q, const proc_t *p);
|
||
/*------ Main Screen routines ------------------------------------------*/
|