aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c64
1 files changed, 52 insertions, 12 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index efdb38e65a92..b2ecad6ec46b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -955,6 +955,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
955 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 955 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
956 struct thread *thread; 956 struct thread *thread;
957 struct map *map; 957 struct map *map;
958 enum map_type type;
958 int ret = 0; 959 int ret = 0;
959 960
960 if (dump_trace) 961 if (dump_trace)
@@ -971,10 +972,17 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
971 thread = machine__findnew_thread(machine, event->mmap.pid); 972 thread = machine__findnew_thread(machine, event->mmap.pid);
972 if (thread == NULL) 973 if (thread == NULL)
973 goto out_problem; 974 goto out_problem;
975
976 if (event->header.misc & PERF_RECORD_MISC_MMAP_DATA)
977 type = MAP__VARIABLE;
978 else
979 type = MAP__FUNCTION;
980
974 map = map__new(&machine->user_dsos, event->mmap.start, 981 map = map__new(&machine->user_dsos, event->mmap.start,
975 event->mmap.len, event->mmap.pgoff, 982 event->mmap.len, event->mmap.pgoff,
976 event->mmap.pid, event->mmap.filename, 983 event->mmap.pid, event->mmap.filename,
977 MAP__FUNCTION); 984 type);
985
978 if (map == NULL) 986 if (map == NULL)
979 goto out_problem; 987 goto out_problem;
980 988
@@ -1003,6 +1011,17 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
1003 return 0; 1011 return 0;
1004} 1012}
1005 1013
1014static void machine__remove_thread(struct machine *machine, struct thread *th)
1015{
1016 machine->last_match = NULL;
1017 rb_erase(&th->rb_node, &machine->threads);
1018 /*
1019 * We may have references to this thread, for instance in some hist_entry
1020 * instances, so just move them to a separate list.
1021 */
1022 list_add_tail(&th->node, &machine->dead_threads);
1023}
1024
1006int machine__process_exit_event(struct machine *machine, union perf_event *event) 1025int machine__process_exit_event(struct machine *machine, union perf_event *event)
1007{ 1026{
1008 struct thread *thread = machine__find_thread(machine, event->fork.tid); 1027 struct thread *thread = machine__find_thread(machine, event->fork.tid);
@@ -1039,17 +1058,6 @@ int machine__process_event(struct machine *machine, union perf_event *event)
1039 return ret; 1058 return ret;
1040} 1059}
1041 1060
1042void machine__remove_thread(struct machine *machine, struct thread *th)
1043{
1044 machine->last_match = NULL;
1045 rb_erase(&th->rb_node, &machine->threads);
1046 /*
1047 * We may have references to this thread, for instance in some hist_entry
1048 * instances, so just move them to a separate list.
1049 */
1050 list_add_tail(&th->node, &machine->dead_threads);
1051}
1052
1053static bool symbol__match_parent_regex(struct symbol *sym) 1061static bool symbol__match_parent_regex(struct symbol *sym)
1054{ 1062{
1055 if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0)) 1063 if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
@@ -1097,6 +1105,38 @@ found:
1097 ams->map = al.map; 1105 ams->map = al.map;
1098} 1106}
1099 1107
1108static void ip__resolve_data(struct machine *machine, struct thread *thread,
1109 u8 m, struct addr_map_symbol *ams, u64 addr)
1110{
1111 struct addr_location al;
1112
1113 memset(&al, 0, sizeof(al));
1114
1115 thread__find_addr_location(thread, machine, m, MAP__VARIABLE, addr, &al,
1116 NULL);
1117 ams->addr = addr;
1118 ams->al_addr = al.addr;
1119 ams->sym = al.sym;
1120 ams->map = al.map;
1121}
1122
1123struct mem_info *machine__resolve_mem(struct machine *machine,
1124 struct thread *thr,
1125 struct perf_sample *sample,
1126 u8 cpumode)
1127{
1128 struct mem_info *mi = zalloc(sizeof(*mi));
1129
1130 if (!mi)
1131 return NULL;
1132
1133 ip__resolve_ams(machine, thr, &mi->iaddr, sample->ip);
1134 ip__resolve_data(machine, thr, cpumode, &mi->daddr, sample->addr);
1135 mi->data_src.val = sample->data_src;
1136
1137 return mi;
1138}
1139
1100struct branch_info *machine__resolve_bstack(struct machine *machine, 1140struct branch_info *machine__resolve_bstack(struct machine *machine,
1101 struct thread *thr, 1141 struct thread *thr,
1102 struct branch_stack *bs) 1142 struct branch_stack *bs)