pmap: new applet. +1k.
pmap is a tool used to look at processes' memory maps, normally found in procps package. It provides more readable and easily sortable output (one line per mapping) from maps/smaps files in /proc/PID/. This would help in debugging memory usage issues, especially on devices where lots of typing is not a viable option. This patch does'n implement -d and -A command line options of GNU pmap, since those are not that must have features and I was afraid of going blind from looking at its code. The implementation takes smaps scanning part out of procps_scan() function and moves it into procps_read_smaps(), which does more detailed processing of a single PID's smaps data. Signed-off-by: Alexander Shishkin <virtuoso@slind.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
committed by
Denys Vlasenko
parent
74c992af5c
commit
0834a6d3b9
@ -1387,6 +1387,29 @@ enum { COMM_LEN = TASK_COMM_LEN };
|
||||
enum { COMM_LEN = 16 };
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct smaprec {
|
||||
unsigned long mapped_rw;
|
||||
unsigned long mapped_ro;
|
||||
unsigned long shared_clean;
|
||||
unsigned long shared_dirty;
|
||||
unsigned long private_clean;
|
||||
unsigned long private_dirty;
|
||||
unsigned long stack;
|
||||
unsigned long smap_pss, smap_swap;
|
||||
unsigned long smap_size;
|
||||
unsigned long smap_start;
|
||||
char smap_mode[5];
|
||||
char *smap_name;
|
||||
};
|
||||
|
||||
#if !ENABLE_PMAP
|
||||
#define procps_read_smaps(pid, total, cb, data) \
|
||||
procps_read_smaps(pid, total)
|
||||
#endif
|
||||
int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
|
||||
void (*cb)(struct smaprec *, void *), void *data);
|
||||
|
||||
typedef struct procps_status_t {
|
||||
DIR *dir;
|
||||
IF_FEATURE_SHOW_THREADS(DIR *task_dir;)
|
||||
@ -1415,13 +1438,7 @@ typedef struct procps_status_t {
|
||||
#endif
|
||||
unsigned tty_major,tty_minor;
|
||||
#if ENABLE_FEATURE_TOPMEM
|
||||
unsigned long mapped_rw;
|
||||
unsigned long mapped_ro;
|
||||
unsigned long shared_clean;
|
||||
unsigned long shared_dirty;
|
||||
unsigned long private_clean;
|
||||
unsigned long private_dirty;
|
||||
unsigned long stack;
|
||||
struct smaprec smaps;
|
||||
#endif
|
||||
char state[4];
|
||||
/* basename of executable in exec(2), read from /proc/N/stat
|
||||
|
Reference in New Issue
Block a user