diff options
author | Alexander Shishkin <virtuoso@slind.org> | 2010-08-28 23:20:34 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-28 23:20:34 +0200 |
commit | 0834a6d3b9daec1f460c3cc836136ace12c53df0 (patch) | |
tree | 5a1ff91bf23113224ee2a54334c020ff97e0f19a /include | |
parent | 74c992af5c6b8cfe6214e705bc04f8c2f9d8a304 (diff) | |
download | busybox-w32-0834a6d3b9daec1f460c3cc836136ace12c53df0.tar.gz busybox-w32-0834a6d3b9daec1f460c3cc836136ace12c53df0.tar.bz2 busybox-w32-0834a6d3b9daec1f460c3cc836136ace12c53df0.zip |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/include/libbb.h b/include/libbb.h index 3fd754511..43e525cb9 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1387,6 +1387,29 @@ enum { COMM_LEN = TASK_COMM_LEN }; | |||
1387 | enum { COMM_LEN = 16 }; | 1387 | enum { COMM_LEN = 16 }; |
1388 | # endif | 1388 | # endif |
1389 | #endif | 1389 | #endif |
1390 | |||
1391 | struct smaprec { | ||
1392 | unsigned long mapped_rw; | ||
1393 | unsigned long mapped_ro; | ||
1394 | unsigned long shared_clean; | ||
1395 | unsigned long shared_dirty; | ||
1396 | unsigned long private_clean; | ||
1397 | unsigned long private_dirty; | ||
1398 | unsigned long stack; | ||
1399 | unsigned long smap_pss, smap_swap; | ||
1400 | unsigned long smap_size; | ||
1401 | unsigned long smap_start; | ||
1402 | char smap_mode[5]; | ||
1403 | char *smap_name; | ||
1404 | }; | ||
1405 | |||
1406 | #if !ENABLE_PMAP | ||
1407 | #define procps_read_smaps(pid, total, cb, data) \ | ||
1408 | procps_read_smaps(pid, total) | ||
1409 | #endif | ||
1410 | int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, | ||
1411 | void (*cb)(struct smaprec *, void *), void *data); | ||
1412 | |||
1390 | typedef struct procps_status_t { | 1413 | typedef struct procps_status_t { |
1391 | DIR *dir; | 1414 | DIR *dir; |
1392 | IF_FEATURE_SHOW_THREADS(DIR *task_dir;) | 1415 | IF_FEATURE_SHOW_THREADS(DIR *task_dir;) |
@@ -1415,13 +1438,7 @@ typedef struct procps_status_t { | |||
1415 | #endif | 1438 | #endif |
1416 | unsigned tty_major,tty_minor; | 1439 | unsigned tty_major,tty_minor; |
1417 | #if ENABLE_FEATURE_TOPMEM | 1440 | #if ENABLE_FEATURE_TOPMEM |
1418 | unsigned long mapped_rw; | 1441 | struct smaprec smaps; |
1419 | unsigned long mapped_ro; | ||
1420 | unsigned long shared_clean; | ||
1421 | unsigned long shared_dirty; | ||
1422 | unsigned long private_clean; | ||
1423 | unsigned long private_dirty; | ||
1424 | unsigned long stack; | ||
1425 | #endif | 1442 | #endif |
1426 | char state[4]; | 1443 | char state[4]; |
1427 | /* basename of executable in exec(2), read from /proc/N/stat | 1444 | /* basename of executable in exec(2), read from /proc/N/stat |