diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/event.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index b7c7f39a8f6..a5787260181 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -261,11 +261,12 @@ int perf_event__synthesize_modules(struct perf_tool *tool, | |||
261 | 261 | ||
262 | static int __event__synthesize_thread(union perf_event *comm_event, | 262 | static int __event__synthesize_thread(union perf_event *comm_event, |
263 | union perf_event *mmap_event, | 263 | union perf_event *mmap_event, |
264 | pid_t pid, perf_event__handler_t process, | 264 | pid_t pid, int full, |
265 | perf_event__handler_t process, | ||
265 | struct perf_tool *tool, | 266 | struct perf_tool *tool, |
266 | struct machine *machine) | 267 | struct machine *machine) |
267 | { | 268 | { |
268 | pid_t tgid = perf_event__synthesize_comm(tool, comm_event, pid, 1, | 269 | pid_t tgid = perf_event__synthesize_comm(tool, comm_event, pid, full, |
269 | process, machine); | 270 | process, machine); |
270 | if (tgid == -1) | 271 | if (tgid == -1) |
271 | return -1; | 272 | return -1; |
@@ -279,7 +280,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, | |||
279 | struct machine *machine) | 280 | struct machine *machine) |
280 | { | 281 | { |
281 | union perf_event *comm_event, *mmap_event; | 282 | union perf_event *comm_event, *mmap_event; |
282 | int err = -1, thread; | 283 | int err = -1, thread, j; |
283 | 284 | ||
284 | comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size); | 285 | comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size); |
285 | if (comm_event == NULL) | 286 | if (comm_event == NULL) |
@@ -292,11 +293,37 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, | |||
292 | err = 0; | 293 | err = 0; |
293 | for (thread = 0; thread < threads->nr; ++thread) { | 294 | for (thread = 0; thread < threads->nr; ++thread) { |
294 | if (__event__synthesize_thread(comm_event, mmap_event, | 295 | if (__event__synthesize_thread(comm_event, mmap_event, |
295 | threads->map[thread], | 296 | threads->map[thread], 0, |
296 | process, tool, machine)) { | 297 | process, tool, machine)) { |
297 | err = -1; | 298 | err = -1; |
298 | break; | 299 | break; |
299 | } | 300 | } |
301 | |||
302 | /* | ||
303 | * comm.pid is set to thread group id by | ||
304 | * perf_event__synthesize_comm | ||
305 | */ | ||
306 | if ((int) comm_event->comm.pid != threads->map[thread]) { | ||
307 | bool need_leader = true; | ||
308 | |||
309 | /* is thread group leader in thread_map? */ | ||
310 | for (j = 0; j < threads->nr; ++j) { | ||
311 | if ((int) comm_event->comm.pid == threads->map[j]) { | ||
312 | need_leader = false; | ||
313 | break; | ||
314 | } | ||
315 | } | ||
316 | |||
317 | /* if not, generate events for it */ | ||
318 | if (need_leader && | ||
319 | __event__synthesize_thread(comm_event, | ||
320 | mmap_event, | ||
321 | comm_event->comm.pid, 0, | ||
322 | process, tool, machine)) { | ||
323 | err = -1; | ||
324 | break; | ||
325 | } | ||
326 | } | ||
300 | } | 327 | } |
301 | free(mmap_event); | 328 | free(mmap_event); |
302 | out_free_comm: | 329 | out_free_comm: |
@@ -333,7 +360,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool, | |||
333 | if (*end) /* only interested in proper numerical dirents */ | 360 | if (*end) /* only interested in proper numerical dirents */ |
334 | continue; | 361 | continue; |
335 | 362 | ||
336 | __event__synthesize_thread(comm_event, mmap_event, pid, | 363 | __event__synthesize_thread(comm_event, mmap_event, pid, 1, |
337 | process, tool, machine); | 364 | process, tool, machine); |
338 | } | 365 | } |
339 | 366 | ||