diff options
author | Colin Cross <ccross@android.com> | 2013-05-23 12:38:54 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2013-06-24 14:56:58 -0700 |
commit | 4ed62f58bc02eca9b6470112f17d2f82c46d6676 (patch) | |
tree | 3ca47f16cdc10cdca676b7e5bdaea1f4ca7d6a3f | |
parent | e6ef997fe214e8daefbaff45ecbfefdad187c25c (diff) | |
download | extras-4ed62f58bc02eca9b6470112f17d2f82c46d6676.tar.gz |
librank: add command line argument to show all mappings
Add -a command line argument to show all mappings, including
anonymous, stack, and heap mappings.
Change-Id: I7d80e2b4f5d880d434f57e1e7a37678917cd7407
-rw-r--r-- | librank/librank.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/librank/librank.c b/librank/librank.c index ef115b13..fac42ed0 100644 --- a/librank/librank.c +++ b/librank/librank.c @@ -18,6 +18,7 @@ #include <dirent.h> #include <errno.h> #include <getopt.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -70,13 +71,19 @@ struct library_info **libraries; int libraries_count; int libraries_size; -struct library_info *get_library(char *name) { +struct library_info *get_library(const char *name, bool all) { int i; struct library_info *library; - for (i = 0; library_name_blacklist[i]; i++) - if (!strcmp(name, library_name_blacklist[i])) - return NULL; + if (!all) { + for (i = 0; library_name_blacklist[i]; i++) + if (!strcmp(name, library_name_blacklist[i])) + return NULL; + } else { + if (name[0] == 0) { + name = "[anon]"; + } + } for (i = 0; i < libraries_count; i++) { if (!strcmp(libraries[i]->name, name)) @@ -209,6 +216,7 @@ int main(int argc, char *argv[]) { int i, j, error; int perm; + bool all; signal(SIGPIPE, SIG_IGN); compfn = &sort_by_pss; @@ -217,10 +225,12 @@ int main(int argc, char *argv[]) { prefix_len = 0; opterr = 0; perm = 0; + all = false; while (1) { int c; const struct option longopts[] = { + {"all", 0, 0, 'a'}, {"help", 0, 0, 'h'}, {"pss", 0, 0, 'p'}, {"uss", 0, 0, 'u'}, @@ -231,12 +241,15 @@ int main(int argc, char *argv[]) { {"perm", required_argument, 0, 'm'}, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hm:pP:uvrR", longopts, NULL); + c = getopt_long(argc, argv, "ahm:pP:uvrR", longopts, NULL); if (c < 0) { break; } /* Alphabetical cases */ switch (c) { + case 'a': + all = true; + break; case 'h': usage(argv[0]); exit(EXIT_SUCCESS); @@ -312,7 +325,7 @@ int main(int argc, char *argv[]) { if (perm && (pm_map_flags(maps[j]) & PM_MAP_PERMISSIONS) != perm) continue; - li = get_library(pm_map_name(maps[j])); + li = get_library(pm_map_name(maps[j]), all); if (!li) continue; @@ -370,6 +383,7 @@ static void usage(char *myname) { " -p Sort processes by PSS.\n" " -u Sort processes by USS.\n" " (Default sort order is PSS.)\n" + " -a Show all mappings, including stack, heap and anon.\n" " -P /path Limit libraries displayed to those in path.\n" " -R Reverse sort order (default is descending).\n" " -m [r][w][x] Only list pages that exactly match permissions\n" |