aboutsummaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
authorAlexander Shishkin <virtuoso@slind.org>2010-08-28 23:20:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-28 23:20:34 +0200
commit0834a6d3b9daec1f460c3cc836136ace12c53df0 (patch)
tree5a1ff91bf23113224ee2a54334c020ff97e0f19a /procps/top.c
parent74c992af5c6b8cfe6214e705bc04f8c2f9d8a304 (diff)
downloadbusybox-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 'procps/top.c')
-rw-r--r--procps/top.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/procps/top.c b/procps/top.c
index fd758099e..4f37878de 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -942,20 +942,20 @@ int top_main(int argc UNUSED_PARAM, char **argv)
942 } 942 }
943#if ENABLE_FEATURE_TOPMEM 943#if ENABLE_FEATURE_TOPMEM
944 else { /* TOPMEM */ 944 else { /* TOPMEM */
945 if (!(p->mapped_ro | p->mapped_rw)) 945 if (!(p->smaps.mapped_ro | p->smaps.mapped_rw))
946 continue; /* kernel threads are ignored */ 946 continue; /* kernel threads are ignored */
947 n = ntop; 947 n = ntop;
948 /* No bug here - top and topmem are the same */ 948 /* No bug here - top and topmem are the same */
949 top = xrealloc_vector(topmem, 6, ntop++); 949 top = xrealloc_vector(topmem, 6, ntop++);
950 strcpy(topmem[n].comm, p->comm); 950 strcpy(topmem[n].comm, p->comm);
951 topmem[n].pid = p->pid; 951 topmem[n].pid = p->pid;
952 topmem[n].vsz = p->mapped_rw + p->mapped_ro; 952 topmem[n].vsz = p->smaps.mapped_rw + p->smaps.mapped_ro;
953 topmem[n].vszrw = p->mapped_rw; 953 topmem[n].vszrw = p->smaps.mapped_rw;
954 topmem[n].rss_sh = p->shared_clean + p->shared_dirty; 954 topmem[n].rss_sh = p->smaps.shared_clean + p->smaps.shared_dirty;
955 topmem[n].rss = p->private_clean + p->private_dirty + topmem[n].rss_sh; 955 topmem[n].rss = p->smaps.private_clean + p->smaps.private_dirty + topmem[n].rss_sh;
956 topmem[n].dirty = p->private_dirty + p->shared_dirty; 956 topmem[n].dirty = p->smaps.private_dirty + p->smaps.shared_dirty;
957 topmem[n].dirty_sh = p->shared_dirty; 957 topmem[n].dirty_sh = p->smaps.shared_dirty;
958 topmem[n].stack = p->stack; 958 topmem[n].stack = p->smaps.stack;
959 } 959 }
960#endif 960#endif
961 } /* end of "while we read /proc" */ 961 } /* end of "while we read /proc" */