pmap: adapt to changes in <pids> API regarding address

This commit was prompted by that change from 'addr' to
'ul_int' in the <pids> interface. Along the way, KLONG
was removed as having long ago outlived its usefulness
as performance optimizations for weird configurations.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2015-09-09 00:00:00 -05:00 committed by Craig Small
parent f0e447cc66
commit 987f4f2e3e

34
pmap.c
View File

@ -91,7 +91,7 @@ static int justify_print(const char *str, int width, int right)
return width; return width;
} }
static int integer_width(unsigned KLONG number) static int integer_width(unsigned long number)
{ {
int result; int result;
@ -134,8 +134,8 @@ usage(FILE * out)
static char mapbuf[1024]; static char mapbuf[1024];
static unsigned KLONG range_low; static unsigned long range_low;
static unsigned KLONG range_high = ~0ull; static unsigned long range_high = ~0ul;
static int c_option; static int c_option;
static int C_option; static int C_option;
@ -173,7 +173,7 @@ static void discover_shm_minor(void)
char perms[32]; char perms[32];
/* to clean up unprintables */ /* to clean up unprintables */
char *tmp; char *tmp;
unsigned KLONG start, end; unsigned long start, end;
unsigned long long file_offset, inode; unsigned long long file_offset, inode;
unsigned dev_major, dev_minor; unsigned dev_major, dev_minor;
sscanf(mapbuf_b, "%" KLF "x-%" KLF "x %31s %llx %x:%x %llu", &start, sscanf(mapbuf_b, "%" KLF "x-%" KLF "x %31s %llx %x:%x %llu", &start,
@ -210,8 +210,8 @@ out_destroy:
return; return;
} }
static char *mapping_name(struct pids_stack *p, unsigned KLONG addr, static char *mapping_name(struct pids_stack *p, unsigned long addr,
unsigned KLONG len, const char *mapbuf_b, unsigned long len, const char *mapbuf_b,
unsigned showpath, unsigned dev_major, unsigned showpath, unsigned dev_major,
unsigned dev_minor, unsigned long long inode) unsigned dev_minor, unsigned long long inode)
{ {
@ -239,8 +239,8 @@ static char *mapping_name(struct pids_stack *p, unsigned KLONG addr,
} }
cp = _(" [ anon ]"); cp = _(" [ anon ]");
if (PROCPS_PIDS_VAL(start_stack, addr, p) >= (void*)addr if (PROCPS_PIDS_VAL(start_stack, ul_int, p) >= addr
&& (PROCPS_PIDS_VAL(start_stack, addr, p) <= (void*)addr + len)) && (PROCPS_PIDS_VAL(start_stack, ul_int, p) <= addr + len))
cp = _(" [ stack ]"); cp = _(" [ stack ]");
return cp; return cp;
} }
@ -255,8 +255,8 @@ static char *mapping_name(struct pids_stack *p, unsigned KLONG addr,
struct listnode { struct listnode {
char description[DETAIL_LENGTH]; char description[DETAIL_LENGTH];
char value_str[NUM_LENGTH]; char value_str[NUM_LENGTH];
unsigned KLONG value; unsigned long value;
unsigned KLONG total; unsigned long total;
int max_width; int max_width;
struct listnode *next; struct listnode *next;
}; };
@ -522,7 +522,7 @@ static int one_proc (struct pids_stack *p)
unsigned long total_shared = 0ul; unsigned long total_shared = 0ul;
unsigned long total_private_readonly = 0ul; unsigned long total_private_readonly = 0ul;
unsigned long total_private_writeable = 0ul; unsigned long total_private_writeable = 0ul;
unsigned KLONG diff = 0; unsigned long diff = 0;
const char *cp2 = NULL; const char *cp2 = NULL;
unsigned long long rss = 0ull; unsigned long long rss = 0ull;
unsigned long long private_dirty = 0ull; unsigned long long private_dirty = 0ull;
@ -551,7 +551,7 @@ static int one_proc (struct pids_stack *p)
if (x_option) { if (x_option) {
maxw1 = 16; maxw1 = 16;
if (sizeof(KLONG) == 4) maxw1 = 8; if (sizeof(long) == 4) maxw1 = 8;
maxw2 = maxw3 = maxw4 = 7; maxw2 = maxw3 = maxw4 = 7;
maxw5 = 5; maxw5 = 5;
if (!q_option) { if (!q_option) {
@ -566,7 +566,7 @@ static int one_proc (struct pids_stack *p)
if (d_option) { if (d_option) {
maxw1 = 16; maxw1 = 16;
if (sizeof(KLONG) == 4) maxw1 = 8; if (sizeof(long) == 4) maxw1 = 8;
maxw2 = 7; maxw2 = 7;
maxw3 = 5; maxw3 = 5;
maxw4 = 16; maxw4 = 16;
@ -585,7 +585,7 @@ static int one_proc (struct pids_stack *p)
char perms[32]; char perms[32];
/* to clean up unprintables */ /* to clean up unprintables */
char *tmp; char *tmp;
unsigned KLONG end, start = 0;; unsigned long end, start = 0;;
unsigned long long file_offset, inode; unsigned long long file_offset, inode;
unsigned dev_major, dev_minor; unsigned dev_major, dev_minor;
unsigned long long smap_value; unsigned long long smap_value;
@ -689,7 +689,7 @@ static int one_proc (struct pids_stack *p)
const char *cp = const char *cp =
mapping_name(p, start, diff, mapbuf, map_desc_showpath, dev_major, mapping_name(p, start, diff, mapbuf, map_desc_showpath, dev_major,
dev_minor, inode); dev_minor, inode);
printf((sizeof(KLONG) == 8) printf((sizeof(long) == 8)
? "%016" KLF "x %6luK %s %s\n" ? "%016" KLF "x %6luK %s %s\n"
: "%08lx %6luK %s %s\n", : "%08lx %6luK %s %s\n",
start, (unsigned long)(diff >> 10), perms, cp); start, (unsigned long)(diff >> 10), perms, cp);
@ -699,7 +699,7 @@ static int one_proc (struct pids_stack *p)
fclose(fp); fclose(fp);
if (!q_option) { if (!q_option) {
if (x_option) { if (x_option) {
if (sizeof(KLONG) == 4) if (sizeof(long) == 4)
justify_print("--------", maxw1, 0); justify_print("--------", maxw1, 0);
else else
justify_print("----------------", maxw1, 0); justify_print("----------------", maxw1, 0);
@ -725,7 +725,7 @@ static int one_proc (struct pids_stack *p)
total_private_writeable >> 10, total_shared >> 10); total_private_writeable >> 10, total_shared >> 10);
} }
if (!x_option && !d_option) { if (!x_option && !d_option) {
if (sizeof(KLONG) == 8) if (sizeof(long) == 8)
/* Translation Hint: keep total string length /* Translation Hint: keep total string length
* as 24 characters. Adjust %16 if needed*/ * as 24 characters. Adjust %16 if needed*/
printf(_(" total %16ldK\n"), printf(_(" total %16ldK\n"),