summaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
authorAlexander Shishkin2010-08-28 23:20:34 +0200
committerDenys Vlasenko2010-08-28 23:20:34 +0200
commit0834a6d3b9daec1f460c3cc836136ace12c53df0 (patch)
tree5a1ff91bf23113224ee2a54334c020ff97e0f19a /include/libbb.h
parent74c992af5c6b8cfe6214e705bc04f8c2f9d8a304 (diff)
downloadbusybox-0834a6d3b9daec1f460c3cc836136ace12c53df0.zip
busybox-0834a6d3b9daec1f460c3cc836136ace12c53df0.tar.gz
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/libbb.h')
-rw-r--r--include/libbb.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 3fd7545..43e525c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -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