related: adapt for changes in result types, <PIDS> api

This patch is the response to changes in <pids> types.

These additional modifications were also incorporated.

. ps -------------------------------------------------
pr_wname was eliminated as it just duplicated pr_wchan
pr_wchan referenced WCHAN_ADDR in error, vs WCHAN_NAME
pr_nwchan referenced WCHAN_NAME, not proper WCHAN_ADDR

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-07-31 00:00:00 -05:00 committed by Craig Small
parent c4aa6c0ab4
commit 51aef8f769
2 changed files with 125 additions and 142 deletions

View File

@ -452,7 +452,7 @@ setREL1(TIME_ALL)
*/ */
static int pr_vsz(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_vsz(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(VM_SIZE) setREL1(VM_SIZE)
return snprintf(outbuf, COLWID, "%ld", rSv(VM_SIZE, sl_int, pp)); return snprintf(outbuf, COLWID, "%lu", rSv(VM_SIZE, ul_int, pp));
} }
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
@ -555,8 +555,8 @@ setREL1(PRIORITY)
// policies (-1). // policies (-1).
static int pr_nice(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_nice(char *restrict const outbuf, const proc_t *restrict const pp){
setREL2(NICE,SCHED_CLASS) setREL2(NICE,SCHED_CLASS)
if(rSv(SCHED_CLASS, ul_int, pp)!=0 && rSv(SCHED_CLASS, ul_int, pp)!=3 && rSv(SCHED_CLASS, ul_int, pp)!=-1) return snprintf(outbuf, COLWID, "-"); if(rSv(SCHED_CLASS, s_int, pp)!=0 && rSv(SCHED_CLASS, s_int, pp)!=3 && rSv(SCHED_CLASS, s_int, pp)!=-1) return snprintf(outbuf, COLWID, "-");
return snprintf(outbuf, COLWID, "%ld", rSv(NICE, sl_int, pp)); return snprintf(outbuf, COLWID, "%d", rSv(NICE, s_int, pp));
} }
// HP-UX "cls": RT RR RR2 ???? HPUX FIFO KERN // HP-UX "cls": RT RR RR2 ???? HPUX FIFO KERN
@ -571,7 +571,7 @@ setREL2(NICE,SCHED_CLASS)
// see miser(1) for this; PRI has some letter codes too // see miser(1) for this; PRI has some letter codes too
static int pr_class(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_class(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(SCHED_CLASS) setREL1(SCHED_CLASS)
switch(rSv(SCHED_CLASS, ul_int, pp)){ switch(rSv(SCHED_CLASS, s_int, pp)){
case -1: return snprintf(outbuf, COLWID, "-"); // not reported case -1: return snprintf(outbuf, COLWID, "-"); // not reported
case 0: return snprintf(outbuf, COLWID, "TS"); // SCHED_OTHER SCHED_NORMAL case 0: return snprintf(outbuf, COLWID, "TS"); // SCHED_OTHER SCHED_NORMAL
case 1: return snprintf(outbuf, COLWID, "FF"); // SCHED_FIFO case 1: return snprintf(outbuf, COLWID, "FF"); // SCHED_FIFO
@ -594,13 +594,13 @@ setREL1(SCHED_CLASS)
// We just print the priority, and have other keywords for type. // We just print the priority, and have other keywords for type.
static int pr_rtprio(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_rtprio(char *restrict const outbuf, const proc_t *restrict const pp){
setREL2(SCHED_CLASS,RTPRIO) setREL2(SCHED_CLASS,RTPRIO)
if(rSv(SCHED_CLASS, ul_int, pp)==0 || rSv(SCHED_CLASS, ul_int, pp)==(unsigned long)-1) return snprintf(outbuf, COLWID, "-"); if(rSv(SCHED_CLASS, s_int, pp)==0 || rSv(SCHED_CLASS, s_int, pp)==-1) return snprintf(outbuf, COLWID, "-");
return snprintf(outbuf, COLWID, "%ld", rSv(RTPRIO, ul_int, pp)); return snprintf(outbuf, COLWID, "%d", rSv(RTPRIO, s_int, pp));
} }
static int pr_sched(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_sched(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(SCHED_CLASS) setREL1(SCHED_CLASS)
if(rSv(SCHED_CLASS, ul_int, pp)==(unsigned long)-1) return snprintf(outbuf, COLWID, "-"); if(rSv(SCHED_CLASS, s_int, pp)==-1) return snprintf(outbuf, COLWID, "-");
return snprintf(outbuf, COLWID, "%ld", rSv(SCHED_CLASS, ul_int, pp)); return snprintf(outbuf, COLWID, "%d", rSv(SCHED_CLASS, s_int, pp));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -632,34 +632,17 @@ setREL1(WCHAN_NAME)
return len; return len;
} }
static int pr_wname(char *restrict const outbuf, const proc_t *restrict const pp){
/* SGI's IRIX always uses a number for "wchan", so "wname" is provided too.
*
* We use '-' for running processes, the location when there is
* only one thread waiting in the kernel, and '*' when there is
* more than one thread waiting in the kernel.
*
* The output should be truncated to maximal columns width -- overflow
* is not supported for the "wchan".
*/
const char *w;
size_t len;
setREL1(WCHAN_NAME)
w = rSv(WCHAN_NAME, str, pp);
len = strlen(w);
if(len>max_rightward) len=max_rightward;
memcpy(outbuf, w, len);
outbuf[len] = '\0';
return len;
}
static int pr_nwchan(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_nwchan(char *restrict const outbuf, const proc_t *restrict const pp){
char buf[32];
setREL1(WCHAN_ADDR) setREL1(WCHAN_ADDR)
if (!(rSv(WCHAN_ADDR, ul_int, pp) & 0xffffff)) { if (!(rSv(WCHAN_ADDR, ul_int, pp) & 0xffffff)) {
memcpy(outbuf, "-",2); memcpy(outbuf, "-",2);
return 1; return 1;
} }
return snprintf(outbuf, COLWID, "%x", (unsigned)rSv(WCHAN_ADDR, ul_int, pp)); snprintf(buf, sizeof(buf), "%lx", rSv(WCHAN_ADDR, ul_int, pp));
// this will force a match with that old ps ...
buf[6] = '\0';
return snprintf(outbuf, COLWID, "%s", buf);
} }
/* Terrible trunctuation, like BSD crap uses: I999 J999 K999 */ /* Terrible trunctuation, like BSD crap uses: I999 J999 K999 */
@ -697,16 +680,16 @@ static int pr_stat(char *restrict const outbuf, const proc_t *restrict const pp)
return 0; return 0;
} }
outbuf[end++] = rSv(STATE, s_ch, pp); outbuf[end++] = rSv(STATE, s_ch, pp);
// if(rSv(RSS, sl_int, pp)==0 && rSv(STATE, s_ch, pp)!='Z') outbuf[end++] = 'W'; // useless "swapped out" // if(rSv(RSS, ul_int, pp)==0 && rSv(STATE, s_ch, pp)!='Z') outbuf[end++] = 'W'; // useless "swapped out"
if(rSv(NICE, sl_int, pp) < 0) outbuf[end++] = '<'; if(rSv(NICE, s_int, pp) < 0) outbuf[end++] = '<';
if(rSv(NICE, sl_int, pp) > 0) outbuf[end++] = 'N'; if(rSv(NICE, s_int, pp) > 0) outbuf[end++] = 'N';
// In this order, NetBSD would add: // In this order, NetBSD would add:
// traced 'X' // traced 'X'
// systrace 'x' // systrace 'x'
// exiting 'E' (not printed for zombies) // exiting 'E' (not printed for zombies)
// vforked 'V' // vforked 'V'
// system 'K' (and do not print 'L' too) // system 'K' (and do not print 'L' too)
if(rSv(VM_RSS_LOCKED, sl_int, pp)) outbuf[end++] = 'L'; if(rSv(VM_RSS_LOCKED, ul_int, pp)) outbuf[end++] = 'L';
if(rSv(ID_SESSION, s_int, pp) == rSv(ID_TGID, s_int, pp)) outbuf[end++] = 's'; // session leader if(rSv(ID_SESSION, s_int, pp) == rSv(ID_TGID, s_int, pp)) outbuf[end++] = 's'; // session leader
if(rSv(NLWP, s_int, pp) > 1) outbuf[end++] = 'l'; // multi-threaded if(rSv(NLWP, s_int, pp) > 1) outbuf[end++] = 'l'; // multi-threaded
if(rSv(ID_PGRP, s_int, pp) == rSv(ID_TPGID, s_int, pp)) outbuf[end++] = '+'; // in foreground process group if(rSv(ID_PGRP, s_int, pp) == rSv(ID_TPGID, s_int, pp)) outbuf[end++] = '+'; // in foreground process group
@ -764,8 +747,8 @@ setREL1(ADDR_KSTK_EIP)
static int old_time_helper(char *dst, unsigned long long t, unsigned long long rel) { static int old_time_helper(char *dst, unsigned long long t, unsigned long long rel) {
if(!t) return snprintf(dst, COLWID, " -"); if(!t) return snprintf(dst, COLWID, " -");
if(t == ~0ULL) return snprintf(dst, COLWID, " xx"); if(t == ~0ULL) return snprintf(dst, COLWID, " xx");
if((long long)(t-=rel) < 0) t=0ULL; if((long long)(t -= rel) < 0) t = 0ULL;
if(t>9999ULL) return snprintf(dst, COLWID, "%5llu", t/100ULL); if(t > 9999ULL) return snprintf(dst, COLWID, "%5llu", t/100ULL);
else return snprintf(dst, COLWID, "%2u.%02u", (unsigned)t/100U, (unsigned)t%100U); else return snprintf(dst, COLWID, "%2u.%02u", (unsigned)t/100U, (unsigned)t%100U);
} }
@ -794,13 +777,13 @@ setREL1(TIME_START)
static int pr_alarm(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_alarm(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(ALARM) setREL1(ALARM)
return old_time_helper(outbuf, rSv(ALARM, sl_int, pp), 0ULL); return old_time_helper(outbuf, rSv(ALARM, ul_int, pp), 0ULL);
} }
/* HP-UX puts this in pages and uses "vsz" for kB */ /* HP-UX puts this in pages and uses "vsz" for kB */
static int pr_sz(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_sz(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(VM_SIZE) setREL1(VM_SIZE)
return snprintf(outbuf, COLWID, "%ld", rSv(VM_SIZE, sl_int, pp)/(page_size/1024)); return snprintf(outbuf, COLWID, "%lu", rSv(VM_SIZE, ul_int, pp)/(page_size/1024));
} }
@ -853,28 +836,28 @@ setREL3(VSIZE_PGS,ADDR_END_CODE,ADDR_START_CODE)
static int pr_swapable(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_swapable(char *restrict const outbuf, const proc_t *restrict const pp){
setREL3(VM_DATA,VM_STACK,VSIZE_PGS) // that last enum will approximate sort needs setREL3(VM_DATA,VM_STACK,VSIZE_PGS) // that last enum will approximate sort needs
return snprintf(outbuf, COLWID, "%ld", rSv(VM_DATA, sl_int, pp) + rSv(VM_STACK, sl_int, pp)); return snprintf(outbuf, COLWID, "%lu", rSv(VM_DATA, ul_int, pp) + rSv(VM_STACK, ul_int, pp));
} }
/* nasty old Debian thing */ /* nasty old Debian thing */
static int pr_size(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_size(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(VSIZE_PGS) setREL1(VSIZE_PGS)
return snprintf(outbuf, COLWID, "%ld", rSv(VSIZE_PGS, ul_int, pp)); return snprintf(outbuf, COLWID, "%lu", rSv(VSIZE_PGS, ul_int, pp));
} }
static int pr_minflt(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_minflt(char *restrict const outbuf, const proc_t *restrict const pp){
setREL2(FLT_MIN,FLT_MIN_C) setREL2(FLT_MIN,FLT_MIN_C)
long flt = rSv(FLT_MIN, ul_int, pp); unsigned long flt = rSv(FLT_MIN, ul_int, pp);
if(include_dead_children) flt = rSv(FLT_MIN_C, ul_int, pp); if(include_dead_children) flt = rSv(FLT_MIN_C, ul_int, pp);
return snprintf(outbuf, COLWID, "%ld", flt); return snprintf(outbuf, COLWID, "%lu", flt);
} }
static int pr_majflt(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_majflt(char *restrict const outbuf, const proc_t *restrict const pp){
setREL2(FLT_MAJ,FLT_MAJ_C) setREL2(FLT_MAJ,FLT_MAJ_C)
long flt = rSv(FLT_MAJ, ul_int, pp); unsigned long flt = rSv(FLT_MAJ, ul_int, pp);
if(include_dead_children) flt = rSv(FLT_MAJ_C, ul_int, pp); if(include_dead_children) flt = rSv(FLT_MAJ_C, ul_int, pp);
return snprintf(outbuf, COLWID, "%ld", flt); return snprintf(outbuf, COLWID, "%lu", flt);
} }
static int pr_lim(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_lim(char *restrict const outbuf, const proc_t *restrict const pp){
@ -885,7 +868,7 @@ setREL1(RSS_RLIM)
outbuf[2] = '\0'; outbuf[2] = '\0';
return 2; return 2;
} }
return snprintf(outbuf, COLWID, "%5ld", rSv(RSS_RLIM, ul_int, pp) >> 10L); return snprintf(outbuf, COLWID, "%5lu", rSv(RSS_RLIM, ul_int, pp) >> 10L);
} }
/* should print leading tilde ('~') if process is bound to the CPU */ /* should print leading tilde ('~') if process is bound to the CPU */
@ -896,14 +879,14 @@ setREL1(PROCESSOR)
static int pr_rss(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_rss(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(VM_RSS) setREL1(VM_RSS)
return snprintf(outbuf, COLWID, "%ld", rSv(VM_RSS, sl_int, pp)); return snprintf(outbuf, COLWID, "%lu", rSv(VM_RSS, ul_int, pp));
} }
/* pp->vm_rss * 1000 would overflow on 32-bit systems with 64 GB memory */ /* pp->vm_rss * 1000 would overflow on 32-bit systems with 64 GB memory */
static int pr_pmem(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_pmem(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long pmem = 0; unsigned long pmem = 0;
setREL1(VM_RSS) setREL1(VM_RSS)
pmem = rSv(VM_RSS, sl_int, pp) * 1000ULL / memory_total; pmem = rSv(VM_RSS, ul_int, pp) * 1000ULL / memory_total;
if (pmem > 999) pmem = 999; if (pmem > 999) pmem = 999;
return snprintf(outbuf, COLWID, "%2u.%u", (unsigned)(pmem/10), (unsigned)(pmem%10)); return snprintf(outbuf, COLWID, "%2u.%u", (unsigned)(pmem/10), (unsigned)(pmem%10));
} }
@ -1466,10 +1449,10 @@ static const format_struct format_array[] = { /*
{"lwp", "LWP", pr_tasks, PIDS_ID_PID, 5, SUN, TO|PIDMAX|RIGHT}, {"lwp", "LWP", pr_tasks, PIDS_ID_PID, 5, SUN, TO|PIDMAX|RIGHT},
{"lxc", "LXC", pr_lxcname, PIDS_LXCNAME, 8, LNX, ET|LEFT}, {"lxc", "LXC", pr_lxcname, PIDS_LXCNAME, 8, LNX, ET|LEFT},
{"m_drs", "DRS", pr_drs, PIDS_VSIZE_PGS, 5, LNx, PO|RIGHT}, {"m_drs", "DRS", pr_drs, PIDS_VSIZE_PGS, 5, LNx, PO|RIGHT},
{"m_dt", "DT", pr_nop, PIDS_MEM_DT, 4, LNx, PO|RIGHT}, {"m_dt", "DT", pr_nop, PIDS_MEM_DT_PGS, 4, LNx, PO|RIGHT},
{"m_lrs", "LRS", pr_nop, PIDS_MEM_LRS, 5, LNx, PO|RIGHT}, {"m_lrs", "LRS", pr_nop, PIDS_MEM_LRS_PGS, 5, LNx, PO|RIGHT},
{"m_resident", "RES", pr_nop, PIDS_MEM_RES, 5, LNx, PO|RIGHT}, {"m_resident", "RES", pr_nop, PIDS_MEM_RES_PGS, 5, LNx, PO|RIGHT},
{"m_share", "SHRD", pr_nop, PIDS_MEM_SHR, 5, LNx, PO|RIGHT}, {"m_share", "SHRD", pr_nop, PIDS_MEM_SHR_PGS, 5, LNx, PO|RIGHT},
{"m_size", "SIZE", pr_size, PIDS_VSIZE_PGS, 5, LNX, PO|RIGHT}, {"m_size", "SIZE", pr_size, PIDS_VSIZE_PGS, 5, LNX, PO|RIGHT},
{"m_swap", "SWAP", pr_nop, PIDS_noop, 5, LNx, PO|RIGHT}, {"m_swap", "SWAP", pr_nop, PIDS_noop, 5, LNx, PO|RIGHT},
{"m_trs", "TRS", pr_trs, PIDS_VSIZE_PGS, 5, LNx, PO|RIGHT}, {"m_trs", "TRS", pr_trs, PIDS_VSIZE_PGS, 5, LNx, PO|RIGHT},
@ -1491,7 +1474,7 @@ static const format_struct format_array[] = { /*
{"nsigs", "NSIGS", pr_nop, PIDS_noop, 5, BSD, AN|RIGHT}, /*nsignals*/ {"nsigs", "NSIGS", pr_nop, PIDS_noop, 5, BSD, AN|RIGHT}, /*nsignals*/
{"nswap", "NSWAP", pr_nop, PIDS_noop, 5, XXX, AN|RIGHT}, {"nswap", "NSWAP", pr_nop, PIDS_noop, 5, XXX, AN|RIGHT},
{"nvcsw", "VCSW", pr_nop, PIDS_noop, 5, XXX, AN|RIGHT}, {"nvcsw", "VCSW", pr_nop, PIDS_noop, 5, XXX, AN|RIGHT},
{"nwchan", "WCHAN", pr_nwchan, PIDS_WCHAN_NAME, 6, XXX, TO|RIGHT}, {"nwchan", "WCHAN", pr_nwchan, PIDS_WCHAN_ADDR, 6, XXX, TO|RIGHT},
{"opri", "PRI", pr_opri, PIDS_PRIORITY, 3, SUN, TO|RIGHT}, {"opri", "PRI", pr_opri, PIDS_PRIORITY, 3, SUN, TO|RIGHT},
{"osz", "SZ", pr_nop, PIDS_noop, 2, SUN, PO|RIGHT}, {"osz", "SZ", pr_nop, PIDS_noop, 2, SUN, PO|RIGHT},
{"oublk", "OUBLK", pr_nop, PIDS_noop, 5, BSD, AN|RIGHT}, /*oublock*/ {"oublk", "OUBLK", pr_nop, PIDS_noop, 5, BSD, AN|RIGHT}, /*oublock*/
@ -1524,7 +1507,7 @@ static const format_struct format_array[] = { /*
{"psr", "PSR", pr_psr, PIDS_PROCESSOR, 3, DEC, TO|RIGHT}, {"psr", "PSR", pr_psr, PIDS_PROCESSOR, 3, DEC, TO|RIGHT},
{"psxpri", "PPR", pr_nop, PIDS_noop, 3, DEC, TO|RIGHT}, {"psxpri", "PPR", pr_nop, PIDS_noop, 3, DEC, TO|RIGHT},
{"re", "RE", pr_nop, PIDS_noop, 3, BSD, AN|RIGHT}, {"re", "RE", pr_nop, PIDS_noop, 3, BSD, AN|RIGHT},
{"resident", "RES", pr_nop, PIDS_MEM_RES, 5, LNX, PO|RIGHT}, {"resident", "RES", pr_nop, PIDS_MEM_RES_PGS, 5, LNX, PO|RIGHT},
{"rgid", "RGID", pr_rgid, PIDS_ID_RGID, 5, XXX, ET|RIGHT}, {"rgid", "RGID", pr_rgid, PIDS_ID_RGID, 5, XXX, ET|RIGHT},
{"rgroup", "RGROUP", pr_rgroup, PIDS_ID_RGROUP, 8, U98, ET|USER}, /* was 8 wide */ {"rgroup", "RGROUP", pr_rgroup, PIDS_ID_RGROUP, 8, U98, ET|USER}, /* was 8 wide */
{"rlink", "RLINK", pr_nop, PIDS_noop, 8, BSD, AN|RIGHT}, {"rlink", "RLINK", pr_nop, PIDS_noop, 8, BSD, AN|RIGHT},
@ -1624,8 +1607,8 @@ static const format_struct format_array[] = { /*
{"vm_stack", "STACK", pr_nop, PIDS_VM_STACK, 5, LNx, PO|RIGHT}, {"vm_stack", "STACK", pr_nop, PIDS_VM_STACK, 5, LNx, PO|RIGHT},
{"vsize", "VSZ", pr_vsz, PIDS_VSIZE_PGS, 6, DEC, PO|RIGHT}, /*vsz*/ {"vsize", "VSZ", pr_vsz, PIDS_VSIZE_PGS, 6, DEC, PO|RIGHT}, /*vsz*/
{"vsz", "VSZ", pr_vsz, PIDS_VM_SIZE, 6, U98, PO|RIGHT}, /*vsize*/ {"vsz", "VSZ", pr_vsz, PIDS_VM_SIZE, 6, U98, PO|RIGHT}, /*vsize*/
{"wchan", "WCHAN", pr_wchan, PIDS_WCHAN_ADDR, 6, XXX, TO|WCHAN}, /* BSD n forces this to nwchan */ /* was 10 wide */ {"wchan", "WCHAN", pr_wchan, PIDS_WCHAN_NAME, 6, XXX, TO|WCHAN}, /* BSD n forces this to nwchan */ /* was 10 wide */
{"wname", "WCHAN", pr_wname, PIDS_WCHAN_NAME, 6, SGI, TO|WCHAN}, /* opposite of nwchan */ {"wname", "WCHAN", pr_wchan, PIDS_WCHAN_NAME, 6, SGI, TO|WCHAN}, /* opposite of nwchan */
{"xstat", "XSTAT", pr_nop, PIDS_noop, 5, BSD, AN|RIGHT}, {"xstat", "XSTAT", pr_nop, PIDS_noop, 5, BSD, AN|RIGHT},
{"zone", "ZONE", pr_context, PIDS_ID_TGID, 31, SUN, ET|LEFT}, // Solaris zone == Linux context? {"zone", "ZONE", pr_context, PIDS_ID_TGID, 31, SUN, ET|LEFT}, // Solaris zone == Linux context?
{"zoneid", "ZONEID", pr_nop, PIDS_noop, 31, SUN, ET|RIGHT}, // Linux only offers context names {"zoneid", "ZONEID", pr_nop, PIDS_noop, 31, SUN, ET|RIGHT}, // Linux only offers context names

174
top/top.c
View File

@ -1496,88 +1496,88 @@ static struct {
a 0 width represents columns set once at startup (see zap_fieldstab) a 0 width represents columns set once at startup (see zap_fieldstab)
.width .scale .align .erel .item .width .scale .align .erel .item
------ ------ -------- ----- ------------------ */ ------ ------ -------- ----- ------------------- */
{ 0, -1, A_right, -1, PIDS_ID_PID }, // s_int EU_PID { 0, -1, A_right, -1, PIDS_ID_PID }, // s_int EU_PID
{ 0, -1, A_right, -1, PIDS_ID_PPID }, // s_int EU_PPD { 0, -1, A_right, -1, PIDS_ID_PPID }, // s_int EU_PPD
{ 5, -1, A_right, -1, PIDS_ID_EUID }, // u_int EU_UED { 5, -1, A_right, -1, PIDS_ID_EUID }, // u_int EU_UED
{ 8, -1, A_left, -1, PIDS_ID_EUSER }, // str EU_UEN { 8, -1, A_left, -1, PIDS_ID_EUSER }, // str EU_UEN
{ 5, -1, A_right, -1, PIDS_ID_RUID }, // u_int EU_URD { 5, -1, A_right, -1, PIDS_ID_RUID }, // u_int EU_URD
{ 8, -1, A_left, -1, PIDS_ID_RUSER }, // str EU_URN { 8, -1, A_left, -1, PIDS_ID_RUSER }, // str EU_URN
{ 5, -1, A_right, -1, PIDS_ID_SUID }, // u_int EU_USD { 5, -1, A_right, -1, PIDS_ID_SUID }, // u_int EU_USD
{ 8, -1, A_left, -1, PIDS_ID_SUSER }, // str EU_USN { 8, -1, A_left, -1, PIDS_ID_SUSER }, // str EU_USN
{ 5, -1, A_right, -1, PIDS_ID_EGID }, // u_int EU_GID { 5, -1, A_right, -1, PIDS_ID_EGID }, // u_int EU_GID
{ 8, -1, A_left, -1, PIDS_ID_EGROUP }, // str EU_GRP { 8, -1, A_left, -1, PIDS_ID_EGROUP }, // str EU_GRP
{ 0, -1, A_right, -1, PIDS_ID_PGRP }, // s_int EU_PGD { 0, -1, A_right, -1, PIDS_ID_PGRP }, // s_int EU_PGD
{ 8, -1, A_left, -1, PIDS_TTY_NAME }, // str EU_TTY { 8, -1, A_left, -1, PIDS_TTY_NAME }, // str EU_TTY
{ 0, -1, A_right, -1, PIDS_ID_TPGID }, // s_int EU_TPG { 0, -1, A_right, -1, PIDS_ID_TPGID }, // s_int EU_TPG
{ 0, -1, A_right, -1, PIDS_ID_SESSION }, // s_int EU_SID { 0, -1, A_right, -1, PIDS_ID_SESSION }, // s_int EU_SID
{ 3, -1, A_right, -1, PIDS_PRIORITY }, // s_int EU_PRI { 3, -1, A_right, -1, PIDS_PRIORITY }, // s_int EU_PRI
{ 3, -1, A_right, -1, PIDS_NICE }, // sl_int EU_NCE { 3, -1, A_right, -1, PIDS_NICE }, // s_int EU_NCE
{ 3, -1, A_right, -1, PIDS_NLWP }, // s_int EU_THD { 3, -1, A_right, -1, PIDS_NLWP }, // s_int EU_THD
{ 0, -1, A_right, -1, PIDS_PROCESSOR }, // u_int EU_CPN { 0, -1, A_right, -1, PIDS_PROCESSOR }, // u_int EU_CPN
{ 0, -1, A_right, -1, PIDS_TICS_DELTA }, // sl_int EU_CPU { 0, -1, A_right, -1, PIDS_TICS_ALL_DELTA }, // s_int EU_CPU
{ 6, -1, A_right, -1, PIDS_TICS_ALL }, // ull_int EU_TME { 6, -1, A_right, -1, PIDS_TICS_ALL }, // ull_int EU_TME
{ 9, -1, A_right, -1, PIDS_TICS_ALL }, // ull_int EU_TM2 { 9, -1, A_right, -1, PIDS_TICS_ALL }, // ull_int EU_TM2
#ifdef BOOST_PERCNT #ifdef BOOST_PERCNT
{ 5, -1, A_right, -1, PIDS_VM_RSS }, // sl_int EU_MEM { 5, -1, A_right, -1, PIDS_VM_RSS }, // ul_int EU_MEM
#else #else
{ 4, -1, A_right, -1, PIDS_VM_RSS }, // sl_int EU_MEM, { 4, -1, A_right, -1, PIDS_VM_RSS }, // ul_int EU_MEM,
#endif #endif
#ifndef NOBOOST_MEMS #ifndef NOBOOST_MEMS
{ 7, SK_Kb, A_right, -1, PIDS_MEM_VIRT_KIB }, // sl_int EU_VRT { 7, SK_Kb, A_right, -1, PIDS_MEM_VIRT }, // ul_int EU_VRT
{ 6, SK_Kb, A_right, -1, PIDS_VM_SWAP }, // sl_int EU_SWP { 6, SK_Kb, A_right, -1, PIDS_VM_SWAP }, // ul_int EU_SWP
{ 6, SK_Kb, A_right, -1, PIDS_VM_RSS }, // sl_int EU_RES { 6, SK_Kb, A_right, -1, PIDS_VM_RSS }, // ul_int EU_RES
{ 6, SK_Kb, A_right, -1, PIDS_MEM_CODE_KIB }, // sl_int EU_COD { 6, SK_Kb, A_right, -1, PIDS_MEM_CODE }, // ul_int EU_COD
{ 7, SK_Kb, A_right, -1, PIDS_MEM_DATA_KIB }, // sl_int EU_DAT { 7, SK_Kb, A_right, -1, PIDS_MEM_DATA }, // ul_int EU_DAT
{ 6, SK_Kb, A_right, -1, PIDS_MEM_SHR_KIB }, // sl_int EU_SHR { 6, SK_Kb, A_right, -1, PIDS_MEM_SHR }, // ul_int EU_SHR
#else #else
{ 5, SK_Kb, A_right, -1, PIDS_MEM_VIRT_KIB }, // sl_int EU_VRT { 5, SK_Kb, A_right, -1, PIDS_MEM_VIRT }, // ul_int EU_VRT
{ 4, SK_Kb, A_right, -1, PIDS_VM_SWAP }, // sl_int EU_SWP { 4, SK_Kb, A_right, -1, PIDS_VM_SWAP }, // ul_int EU_SWP
{ 4, SK_Kb, A_right, -1, PIDS_VM_RSS }, // sl_int EU_RES { 4, SK_Kb, A_right, -1, PIDS_VM_RSS }, // ul_int EU_RES
{ 4, SK_Kb, A_right, -1, PIDS_MEM_CODE_KIB }, // sl_int EU_COD { 4, SK_Kb, A_right, -1, PIDS_MEM_CODE }, // ul_int EU_COD
{ 5, SK_Kb, A_right, -1, PIDS_MEM_DATA_KIB }, // sl_int EU_DAT { 5, SK_Kb, A_right, -1, PIDS_MEM_DATA }, // ul_int EU_DAT
{ 4, SK_Kb, A_right, -1, PIDS_MEM_SHR_KIB }, // sl_int EU_SHR { 4, SK_Kb, A_right, -1, PIDS_MEM_SHR }, // ul_int EU_SHR
#endif #endif
{ 4, -1, A_right, -1, PIDS_FLT_MAJ }, // sl_int EU_FL1 { 4, -1, A_right, -1, PIDS_FLT_MAJ }, // ul_int EU_FL1
{ 4, -1, A_right, -1, PIDS_FLT_MIN }, // sl_int EU_FL2 { 4, -1, A_right, -1, PIDS_FLT_MIN }, // ul_int EU_FL2
{ 4, -1, A_right, -1, PIDS_MEM_DT }, // sl_int EU_DRT ( always 0 w/ since 2.6 ) { 4, -1, A_right, -1, PIDS_MEM_DT_PGS }, // ul_int EU_DRT ( always 0 w/ since 2.6 )
{ 1, -1, A_right, -1, PIDS_STATE }, // s_ch EU_STA { 1, -1, A_right, -1, PIDS_STATE }, // s_ch EU_STA
{ -1, -1, A_left, -1, PIDS_CMD }, // str EU_CMD { -1, -1, A_left, -1, PIDS_CMD }, // str EU_CMD
{ 10, -1, A_left, -1, PIDS_WCHAN_NAME }, // str EU_WCH { 10, -1, A_left, -1, PIDS_WCHAN_NAME }, // str EU_WCH
{ 8, -1, A_left, -1, PIDS_FLAGS }, // ul_int EU_FLG { 8, -1, A_left, -1, PIDS_FLAGS }, // ul_int EU_FLG
{ -1, -1, A_left, -1, PIDS_CGROUP }, // str EU_CGR { -1, -1, A_left, -1, PIDS_CGROUP }, // str EU_CGR
{ -1, -1, A_left, -1, PIDS_SUPGIDS }, // str EU_SGD { -1, -1, A_left, -1, PIDS_SUPGIDS }, // str EU_SGD
{ -1, -1, A_left, -1, PIDS_SUPGROUPS }, // str EU_SGN { -1, -1, A_left, -1, PIDS_SUPGROUPS }, // str EU_SGN
{ 0, -1, A_right, -1, PIDS_ID_TGID }, // s_int EU_TGD { 0, -1, A_right, -1, PIDS_ID_TGID }, // s_int EU_TGD
{ 5, -1, A_right, -1, PIDS_OOM_ADJ }, // s_int EU_OOA { 5, -1, A_right, -1, PIDS_OOM_ADJ }, // s_int EU_OOA
{ 4, -1, A_right, -1, PIDS_OOM_SCORE }, // s_int EU_OOM { 4, -1, A_right, -1, PIDS_OOM_SCORE }, // s_int EU_OOM
{ -1, -1, A_left, -1, PIDS_ENVIRON }, // str EU_ENV { -1, -1, A_left, -1, PIDS_ENVIRON }, // str EU_ENV
{ 3, -1, A_right, -1, PIDS_FLT_MAJ_DELTA }, // sl_int EU_FV1 { 3, -1, A_right, -1, PIDS_FLT_MAJ_DELTA }, // s_int EU_FV1
{ 3, -1, A_right, -1, PIDS_FLT_MIN_DELTA }, // sl_int EU_FV2 { 3, -1, A_right, -1, PIDS_FLT_MIN_DELTA }, // s_int EU_FV2
#ifndef NOBOOST_MEMS #ifndef NOBOOST_MEMS
{ 6, SK_Kb, A_right, -1, PIDS_VM_USED }, // sl_int EU_USE { 6, SK_Kb, A_right, -1, PIDS_VM_USED }, // ul_int EU_USE
#else #else
{ 4, SK_Kb, A_right, -1, PIDS_VM_USED }, // sl_int EU_USE { 4, SK_Kb, A_right, -1, PIDS_VM_USED }, // ul_int EU_USE
#endif #endif
{ 10, -1, A_right, -1, PIDS_NS_IPC }, // ul_int EU_NS1 { 10, -1, A_right, -1, PIDS_NS_IPC }, // ul_int EU_NS1
{ 10, -1, A_right, -1, PIDS_NS_MNT }, // ul_int EU_NS2 { 10, -1, A_right, -1, PIDS_NS_MNT }, // ul_int EU_NS2
{ 10, -1, A_right, -1, PIDS_NS_NET }, // ul_int EU_NS3 { 10, -1, A_right, -1, PIDS_NS_NET }, // ul_int EU_NS3
{ 10, -1, A_right, -1, PIDS_NS_PID }, // ul_int EU_NS4 { 10, -1, A_right, -1, PIDS_NS_PID }, // ul_int EU_NS4
{ 10, -1, A_right, -1, PIDS_NS_USER }, // ul_int EU_NS5 { 10, -1, A_right, -1, PIDS_NS_USER }, // ul_int EU_NS5
{ 10, -1, A_right, -1, PIDS_NS_UTS }, // ul_int EU_NS6 { 10, -1, A_right, -1, PIDS_NS_UTS }, // ul_int EU_NS6
{ 8, -1, A_left, -1, PIDS_LXCNAME }, // str EU_LXC { 8, -1, A_left, -1, PIDS_LXCNAME }, // str EU_LXC
#ifndef NOBOOST_MEMS #ifndef NOBOOST_MEMS
{ 6, SK_Kb, A_right, -1, PIDS_VM_RSS_ANON }, // sl_int EU_RZA { 6, SK_Kb, A_right, -1, PIDS_VM_RSS_ANON }, // ul_int EU_RZA
{ 6, SK_Kb, A_right, -1, PIDS_VM_RSS_FILE }, // sl_int EU_RZF { 6, SK_Kb, A_right, -1, PIDS_VM_RSS_FILE }, // ul_int EU_RZF
{ 6, SK_Kb, A_right, -1, PIDS_VM_RSS_LOCKED }, // sl_int EU_RZL { 6, SK_Kb, A_right, -1, PIDS_VM_RSS_LOCKED }, // ul_int EU_RZL
{ 6, SK_Kb, A_right, -1, PIDS_VM_RSS_SHARED }, // sl_int EU_RZS { 6, SK_Kb, A_right, -1, PIDS_VM_RSS_SHARED }, // ul_int EU_RZS
#else #else
{ 4, SK_Kb, A_right, -1, PIDS_VM_RSS_ANON }, // sl_int EU_RZA { 4, SK_Kb, A_right, -1, PIDS_VM_RSS_ANON }, // ul_int EU_RZA
{ 4, SK_Kb, A_right, -1, PIDS_VM_RSS_FILE }, // sl_int EU_RZF { 4, SK_Kb, A_right, -1, PIDS_VM_RSS_FILE }, // ul_int EU_RZF
{ 4, SK_Kb, A_right, -1, PIDS_VM_RSS_LOCKED }, // sl_int EU_RZL { 4, SK_Kb, A_right, -1, PIDS_VM_RSS_LOCKED }, // ul_int EU_RZL
{ 4, SK_Kb, A_right, -1, PIDS_VM_RSS_SHARED }, // sl_int EU_RZS { 4, SK_Kb, A_right, -1, PIDS_VM_RSS_SHARED }, // ul_int EU_RZS
#endif #endif
{ -1, -1, A_left, -1, PIDS_CGNAME }, // str EU_CGN { -1, -1, A_left, -1, PIDS_CGNAME }, // str EU_CGN
#define eu_LAST EU_CGN #define eu_LAST EU_CGN
// xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . . . . . // xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . . . . .
#define eu_CMDLINE eu_LAST +1 #define eu_CMDLINE eu_LAST +1
@ -1585,11 +1585,11 @@ static struct {
#define eu_TIME_START eu_LAST +3 #define eu_TIME_START eu_LAST +3
#define eu_ID_FUID eu_LAST +4 #define eu_ID_FUID eu_LAST +4
#define eu_XTRA eu_LAST +5 #define eu_XTRA eu_LAST +5
{ -1, -1, -1, -1, PIDS_CMDLINE }, // str ( if Show_CMDLIN ) { -1, -1, -1, -1, PIDS_CMDLINE }, // str ( if Show_CMDLIN )
{ -1, -1, -1, -1, PIDS_TICS_ALL_C }, // ull_int ( if Show_CTIMES ) { -1, -1, -1, -1, PIDS_TICS_ALL_C }, // ull_int ( if Show_CTIMES )
{ -1, -1, -1, -1, PIDS_TIME_START }, // ull_int ( if Show_FOREST ) { -1, -1, -1, -1, PIDS_TIME_START }, // ull_int ( if Show_FOREST )
{ -1, -1, -1, -1, PIDS_ID_FUID }, // u_int ( if a usrseltyp ) { -1, -1, -1, -1, PIDS_ID_FUID }, // u_int ( if a usrseltyp )
{ -1, -1, -1, -1, PIDS_extra } // u_int ( if Show_FOREST ) { -1, -1, -1, -1, PIDS_extra } // u_int ( if Show_FOREST )
#undef A_left #undef A_left
#undef A_right #undef A_right
}; };
@ -4895,10 +4895,16 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
cp = make_num(rSv(i, s_int), W, Jn, AUTOX_NO, 0); cp = make_num(rSv(i, s_int), W, Jn, AUTOX_NO, 0);
break; break;
/* s_int, make_num without auto width, but with zero supression */ /* s_int, make_num without auto width, but with zero supression */
case EU_NCE:
case EU_OOA: case EU_OOA:
case EU_OOM: case EU_OOM:
cp = make_num(rSv(i, s_int), W, Jn, AUTOX_NO, 1); cp = make_num(rSv(i, s_int), W, Jn, AUTOX_NO, 1);
break; break;
/* s_int, scale_num */
case EU_FV1:
case EU_FV2:
cp = scale_num(rSv(i, s_int), W, Jn);
break;
/* s_int, make_num or make_str */ /* s_int, make_num or make_str */
case EU_PRI: case EU_PRI:
if (-99 > rSv(EU_PRI, s_int) || 999 < rSv(EU_PRI, s_int)) { if (-99 > rSv(EU_PRI, s_int) || 999 < rSv(EU_PRI, s_int)) {
@ -4919,7 +4925,7 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
break; break;
/* u_int, scale_pcnt with special handling */ /* u_int, scale_pcnt with special handling */
case EU_CPU: case EU_CPU:
{ float u = (float)rSv(EU_CPU, sl_int) * Frame_etscale; { float u = (float)rSv(EU_CPU, s_int) * Frame_etscale;
int n = rSv(EU_THD, s_int); int n = rSv(EU_THD, s_int);
/* process can't use more %cpu than number of threads it has /* process can't use more %cpu than number of threads it has
( thanks Jaromir Capik <jcapik@redhat.com> ) */ ( thanks Jaromir Capik <jcapik@redhat.com> ) */
@ -4928,10 +4934,6 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
cp = scale_pcnt(u, W, Jn); cp = scale_pcnt(u, W, Jn);
} }
break; break;
/* sl_int, make_num without auto width, but with zero supression */
case EU_NCE:
cp = make_num(rSv(EU_NCE, sl_int), W, Jn, AUTOX_NO, 1);
break;
/* ul_int, make_num with auto width and zero supression */ /* ul_int, make_num with auto width and zero supression */
case EU_NS1: case EU_NS1:
case EU_NS2: case EU_NS2:
@ -4944,7 +4946,7 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
/* ul_int, scale_mem */ /* ul_int, scale_mem */
case EU_COD: case EU_COD:
case EU_DAT: case EU_DAT:
case EU_DRT: // really # pgs & sl_int, but always zero since 2.6 case EU_DRT: // really # pgs, but always zero since 2.6
case EU_RES: case EU_RES:
case EU_RZA: case EU_RZA:
case EU_RZF: case EU_RZF:
@ -4954,18 +4956,16 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
case EU_SWP: case EU_SWP:
case EU_USE: case EU_USE:
case EU_VRT: case EU_VRT:
cp = scale_mem(S, rSv(i, sl_int), W, Jn); cp = scale_mem(S, rSv(i, ul_int), W, Jn);
break; break;
/* ul_int, scale_num */ /* ul_int, scale_num */
case EU_FL1: case EU_FL1:
case EU_FL2: case EU_FL2:
case EU_FV1: cp = scale_num(rSv(i, ul_int), W, Jn);
case EU_FV2:
cp = scale_num(rSv(i, sl_int), W, Jn);
break; break;
/* ul_int, scale_pcnt */ /* ul_int, scale_pcnt */
case EU_MEM: case EU_MEM:
cp = scale_pcnt((float)rSv(EU_RES, sl_int) * 100 / MEM_VAL(mem_TOT), W, Jn); cp = scale_pcnt((float)rSv(EU_RES, ul_int) * 100 / MEM_VAL(mem_TOT), W, Jn);
break; break;
/* ul_int, make_str with special handling */ /* ul_int, make_str with special handling */
case EU_FLG: case EU_FLG:
@ -5051,7 +5051,7 @@ static int window_show (WIN_t *q, int wmax) {
/* the isBUSY macro determines if a task is 'active' -- /* the isBUSY macro determines if a task is 'active' --
it returns true if some cpu was used since the last sample. it returns true if some cpu was used since the last sample.
( actual 'running' tasks will be a subset of those selected ) */ ( actual 'running' tasks will be a subset of those selected ) */
#define isBUSY(x) (0 < PID_VAL(EU_CPU, u_int, x)) #define isBUSY(x) (0 < PID_VAL(EU_CPU, s_int, x))
#define winMIN(a,b) ((a < b) ? a : b) #define winMIN(a,b) ((a < b) ? a : b)
int i, lwin; int i, lwin;