ps: now made responsive to 32 or 64-bit address widths

While a Debian bug report referenced below was limited
to the 'eip' and 'esp' fields, this patch also extends
address width adaptations to some other addresses too.

[ and, we do so in a far less invasive manner than a ]
[ redhat approach shown below adding two new fields! ]

Reference(s):
. new debian bug report
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=846361
. old redhat solution
https://bugzilla.redhat.com/show_bug.cgi?id=244152

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-12-03 03:03:03 -06:00 committed by Craig Small
parent 8ba07209f0
commit 1c0d54e963
2 changed files with 10 additions and 9 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ procps-ng-NEXT
* library: dont use SIGPWR on FreeBSD Debian #832148
* pmap: fix duplicate output line under '-x' option Redhat #1374061
* top: eliminated minor libnuma memory leak
* ps: avoid eip/esp address truncations Debain #846361
procps-ng-3.3.12
----------------

View File

@ -719,17 +719,17 @@ tsiz text size (in Kbytes)
static int pr_stackp(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(ADDR_START_STACK)
return snprintf(outbuf, COLWID, "%08x", (unsigned)(rSv(ADDR_START_STACK, ul_int, pp)));
return snprintf(outbuf, COLWID, "%0*lx", (int)(2*sizeof(long)), rSv(ADDR_START_STACK, ul_int, pp));
}
static int pr_esp(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(ADDR_KSTK_ESP)
return snprintf(outbuf, COLWID, "%08x", (unsigned)(rSv(ADDR_KSTK_ESP, ul_int, pp)));
return snprintf(outbuf, COLWID, "%0*lx", (int)(2*sizeof(long)), rSv(ADDR_KSTK_ESP, ul_int, pp));
}
static int pr_eip(char *restrict const outbuf, const proc_t *restrict const pp){
setREL1(ADDR_KSTK_EIP)
return snprintf(outbuf, COLWID, "%08x", (unsigned)(rSv(ADDR_KSTK_EIP, ul_int, pp)));
return snprintf(outbuf, COLWID, "%0*lx", (int)(2*sizeof(long)), rSv(ADDR_KSTK_EIP, ul_int, pp));
}
static int pr_bsdtime(char *restrict const outbuf, const proc_t *restrict const pp){
@ -1380,11 +1380,11 @@ static const format_struct format_array[] = { /*
{"dsiz", "DSIZ", pr_dsiz, PIDS_VSIZE_PGS, 4, LNX, PO|RIGHT},
{"egid", "EGID", pr_egid, PIDS_ID_EGID, 5, LNX, ET|RIGHT},
{"egroup", "EGROUP", pr_egroup, PIDS_ID_EGROUP, 8, LNX, ET|USER},
{"eip", "EIP", pr_eip, PIDS_ADDR_KSTK_EIP, 8, LNX, TO|RIGHT},
{"eip", "EIP", pr_eip, PIDS_ADDR_KSTK_EIP, (int)(2*sizeof(long)), LNX, TO|RIGHT},
{"emul", "EMUL", pr_nop, PIDS_noop, 13, BSD, PO|LEFT}, /* "FreeBSD ELF32" and such */
{"end_code", "E_CODE", pr_nop, PIDS_ADDR_END_CODE, 8, LNx, PO|RIGHT},
{"end_code", "E_CODE", pr_nop, PIDS_ADDR_END_CODE, (int)(2*sizeof(long)), LNx, PO|RIGHT}, // sortable, but unprintable ??
{"environ","ENVIRONMENT",pr_nop, PIDS_noop, 11, LNx, PO|UNLIMITED},
{"esp", "ESP", pr_esp, PIDS_ADDR_KSTK_ESP, 8, LNX, TO|RIGHT},
{"esp", "ESP", pr_esp, PIDS_ADDR_KSTK_ESP, (int)(2*sizeof(long)), LNX, TO|RIGHT},
{"etime", "ELAPSED", pr_etime, PIDS_TIME_ELAPSED, 11, U98, ET|RIGHT}, /* was 7 wide */
{"etimes", "ELAPSED", pr_etimes, PIDS_TIME_ELAPSED, 7, BSD, ET|RIGHT}, /* FreeBSD */
{"euid", "EUID", pr_euid, PIDS_ID_EUID, 5, LNX, ET|RIGHT},
@ -1518,10 +1518,10 @@ static const format_struct format_array[] = { /*
{"sl", "SL", pr_nop, PIDS_noop, 3, XXX, AN|RIGHT},
{"slice", "SLICE", pr_sd_slice, PIDS_SD_SLICE, 31, LNX, ET|LEFT},
{"spid", "SPID", pr_tasks, PIDS_ID_PID, 5, SGI, TO|PIDMAX|RIGHT},
{"stackp", "STACKP", pr_stackp, PIDS_ADDR_START_STACK, 8, LNX, PO|RIGHT}, /*start_stack*/
{"stackp", "STACKP", pr_stackp, PIDS_ADDR_START_STACK, (int)(2*sizeof(long)), LNX, PO|RIGHT}, /*start_stack*/
{"start", "STARTED", pr_start, PIDS_TIME_START, 8, XXX, ET|RIGHT},
{"start_code", "S_CODE", pr_nop, PIDS_noop, 8, LNx, PO|RIGHT},
{"start_stack", "STACKP", pr_stackp, PIDS_ADDR_START_STACK, 8, LNX, PO|RIGHT}, /*stackp*/
{"start_code", "S_CODE", pr_nop, PIDS_ADDR_START_CODE, (int)(2*sizeof(long)), LNx, PO|RIGHT}, // sortable, but unprintable ??
{"start_stack", "STACKP",pr_stackp, PIDS_ADDR_START_STACK, (int)(2*sizeof(long)), LNX, PO|RIGHT}, /*stackp*/
{"start_time", "START", pr_stime, PIDS_TIME_START, 5, LNx, ET|RIGHT},
{"stat", "STAT", pr_stat, PIDS_STATE, 4, BSD, TO|LEFT}, /*state,s*/
{"state", "S", pr_s, PIDS_STATE, 1, XXX, TO|LEFT}, /*stat,s*/ /* was STAT */