Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 1 | #include <linux/types.h> |
| 2 | #include "event.h" |
| 3 | #include "debug.h" |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 4 | #include "session.h" |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 5 | #include "sort.h" |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 6 | #include "string.h" |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 7 | #include "strlist.h" |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 8 | #include "thread.h" |
Arnaldo Carvalho de Melo | 7c940c1 | 2011-02-11 11:45:54 -0200 | [diff] [blame] | 9 | #include "thread_map.h" |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 10 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 11 | static const char *perf_event__names[] = { |
Frederic Weisbecker | 3cb6d15 | 2011-05-23 13:06:27 +0200 | [diff] [blame^] | 12 | [0] = "TOTAL", |
| 13 | [PERF_RECORD_MMAP] = "MMAP", |
| 14 | [PERF_RECORD_LOST] = "LOST", |
| 15 | [PERF_RECORD_COMM] = "COMM", |
| 16 | [PERF_RECORD_EXIT] = "EXIT", |
| 17 | [PERF_RECORD_THROTTLE] = "THROTTLE", |
| 18 | [PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE", |
| 19 | [PERF_RECORD_FORK] = "FORK", |
| 20 | [PERF_RECORD_READ] = "READ", |
| 21 | [PERF_RECORD_SAMPLE] = "SAMPLE", |
| 22 | [PERF_RECORD_HEADER_ATTR] = "ATTR", |
| 23 | [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE", |
| 24 | [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA", |
| 25 | [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID", |
| 26 | [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND", |
Arnaldo Carvalho de Melo | c8446b9 | 2010-05-14 10:36:42 -0300 | [diff] [blame] | 27 | }; |
| 28 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 29 | const char *perf_event__name(unsigned int id) |
Thomas Gleixner | 3835bc0 | 2010-12-07 12:48:42 +0000 | [diff] [blame] | 30 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 31 | if (id >= ARRAY_SIZE(perf_event__names)) |
Thomas Gleixner | 3835bc0 | 2010-12-07 12:48:42 +0000 | [diff] [blame] | 32 | return "INVALID"; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 33 | if (!perf_event__names[id]) |
Thomas Gleixner | 3835bc0 | 2010-12-07 12:48:42 +0000 | [diff] [blame] | 34 | return "UNKNOWN"; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 35 | return perf_event__names[id]; |
Thomas Gleixner | 3835bc0 | 2010-12-07 12:48:42 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 38 | int perf_sample_size(u64 sample_type) |
| 39 | { |
| 40 | u64 mask = sample_type & PERF_SAMPLE_MASK; |
| 41 | int size = 0; |
| 42 | int i; |
| 43 | |
| 44 | for (i = 0; i < 64; i++) { |
Frederic Weisbecker | 3cb6d15 | 2011-05-23 13:06:27 +0200 | [diff] [blame^] | 45 | if (mask & (1UL << i)) |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 46 | size++; |
| 47 | } |
| 48 | |
| 49 | size *= sizeof(u64); |
| 50 | |
| 51 | return size; |
| 52 | } |
| 53 | |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 54 | static struct perf_sample synth_sample = { |
Arnaldo Carvalho de Melo | 640c03c | 2010-12-02 14:10:21 -0200 | [diff] [blame] | 55 | .pid = -1, |
| 56 | .tid = -1, |
| 57 | .time = -1, |
| 58 | .stream_id = -1, |
| 59 | .cpu = -1, |
| 60 | .period = 1, |
| 61 | }; |
| 62 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 63 | static pid_t perf_event__synthesize_comm(union perf_event *event, pid_t pid, |
| 64 | int full, perf_event__handler_t process, |
| 65 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 66 | { |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 67 | char filename[PATH_MAX]; |
| 68 | char bf[BUFSIZ]; |
| 69 | FILE *fp; |
| 70 | size_t size = 0; |
| 71 | DIR *tasks; |
| 72 | struct dirent dirent, *next; |
| 73 | pid_t tgid = 0; |
| 74 | |
| 75 | snprintf(filename, sizeof(filename), "/proc/%d/status", pid); |
| 76 | |
| 77 | fp = fopen(filename, "r"); |
| 78 | if (fp == NULL) { |
| 79 | out_race: |
| 80 | /* |
| 81 | * We raced with a task exiting - just return: |
| 82 | */ |
| 83 | pr_debug("couldn't open %s\n", filename); |
| 84 | return 0; |
| 85 | } |
| 86 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 87 | memset(&event->comm, 0, sizeof(event->comm)); |
| 88 | |
| 89 | while (!event->comm.comm[0] || !event->comm.pid) { |
| 90 | if (fgets(bf, sizeof(bf), fp) == NULL) { |
| 91 | pr_warning("couldn't get COMM and pgid, malformed %s\n", filename); |
| 92 | goto out; |
| 93 | } |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 94 | |
| 95 | if (memcmp(bf, "Name:", 5) == 0) { |
| 96 | char *name = bf + 5; |
| 97 | while (*name && isspace(*name)) |
| 98 | ++name; |
| 99 | size = strlen(name) - 1; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 100 | memcpy(event->comm.comm, name, size++); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 101 | } else if (memcmp(bf, "Tgid:", 5) == 0) { |
| 102 | char *tgids = bf + 5; |
| 103 | while (*tgids && isspace(*tgids)) |
| 104 | ++tgids; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 105 | tgid = event->comm.pid = atoi(tgids); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 109 | event->comm.header.type = PERF_RECORD_COMM; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 110 | size = ALIGN(size, sizeof(u64)); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 111 | memset(event->comm.comm + size, 0, session->id_hdr_size); |
| 112 | event->comm.header.size = (sizeof(event->comm) - |
| 113 | (sizeof(event->comm.comm) - size) + |
| 114 | session->id_hdr_size); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 115 | if (!full) { |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 116 | event->comm.tid = pid; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 117 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 118 | process(event, &synth_sample, session); |
| 119 | goto out; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | snprintf(filename, sizeof(filename), "/proc/%d/task", pid); |
| 123 | |
| 124 | tasks = opendir(filename); |
| 125 | if (tasks == NULL) |
| 126 | goto out_race; |
| 127 | |
| 128 | while (!readdir_r(tasks, &dirent, &next) && next) { |
| 129 | char *end; |
| 130 | pid = strtol(dirent.d_name, &end, 10); |
| 131 | if (*end) |
| 132 | continue; |
| 133 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 134 | event->comm.tid = pid; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 135 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 136 | process(event, &synth_sample, session); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 137 | } |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 138 | |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 139 | closedir(tasks); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 140 | out: |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 141 | fclose(fp); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 142 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 143 | return tgid; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 144 | } |
| 145 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 146 | static int perf_event__synthesize_mmap_events(union perf_event *event, |
| 147 | pid_t pid, pid_t tgid, |
| 148 | perf_event__handler_t process, |
| 149 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 150 | { |
| 151 | char filename[PATH_MAX]; |
| 152 | FILE *fp; |
| 153 | |
| 154 | snprintf(filename, sizeof(filename), "/proc/%d/maps", pid); |
| 155 | |
| 156 | fp = fopen(filename, "r"); |
| 157 | if (fp == NULL) { |
| 158 | /* |
| 159 | * We raced with a task exiting - just return: |
| 160 | */ |
| 161 | pr_debug("couldn't open %s\n", filename); |
| 162 | return -1; |
| 163 | } |
| 164 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 165 | event->header.type = PERF_RECORD_MMAP; |
| 166 | /* |
| 167 | * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c |
| 168 | */ |
| 169 | event->header.misc = PERF_RECORD_MISC_USER; |
| 170 | |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 171 | while (1) { |
| 172 | char bf[BUFSIZ], *pbf = bf; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 173 | int n; |
| 174 | size_t size; |
| 175 | if (fgets(bf, sizeof(bf), fp) == NULL) |
| 176 | break; |
| 177 | |
| 178 | /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 179 | n = hex2u64(pbf, &event->mmap.start); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 180 | if (n < 0) |
| 181 | continue; |
| 182 | pbf += n + 1; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 183 | n = hex2u64(pbf, &event->mmap.len); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 184 | if (n < 0) |
| 185 | continue; |
| 186 | pbf += n + 3; |
| 187 | if (*pbf == 'x') { /* vm_exec */ |
| 188 | char *execname = strchr(bf, '/'); |
| 189 | |
| 190 | /* Catch VDSO */ |
| 191 | if (execname == NULL) |
| 192 | execname = strstr(bf, "[vdso]"); |
| 193 | |
| 194 | if (execname == NULL) |
| 195 | continue; |
| 196 | |
Anton Blanchard | 4af8b35 | 2010-04-03 22:53:31 +1100 | [diff] [blame] | 197 | pbf += 3; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 198 | n = hex2u64(pbf, &event->mmap.pgoff); |
Anton Blanchard | 4af8b35 | 2010-04-03 22:53:31 +1100 | [diff] [blame] | 199 | |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 200 | size = strlen(execname); |
| 201 | execname[size - 1] = '\0'; /* Remove \n */ |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 202 | memcpy(event->mmap.filename, execname, size); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 203 | size = ALIGN(size, sizeof(u64)); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 204 | event->mmap.len -= event->mmap.start; |
| 205 | event->mmap.header.size = (sizeof(event->mmap) - |
| 206 | (sizeof(event->mmap.filename) - size)); |
| 207 | memset(event->mmap.filename + size, 0, session->id_hdr_size); |
| 208 | event->mmap.header.size += session->id_hdr_size; |
| 209 | event->mmap.pid = tgid; |
| 210 | event->mmap.tid = pid; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 211 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 212 | process(event, &synth_sample, session); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
| 216 | fclose(fp); |
| 217 | return 0; |
| 218 | } |
| 219 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 220 | int perf_event__synthesize_modules(perf_event__handler_t process, |
| 221 | struct perf_session *session, |
| 222 | struct machine *machine) |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 223 | { |
| 224 | struct rb_node *nd; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 225 | struct map_groups *kmaps = &machine->kmaps; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 226 | union perf_event *event = zalloc((sizeof(event->mmap) + |
| 227 | session->id_hdr_size)); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 228 | if (event == NULL) { |
| 229 | pr_debug("Not enough memory synthesizing mmap event " |
| 230 | "for kernel modules\n"); |
| 231 | return -1; |
| 232 | } |
| 233 | |
| 234 | event->header.type = PERF_RECORD_MMAP; |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 235 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 236 | /* |
| 237 | * kernel uses 0 for user space maps, see kernel/perf_event.c |
| 238 | * __perf_event_mmap |
| 239 | */ |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 240 | if (machine__is_host(machine)) |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 241 | event->header.misc = PERF_RECORD_MISC_KERNEL; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 242 | else |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 243 | event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 244 | |
| 245 | for (nd = rb_first(&kmaps->maps[MAP__FUNCTION]); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 246 | nd; nd = rb_next(nd)) { |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 247 | size_t size; |
| 248 | struct map *pos = rb_entry(nd, struct map, rb_node); |
| 249 | |
| 250 | if (pos->dso->kernel) |
| 251 | continue; |
| 252 | |
| 253 | size = ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 254 | event->mmap.header.type = PERF_RECORD_MMAP; |
| 255 | event->mmap.header.size = (sizeof(event->mmap) - |
| 256 | (sizeof(event->mmap.filename) - size)); |
| 257 | memset(event->mmap.filename + size, 0, session->id_hdr_size); |
| 258 | event->mmap.header.size += session->id_hdr_size; |
| 259 | event->mmap.start = pos->start; |
| 260 | event->mmap.len = pos->end - pos->start; |
| 261 | event->mmap.pid = machine->pid; |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 262 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 263 | memcpy(event->mmap.filename, pos->dso->long_name, |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 264 | pos->dso->long_name_len + 1); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 265 | process(event, &synth_sample, session); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 266 | } |
| 267 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 268 | free(event); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 269 | return 0; |
| 270 | } |
| 271 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 272 | static int __event__synthesize_thread(union perf_event *comm_event, |
| 273 | union perf_event *mmap_event, |
| 274 | pid_t pid, perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 275 | struct perf_session *session) |
| 276 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 277 | pid_t tgid = perf_event__synthesize_comm(comm_event, pid, 1, process, |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 278 | session); |
| 279 | if (tgid == -1) |
| 280 | return -1; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 281 | return perf_event__synthesize_mmap_events(mmap_event, pid, tgid, |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 282 | process, session); |
| 283 | } |
| 284 | |
Arnaldo Carvalho de Melo | 7c940c1 | 2011-02-11 11:45:54 -0200 | [diff] [blame] | 285 | int perf_event__synthesize_thread_map(struct thread_map *threads, |
| 286 | perf_event__handler_t process, |
| 287 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 288 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 289 | union perf_event *comm_event, *mmap_event; |
Arnaldo Carvalho de Melo | 401b8e1 | 2011-02-10 12:52:47 -0200 | [diff] [blame] | 290 | int err = -1, thread; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 291 | |
| 292 | comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); |
| 293 | if (comm_event == NULL) |
| 294 | goto out; |
| 295 | |
| 296 | mmap_event = malloc(sizeof(mmap_event->mmap) + session->id_hdr_size); |
| 297 | if (mmap_event == NULL) |
| 298 | goto out_free_comm; |
| 299 | |
Arnaldo Carvalho de Melo | 401b8e1 | 2011-02-10 12:52:47 -0200 | [diff] [blame] | 300 | err = 0; |
| 301 | for (thread = 0; thread < threads->nr; ++thread) { |
| 302 | if (__event__synthesize_thread(comm_event, mmap_event, |
| 303 | threads->map[thread], |
| 304 | process, session)) { |
| 305 | err = -1; |
| 306 | break; |
| 307 | } |
| 308 | } |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 309 | free(mmap_event); |
| 310 | out_free_comm: |
| 311 | free(comm_event); |
| 312 | out: |
| 313 | return err; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 314 | } |
| 315 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 316 | int perf_event__synthesize_threads(perf_event__handler_t process, |
| 317 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 318 | { |
| 319 | DIR *proc; |
| 320 | struct dirent dirent, *next; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 321 | union perf_event *comm_event, *mmap_event; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 322 | int err = -1; |
| 323 | |
| 324 | comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); |
| 325 | if (comm_event == NULL) |
| 326 | goto out; |
| 327 | |
| 328 | mmap_event = malloc(sizeof(mmap_event->mmap) + session->id_hdr_size); |
| 329 | if (mmap_event == NULL) |
| 330 | goto out_free_comm; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 331 | |
| 332 | proc = opendir("/proc"); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 333 | if (proc == NULL) |
| 334 | goto out_free_mmap; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 335 | |
| 336 | while (!readdir_r(proc, &dirent, &next) && next) { |
| 337 | char *end; |
| 338 | pid_t pid = strtol(dirent.d_name, &end, 10); |
| 339 | |
| 340 | if (*end) /* only interested in proper numerical dirents */ |
| 341 | continue; |
| 342 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 343 | __event__synthesize_thread(comm_event, mmap_event, pid, |
| 344 | process, session); |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | closedir(proc); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 348 | err = 0; |
| 349 | out_free_mmap: |
| 350 | free(mmap_event); |
| 351 | out_free_comm: |
| 352 | free(comm_event); |
| 353 | out: |
| 354 | return err; |
Arnaldo Carvalho de Melo | 234fbbf | 2009-10-26 19:23:18 -0200 | [diff] [blame] | 355 | } |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 356 | |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 357 | struct process_symbol_args { |
| 358 | const char *name; |
| 359 | u64 start; |
| 360 | }; |
| 361 | |
Arnaldo Carvalho de Melo | 3b01a41 | 2010-12-22 01:08:36 -0200 | [diff] [blame] | 362 | static int find_symbol_cb(void *arg, const char *name, char type, |
| 363 | u64 start, u64 end __used) |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 364 | { |
| 365 | struct process_symbol_args *args = arg; |
| 366 | |
Arnaldo Carvalho de Melo | 881516e | 2010-01-15 18:08:27 -0200 | [diff] [blame] | 367 | /* |
| 368 | * Must be a function or at least an alias, as in PARISC64, where "_text" is |
| 369 | * an 'A' to the same address as "_stext". |
| 370 | */ |
| 371 | if (!(symbol_type__is_a(type, MAP__FUNCTION) || |
| 372 | type == 'A') || strcmp(name, args->name)) |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 373 | return 0; |
| 374 | |
| 375 | args->start = start; |
| 376 | return 1; |
| 377 | } |
| 378 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 379 | int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, |
| 380 | struct perf_session *session, |
| 381 | struct machine *machine, |
| 382 | const char *symbol_name) |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 383 | { |
| 384 | size_t size; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 385 | const char *filename, *mmap_name; |
| 386 | char path[PATH_MAX]; |
| 387 | char name_buff[PATH_MAX]; |
| 388 | struct map *map; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 389 | int err; |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 390 | /* |
| 391 | * We should get this from /sys/kernel/sections/.text, but till that is |
| 392 | * available use this, and after it is use this as a fallback for older |
| 393 | * kernels. |
| 394 | */ |
| 395 | struct process_symbol_args args = { .name = symbol_name, }; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 396 | union perf_event *event = zalloc((sizeof(event->mmap) + |
| 397 | session->id_hdr_size)); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 398 | if (event == NULL) { |
| 399 | pr_debug("Not enough memory synthesizing mmap event " |
| 400 | "for kernel modules\n"); |
| 401 | return -1; |
| 402 | } |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 403 | |
Arnaldo Carvalho de Melo | 48ea8f5 | 2010-04-27 21:19:05 -0300 | [diff] [blame] | 404 | mmap_name = machine__mmap_name(machine, name_buff, sizeof(name_buff)); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 405 | if (machine__is_host(machine)) { |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 406 | /* |
| 407 | * kernel uses PERF_RECORD_MISC_USER for user space maps, |
| 408 | * see kernel/perf_event.c __perf_event_mmap |
| 409 | */ |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 410 | event->header.misc = PERF_RECORD_MISC_KERNEL; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 411 | filename = "/proc/kallsyms"; |
| 412 | } else { |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 413 | event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 414 | if (machine__is_default_guest(machine)) |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 415 | filename = (char *) symbol_conf.default_guest_kallsyms; |
| 416 | else { |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 417 | sprintf(path, "%s/proc/kallsyms", machine->root_dir); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 418 | filename = path; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | if (kallsyms__parse(filename, &args, find_symbol_cb) <= 0) |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 423 | return -ENOENT; |
| 424 | |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 425 | map = machine->vmlinux_maps[MAP__FUNCTION]; |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 426 | size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 427 | "%s%s", mmap_name, symbol_name) + 1; |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 428 | size = ALIGN(size, sizeof(u64)); |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 429 | event->mmap.header.type = PERF_RECORD_MMAP; |
| 430 | event->mmap.header.size = (sizeof(event->mmap) - |
| 431 | (sizeof(event->mmap.filename) - size) + session->id_hdr_size); |
| 432 | event->mmap.pgoff = args.start; |
| 433 | event->mmap.start = map->start; |
| 434 | event->mmap.len = map->end - event->mmap.start; |
| 435 | event->mmap.pid = machine->pid; |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 436 | |
Arnaldo Carvalho de Melo | 9c90a61 | 2010-12-02 10:25:28 -0200 | [diff] [blame] | 437 | err = process(event, &synth_sample, session); |
| 438 | free(event); |
| 439 | |
| 440 | return err; |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 441 | } |
| 442 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 443 | int perf_event__process_comm(union perf_event *event, |
| 444 | struct perf_sample *sample __used, |
| 445 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 446 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 447 | struct thread *thread = perf_session__findnew(session, event->comm.tid); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 448 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 449 | dump_printf(": %s:%d\n", event->comm.comm, event->comm.tid); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 450 | |
Arnaldo Carvalho de Melo | d7603d5 | 2011-03-04 14:51:33 -0300 | [diff] [blame] | 451 | if (thread == NULL || thread__set_comm(thread, event->comm.comm)) { |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 452 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); |
| 453 | return -1; |
| 454 | } |
| 455 | |
| 456 | return 0; |
| 457 | } |
| 458 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 459 | int perf_event__process_lost(union perf_event *event, |
| 460 | struct perf_sample *sample __used, |
| 461 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 462 | { |
Arnaldo Carvalho de Melo | 9486aa3 | 2011-01-22 20:37:02 -0200 | [diff] [blame] | 463 | dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 464 | event->lost.id, event->lost.lost); |
| 465 | session->hists.stats.total_lost += event->lost.lost; |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 469 | static void perf_event__set_kernel_mmap_len(union perf_event *event, |
| 470 | struct map **maps) |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 471 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 472 | maps[MAP__FUNCTION]->start = event->mmap.start; |
| 473 | maps[MAP__FUNCTION]->end = event->mmap.start + event->mmap.len; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 474 | /* |
| 475 | * Be a bit paranoid here, some perf.data file came with |
| 476 | * a zero sized synthesized MMAP event for the kernel. |
| 477 | */ |
| 478 | if (maps[MAP__FUNCTION]->end == 0) |
Ian Munsie | 9d1faba | 2010-11-25 15:12:53 +1100 | [diff] [blame] | 479 | maps[MAP__FUNCTION]->end = ~0ULL; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 480 | } |
| 481 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 482 | static int perf_event__process_kernel_mmap(union perf_event *event, |
| 483 | struct perf_session *session) |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 484 | { |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 485 | struct map *map; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 486 | char kmmap_prefix[PATH_MAX]; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 487 | struct machine *machine; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 488 | enum dso_kernel_type kernel_type; |
| 489 | bool is_kernel_mmap; |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 490 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 491 | machine = perf_session__findnew_machine(session, event->mmap.pid); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 492 | if (!machine) { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 493 | pr_err("Can't find id %d's machine\n", event->mmap.pid); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 494 | goto out_problem; |
| 495 | } |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 496 | |
Arnaldo Carvalho de Melo | 48ea8f5 | 2010-04-27 21:19:05 -0300 | [diff] [blame] | 497 | machine__mmap_name(machine, kmmap_prefix, sizeof(kmmap_prefix)); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 498 | if (machine__is_host(machine)) |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 499 | kernel_type = DSO_TYPE_KERNEL; |
| 500 | else |
| 501 | kernel_type = DSO_TYPE_GUEST_KERNEL; |
| 502 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 503 | is_kernel_mmap = memcmp(event->mmap.filename, |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 504 | kmmap_prefix, |
| 505 | strlen(kmmap_prefix)) == 0; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 506 | if (event->mmap.filename[0] == '/' || |
| 507 | (!is_kernel_mmap && event->mmap.filename[0] == '[')) { |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 508 | |
| 509 | char short_module_name[1024]; |
| 510 | char *name, *dot; |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 511 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 512 | if (event->mmap.filename[0] == '/') { |
| 513 | name = strrchr(event->mmap.filename, '/'); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 514 | if (name == NULL) |
| 515 | goto out_problem; |
| 516 | |
| 517 | ++name; /* skip / */ |
| 518 | dot = strrchr(name, '.'); |
| 519 | if (dot == NULL) |
| 520 | goto out_problem; |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 521 | snprintf(short_module_name, sizeof(short_module_name), |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 522 | "[%.*s]", (int)(dot - name), name); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 523 | strxfrchar(short_module_name, '-', '_'); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 524 | } else |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 525 | strcpy(short_module_name, event->mmap.filename); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 526 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 527 | map = machine__new_module(machine, event->mmap.start, |
| 528 | event->mmap.filename); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 529 | if (map == NULL) |
| 530 | goto out_problem; |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 531 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 532 | name = strdup(short_module_name); |
| 533 | if (name == NULL) |
| 534 | goto out_problem; |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 535 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 536 | map->dso->short_name = name; |
Arnaldo Carvalho de Melo | 6e40625 | 2010-07-29 15:11:30 -0300 | [diff] [blame] | 537 | map->dso->sname_alloc = 1; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 538 | map->end = map->start + event->mmap.len; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 539 | } else if (is_kernel_mmap) { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 540 | const char *symbol_name = (event->mmap.filename + |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 541 | strlen(kmmap_prefix)); |
| 542 | /* |
| 543 | * Should be there already, from the build-id table in |
| 544 | * the header. |
| 545 | */ |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 546 | struct dso *kernel = __dsos__findnew(&machine->kernel_dsos, |
| 547 | kmmap_prefix); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 548 | if (kernel == NULL) |
| 549 | goto out_problem; |
| 550 | |
| 551 | kernel->kernel = kernel_type; |
Arnaldo Carvalho de Melo | d28c622 | 2010-04-27 21:20:43 -0300 | [diff] [blame] | 552 | if (__machine__create_kernel_maps(machine, kernel) < 0) |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 553 | goto out_problem; |
| 554 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 555 | perf_event__set_kernel_mmap_len(event, machine->vmlinux_maps); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 556 | perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, |
| 557 | symbol_name, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 558 | event->mmap.pgoff); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 559 | if (machine__is_default_guest(machine)) { |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 560 | /* |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 561 | * preload dso of guest kernel and modules |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 562 | */ |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 563 | dso__load(kernel, machine->vmlinux_maps[MAP__FUNCTION], |
| 564 | NULL); |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 565 | } |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 566 | } |
| 567 | return 0; |
| 568 | out_problem: |
| 569 | return -1; |
| 570 | } |
| 571 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 572 | int perf_event__process_mmap(union perf_event *event, |
| 573 | struct perf_sample *sample __used, |
| 574 | struct perf_session *session) |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 575 | { |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 576 | struct machine *machine; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 577 | struct thread *thread; |
| 578 | struct map *map; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 579 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 580 | int ret = 0; |
| 581 | |
Arnaldo Carvalho de Melo | 9486aa3 | 2011-01-22 20:37:02 -0200 | [diff] [blame] | 582 | dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n", |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 583 | event->mmap.pid, event->mmap.tid, event->mmap.start, |
| 584 | event->mmap.len, event->mmap.pgoff, event->mmap.filename); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 585 | |
| 586 | if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || |
| 587 | cpumode == PERF_RECORD_MISC_KERNEL) { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 588 | ret = perf_event__process_kernel_mmap(event, session); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 589 | if (ret < 0) |
| 590 | goto out_problem; |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 591 | return 0; |
| 592 | } |
| 593 | |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 594 | machine = perf_session__find_host_machine(session); |
Arnaldo Carvalho de Melo | 4cc4945 | 2010-05-09 21:14:07 -0300 | [diff] [blame] | 595 | if (machine == NULL) |
| 596 | goto out_problem; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 597 | thread = perf_session__findnew(session, event->mmap.pid); |
Arnaldo Carvalho de Melo | d65a458 | 2010-07-30 18:31:28 -0300 | [diff] [blame] | 598 | if (thread == NULL) |
| 599 | goto out_problem; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 600 | map = map__new(&machine->user_dsos, event->mmap.start, |
| 601 | event->mmap.len, event->mmap.pgoff, |
| 602 | event->mmap.pid, event->mmap.filename, |
Dave Martin | 361d134 | 2010-07-27 16:40:02 +0100 | [diff] [blame] | 603 | MAP__FUNCTION); |
Arnaldo Carvalho de Melo | d65a458 | 2010-07-30 18:31:28 -0300 | [diff] [blame] | 604 | if (map == NULL) |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 605 | goto out_problem; |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 606 | |
Arnaldo Carvalho de Melo | b7cece7 | 2010-01-13 13:22:17 -0200 | [diff] [blame] | 607 | thread__insert_map(thread, map); |
| 608 | return 0; |
| 609 | |
| 610 | out_problem: |
| 611 | dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n"); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 612 | return 0; |
| 613 | } |
| 614 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 615 | int perf_event__process_task(union perf_event *event, |
| 616 | struct perf_sample *sample __used, |
| 617 | struct perf_session *session) |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 618 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 619 | struct thread *thread = perf_session__findnew(session, event->fork.tid); |
| 620 | struct thread *parent = perf_session__findnew(session, event->fork.ptid); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 621 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 622 | dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, |
| 623 | event->fork.ppid, event->fork.ptid); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 624 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 625 | if (event->header.type == PERF_RECORD_EXIT) { |
Arnaldo Carvalho de Melo | 720a3ae | 2010-06-17 08:37:44 -0300 | [diff] [blame] | 626 | perf_session__remove_thread(session, thread); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 627 | return 0; |
Arnaldo Carvalho de Melo | 720a3ae | 2010-06-17 08:37:44 -0300 | [diff] [blame] | 628 | } |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 629 | |
| 630 | if (thread == NULL || parent == NULL || |
| 631 | thread__fork(thread, parent) < 0) { |
| 632 | dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); |
| 633 | return -1; |
| 634 | } |
| 635 | |
| 636 | return 0; |
| 637 | } |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 638 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 639 | int perf_event__process(union perf_event *event, struct perf_sample *sample, |
| 640 | struct perf_session *session) |
Srikar Dronamraju | b83f920 | 2010-08-02 18:08:51 +0530 | [diff] [blame] | 641 | { |
| 642 | switch (event->header.type) { |
| 643 | case PERF_RECORD_COMM: |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 644 | perf_event__process_comm(event, sample, session); |
Srikar Dronamraju | b83f920 | 2010-08-02 18:08:51 +0530 | [diff] [blame] | 645 | break; |
| 646 | case PERF_RECORD_MMAP: |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 647 | perf_event__process_mmap(event, sample, session); |
Srikar Dronamraju | b83f920 | 2010-08-02 18:08:51 +0530 | [diff] [blame] | 648 | break; |
| 649 | case PERF_RECORD_FORK: |
| 650 | case PERF_RECORD_EXIT: |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 651 | perf_event__process_task(event, sample, session); |
Srikar Dronamraju | b83f920 | 2010-08-02 18:08:51 +0530 | [diff] [blame] | 652 | break; |
Arnaldo Carvalho de Melo | ef2bf6d | 2011-01-29 09:04:40 -0200 | [diff] [blame] | 653 | case PERF_RECORD_LOST: |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 654 | perf_event__process_lost(event, sample, session); |
Srikar Dronamraju | b83f920 | 2010-08-02 18:08:51 +0530 | [diff] [blame] | 655 | default: |
| 656 | break; |
| 657 | } |
| 658 | |
| 659 | return 0; |
| 660 | } |
| 661 | |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 662 | void thread__find_addr_map(struct thread *self, |
| 663 | struct perf_session *session, u8 cpumode, |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 664 | enum map_type type, pid_t pid, u64 addr, |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 665 | struct addr_location *al) |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 666 | { |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 667 | struct map_groups *mg = &self->mg; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 668 | struct machine *machine = NULL; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 669 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 670 | al->thread = self; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 671 | al->addr = addr; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 672 | al->cpumode = cpumode; |
| 673 | al->filtered = false; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 674 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 675 | if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 676 | al->level = 'k'; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 677 | machine = perf_session__find_host_machine(session); |
Arnaldo Carvalho de Melo | 4cc4945 | 2010-05-09 21:14:07 -0300 | [diff] [blame] | 678 | if (machine == NULL) { |
| 679 | al->map = NULL; |
| 680 | return; |
| 681 | } |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 682 | mg = &machine->kmaps; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 683 | } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) { |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 684 | al->level = '.'; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 685 | machine = perf_session__find_host_machine(session); |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 686 | } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) { |
| 687 | al->level = 'g'; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 688 | machine = perf_session__find_machine(session, pid); |
Arnaldo Carvalho de Melo | 4cc4945 | 2010-05-09 21:14:07 -0300 | [diff] [blame] | 689 | if (machine == NULL) { |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 690 | al->map = NULL; |
| 691 | return; |
| 692 | } |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 693 | mg = &machine->kmaps; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 694 | } else { |
| 695 | /* |
| 696 | * 'u' means guest os user space. |
| 697 | * TODO: We don't support guest user space. Might support late. |
| 698 | */ |
| 699 | if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) |
| 700 | al->level = 'u'; |
| 701 | else |
| 702 | al->level = 'H'; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 703 | al->map = NULL; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 704 | |
| 705 | if ((cpumode == PERF_RECORD_MISC_GUEST_USER || |
| 706 | cpumode == PERF_RECORD_MISC_GUEST_KERNEL) && |
| 707 | !perf_guest) |
| 708 | al->filtered = true; |
| 709 | if ((cpumode == PERF_RECORD_MISC_USER || |
| 710 | cpumode == PERF_RECORD_MISC_KERNEL) && |
| 711 | !perf_host) |
| 712 | al->filtered = true; |
| 713 | |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 714 | return; |
| 715 | } |
| 716 | try_again: |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 717 | al->map = map_groups__find(mg, type, al->addr); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 718 | if (al->map == NULL) { |
| 719 | /* |
| 720 | * If this is outside of all known maps, and is a negative |
| 721 | * address, try to look it up in the kernel dso, as it might be |
| 722 | * a vsyscall or vdso (which executes in user-mode). |
| 723 | * |
| 724 | * XXX This is nasty, we should have a symbol list in the |
| 725 | * "[vdso]" dso, but for now lets use the old trick of looking |
| 726 | * in the whole kernel symbol list. |
| 727 | */ |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 728 | if ((long long)al->addr < 0 && |
Andrew Lutomirski | 6c6804fb | 2011-03-24 00:36:56 -0400 | [diff] [blame] | 729 | cpumode == PERF_RECORD_MISC_USER && |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 730 | machine && mg != &machine->kmaps) { |
| 731 | mg = &machine->kmaps; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 732 | goto try_again; |
| 733 | } |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 734 | } else |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 735 | al->addr = al->map->map_ip(al->map, al->addr); |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | void thread__find_addr_location(struct thread *self, |
| 739 | struct perf_session *session, u8 cpumode, |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 740 | enum map_type type, pid_t pid, u64 addr, |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 741 | struct addr_location *al, |
| 742 | symbol_filter_t filter) |
| 743 | { |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 744 | thread__find_addr_map(self, session, cpumode, type, pid, addr, al); |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 745 | if (al->map != NULL) |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 746 | al->sym = map__find_symbol(al->map, al->addr, filter); |
Arnaldo Carvalho de Melo | 59ee68e | 2010-01-14 23:45:29 -0200 | [diff] [blame] | 747 | else |
| 748 | al->sym = NULL; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 749 | } |
| 750 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 751 | int perf_event__preprocess_sample(const union perf_event *event, |
| 752 | struct perf_session *session, |
| 753 | struct addr_location *al, |
| 754 | struct perf_sample *sample, |
| 755 | symbol_filter_t filter) |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 756 | { |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 757 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
| 758 | struct thread *thread = perf_session__findnew(session, event->ip.pid); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 759 | |
| 760 | if (thread == NULL) |
| 761 | return -1; |
| 762 | |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 763 | if (symbol_conf.comm_list && |
| 764 | !strlist__has_entry(symbol_conf.comm_list, thread->comm)) |
| 765 | goto out_filtered; |
| 766 | |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 767 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
Arnaldo Carvalho de Melo | 1f626bc | 2010-05-09 19:57:08 -0300 | [diff] [blame] | 768 | /* |
| 769 | * Have we already created the kernel maps for the host machine? |
| 770 | * |
| 771 | * This should have happened earlier, when we processed the kernel MMAP |
| 772 | * events, but for older perf.data files there was no such thing, so do |
| 773 | * it now. |
| 774 | */ |
| 775 | if (cpumode == PERF_RECORD_MISC_KERNEL && |
| 776 | session->host_machine.vmlinux_maps[MAP__FUNCTION] == NULL) |
| 777 | machine__create_kernel_maps(&session->host_machine); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 778 | |
Arnaldo Carvalho de Melo | 96415e4 | 2010-03-24 16:40:15 -0300 | [diff] [blame] | 779 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 780 | event->ip.pid, event->ip.ip, al); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 781 | dump_printf(" ...... dso: %s\n", |
| 782 | al->map ? al->map->dso->long_name : |
| 783 | al->level == 'H' ? "[hypervisor]" : "<not found>"); |
Arnaldo Carvalho de Melo | 96415e4 | 2010-03-24 16:40:15 -0300 | [diff] [blame] | 784 | al->sym = NULL; |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 785 | al->cpu = sample->cpu; |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 786 | |
Arnaldo Carvalho de Melo | 96415e4 | 2010-03-24 16:40:15 -0300 | [diff] [blame] | 787 | if (al->map) { |
| 788 | if (symbol_conf.dso_list && |
| 789 | (!al->map || !al->map->dso || |
| 790 | !(strlist__has_entry(symbol_conf.dso_list, |
| 791 | al->map->dso->short_name) || |
| 792 | (al->map->dso->short_name != al->map->dso->long_name && |
| 793 | strlist__has_entry(symbol_conf.dso_list, |
| 794 | al->map->dso->long_name))))) |
| 795 | goto out_filtered; |
Arnaldo Carvalho de Melo | 96415e4 | 2010-03-24 16:40:15 -0300 | [diff] [blame] | 796 | |
| 797 | al->sym = map__find_symbol(al->map, al->addr, filter); |
| 798 | } |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 799 | |
| 800 | if (symbol_conf.sym_list && al->sym && |
| 801 | !strlist__has_entry(symbol_conf.sym_list, al->sym->name)) |
| 802 | goto out_filtered; |
| 803 | |
Arnaldo Carvalho de Melo | c410a33 | 2009-12-15 20:04:41 -0200 | [diff] [blame] | 804 | return 0; |
| 805 | |
| 806 | out_filtered: |
| 807 | al->filtered = true; |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 808 | return 0; |
| 809 | } |