diff options
| -rw-r--r-- | tools/perf/util/event.c | 23 | ||||
| -rw-r--r-- | tools/perf/util/event.h | 2 | ||||
| -rw-r--r-- | tools/perf/util/machine.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/map.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/map.h | 4 |
5 files changed, 32 insertions, 5 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 65795b835b39..ce43cbae3bd5 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
| 2 | #include <sys/mman.h> | ||
| 2 | #include "event.h" | 3 | #include "event.h" |
| 3 | #include "debug.h" | 4 | #include "debug.h" |
| 4 | #include "hist.h" | 5 | #include "hist.h" |
| @@ -212,6 +213,21 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
| 212 | else | 213 | else |
| 213 | event->header.misc = PERF_RECORD_MISC_GUEST_USER; | 214 | event->header.misc = PERF_RECORD_MISC_GUEST_USER; |
| 214 | 215 | ||
| 216 | /* map protection and flags bits */ | ||
| 217 | event->mmap2.prot = 0; | ||
| 218 | event->mmap2.flags = 0; | ||
| 219 | if (prot[0] == 'r') | ||
| 220 | event->mmap2.prot |= PROT_READ; | ||
| 221 | if (prot[1] == 'w') | ||
| 222 | event->mmap2.prot |= PROT_WRITE; | ||
| 223 | if (prot[2] == 'x') | ||
| 224 | event->mmap2.prot |= PROT_EXEC; | ||
| 225 | |||
| 226 | if (prot[3] == 's') | ||
| 227 | event->mmap2.flags |= MAP_SHARED; | ||
| 228 | else | ||
| 229 | event->mmap2.flags |= MAP_PRIVATE; | ||
| 230 | |||
| 215 | if (prot[2] != 'x') { | 231 | if (prot[2] != 'x') { |
| 216 | if (!mmap_data || prot[0] != 'r') | 232 | if (!mmap_data || prot[0] != 'r') |
| 217 | continue; | 233 | continue; |
| @@ -612,12 +628,15 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) | |||
| 612 | size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) | 628 | size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) |
| 613 | { | 629 | { |
| 614 | return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 | 630 | return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 |
| 615 | " %02x:%02x %"PRIu64" %"PRIu64"]: %c %s\n", | 631 | " %02x:%02x %"PRIu64" %"PRIu64"]: %c%c%c%c %s\n", |
| 616 | event->mmap2.pid, event->mmap2.tid, event->mmap2.start, | 632 | event->mmap2.pid, event->mmap2.tid, event->mmap2.start, |
| 617 | event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, | 633 | event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, |
| 618 | event->mmap2.min, event->mmap2.ino, | 634 | event->mmap2.min, event->mmap2.ino, |
| 619 | event->mmap2.ino_generation, | 635 | event->mmap2.ino_generation, |
| 620 | (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x', | 636 | (event->mmap2.prot & PROT_READ) ? 'r' : '-', |
| 637 | (event->mmap2.prot & PROT_WRITE) ? 'w' : '-', | ||
| 638 | (event->mmap2.prot & PROT_EXEC) ? 'x' : '-', | ||
| 639 | (event->mmap2.flags & MAP_SHARED) ? 's' : 'p', | ||
| 621 | event->mmap2.filename); | 640 | event->mmap2.filename); |
| 622 | } | 641 | } |
| 623 | 642 | ||
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index d970232cb270..9ba2eb3bdcfd 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
| @@ -27,6 +27,8 @@ struct mmap2_event { | |||
| 27 | u32 min; | 27 | u32 min; |
| 28 | u64 ino; | 28 | u64 ino; |
| 29 | u64 ino_generation; | 29 | u64 ino_generation; |
| 30 | u32 prot; | ||
| 31 | u32 flags; | ||
| 30 | char filename[PATH_MAX]; | 32 | char filename[PATH_MAX]; |
| 31 | }; | 33 | }; |
| 32 | 34 | ||
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 7409ac8de51c..0e5fea95d596 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
| @@ -1060,6 +1060,8 @@ int machine__process_mmap2_event(struct machine *machine, | |||
| 1060 | event->mmap2.pid, event->mmap2.maj, | 1060 | event->mmap2.pid, event->mmap2.maj, |
| 1061 | event->mmap2.min, event->mmap2.ino, | 1061 | event->mmap2.min, event->mmap2.ino, |
| 1062 | event->mmap2.ino_generation, | 1062 | event->mmap2.ino_generation, |
| 1063 | event->mmap2.prot, | ||
| 1064 | event->mmap2.flags, | ||
| 1063 | event->mmap2.filename, type); | 1065 | event->mmap2.filename, type); |
| 1064 | 1066 | ||
| 1065 | if (map == NULL) | 1067 | if (map == NULL) |
| @@ -1105,7 +1107,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event | |||
| 1105 | 1107 | ||
| 1106 | map = map__new(&machine->user_dsos, event->mmap.start, | 1108 | map = map__new(&machine->user_dsos, event->mmap.start, |
| 1107 | event->mmap.len, event->mmap.pgoff, | 1109 | event->mmap.len, event->mmap.pgoff, |
| 1108 | event->mmap.pid, 0, 0, 0, 0, | 1110 | event->mmap.pid, 0, 0, 0, 0, 0, 0, |
| 1109 | event->mmap.filename, | 1111 | event->mmap.filename, |
| 1110 | type); | 1112 | type); |
| 1111 | 1113 | ||
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 8ccbb32eda25..25c571f4cba6 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
| @@ -138,7 +138,7 @@ void map__init(struct map *map, enum map_type type, | |||
| 138 | 138 | ||
| 139 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | 139 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, |
| 140 | u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, | 140 | u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, |
| 141 | u64 ino_gen, char *filename, | 141 | u64 ino_gen, u32 prot, u32 flags, char *filename, |
| 142 | enum map_type type) | 142 | enum map_type type) |
| 143 | { | 143 | { |
| 144 | struct map *map = malloc(sizeof(*map)); | 144 | struct map *map = malloc(sizeof(*map)); |
| @@ -157,6 +157,8 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | |||
| 157 | map->min = d_min; | 157 | map->min = d_min; |
| 158 | map->ino = ino; | 158 | map->ino = ino; |
| 159 | map->ino_generation = ino_gen; | 159 | map->ino_generation = ino_gen; |
| 160 | map->prot = prot; | ||
| 161 | map->flags = flags; | ||
| 160 | 162 | ||
| 161 | if ((anon || no_dso) && type == MAP__FUNCTION) { | 163 | if ((anon || no_dso) && type == MAP__FUNCTION) { |
| 162 | snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid); | 164 | snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid); |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index ae2d45110588..7758c72522ef 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
| @@ -35,6 +35,8 @@ struct map { | |||
| 35 | bool referenced; | 35 | bool referenced; |
| 36 | bool erange_warned; | 36 | bool erange_warned; |
| 37 | u32 priv; | 37 | u32 priv; |
| 38 | u32 prot; | ||
| 39 | u32 flags; | ||
| 38 | u64 pgoff; | 40 | u64 pgoff; |
| 39 | u64 reloc; | 41 | u64 reloc; |
| 40 | u32 maj, min; /* only valid for MMAP2 record */ | 42 | u32 maj, min; /* only valid for MMAP2 record */ |
| @@ -118,7 +120,7 @@ void map__init(struct map *map, enum map_type type, | |||
| 118 | u64 start, u64 end, u64 pgoff, struct dso *dso); | 120 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
| 119 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, | 121 | struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, |
| 120 | u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, | 122 | u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, |
| 121 | u64 ino_gen, | 123 | u64 ino_gen, u32 prot, u32 flags, |
| 122 | char *filename, enum map_type type); | 124 | char *filename, enum map_type type); |
| 123 | struct map *map__new2(u64 start, struct dso *dso, enum map_type type); | 125 | struct map *map__new2(u64 start, struct dso *dso, enum map_type type); |
| 124 | void map__delete(struct map *map); | 126 | void map__delete(struct map *map); |
