diff options
author | Suren Baghdasaryan <surenb@google.com> | 2019-10-09 16:18:04 -0700 |
---|---|---|
committer | Suren Baghdasaryan <surenb@google.com> | 2019-10-09 16:18:18 -0700 |
commit | e8f1468b14b38b7968b38823e4760ffd7ce057c3 (patch) | |
tree | 77fa5e507479b3494357f897a35814024c0d016a | |
parent | 11dc734a06bd189de8cb6bccf4efd636fad68313 (diff) |
libmeminfo: Report VMA flags in showmap report
Add VMA flags into showmap report so that we can distinguish different
sections of an executable or a library.
Bug: 138148041
Test: showmap -v <PID>
Change-Id: Ic1a13accbea447548c75a0c54d750280e40c6de8
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
-rw-r--r-- | libmeminfo/tools/showmap.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libmeminfo/tools/showmap.cpp b/libmeminfo/tools/showmap.cpp index 8ea21085e..72ab0f390 100644 --- a/libmeminfo/tools/showmap.cpp +++ b/libmeminfo/tools/showmap.cpp @@ -18,6 +18,7 @@ #include <inttypes.h> #include <stdio.h> #include <stdlib.h> +#include <sys/mman.h> #include <sys/signal.h> #include <sys/types.h> #include <unistd.h> @@ -139,6 +140,9 @@ static void print_header() { if (!g_verbose && !g_show_addr) { printf(" # "); } + if (g_verbose) { + printf(" flags "); + } printf(" object\n"); } @@ -150,6 +154,9 @@ static void print_divider() { if (!g_verbose && !g_show_addr) { printf("---- "); } + if (g_verbose) { + printf("------ "); + } printf("------------------------------\n"); } @@ -169,6 +176,18 @@ static void print_vmainfo(const VmaInfo& v, bool total) { if (!g_verbose && !g_show_addr) { printf("%4" PRIu32 " ", v.count); } + if (g_verbose) { + if (total) { + printf(" "); + } else { + std::string flags_str("---"); + if (v.vma.flags & PROT_READ) flags_str[0] = 'r'; + if (v.vma.flags & PROT_WRITE) flags_str[1] = 'w'; + if (v.vma.flags & PROT_EXEC) flags_str[2] = 'x'; + + printf("%6s ", flags_str.c_str()); + } + } } static int showmap(void) { |