diff options
-rw-r--r-- | tools/perf/builtin-trace.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index ba055103b525..c95a3e9b0331 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -67,6 +67,7 @@ struct thread_trace { | |||
67 | u64 entry_time; | 67 | u64 entry_time; |
68 | u64 exit_time; | 68 | u64 exit_time; |
69 | bool entry_pending; | 69 | bool entry_pending; |
70 | unsigned long nr_events; | ||
70 | char *entry_str; | 71 | char *entry_str; |
71 | }; | 72 | }; |
72 | 73 | ||
@@ -77,16 +78,21 @@ static struct thread_trace *thread_trace__new(void) | |||
77 | 78 | ||
78 | static struct thread_trace *thread__trace(struct thread *thread) | 79 | static struct thread_trace *thread__trace(struct thread *thread) |
79 | { | 80 | { |
81 | struct thread_trace *ttrace; | ||
82 | |||
80 | if (thread == NULL) | 83 | if (thread == NULL) |
81 | goto fail; | 84 | goto fail; |
82 | 85 | ||
83 | if (thread->priv == NULL) | 86 | if (thread->priv == NULL) |
84 | thread->priv = thread_trace__new(); | 87 | thread->priv = thread_trace__new(); |
85 | 88 | ||
86 | if (thread->priv == NULL) | 89 | if (thread->priv == NULL) |
87 | goto fail; | 90 | goto fail; |
88 | 91 | ||
89 | return thread->priv; | 92 | ttrace = thread->priv; |
93 | ++ttrace->nr_events; | ||
94 | |||
95 | return ttrace; | ||
90 | fail: | 96 | fail: |
91 | color_fprintf(stdout, PERF_COLOR_RED, | 97 | color_fprintf(stdout, PERF_COLOR_RED, |
92 | "WARNING: not enough memory, dropping samples!\n"); | 98 | "WARNING: not enough memory, dropping samples!\n"); |
@@ -102,6 +108,7 @@ struct trace { | |||
102 | struct perf_record_opts opts; | 108 | struct perf_record_opts opts; |
103 | struct machine host; | 109 | struct machine host; |
104 | u64 base_time; | 110 | u64 base_time; |
111 | unsigned long nr_events; | ||
105 | bool multiple_threads; | 112 | bool multiple_threads; |
106 | double duration_filter; | 113 | double duration_filter; |
107 | }; | 114 | }; |
@@ -386,7 +393,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
386 | { | 393 | { |
387 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); | 394 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); |
388 | struct perf_evsel *evsel; | 395 | struct perf_evsel *evsel; |
389 | int err = -1, i, nr_events = 0, before; | 396 | int err = -1, i; |
397 | unsigned long before; | ||
390 | const bool forks = argc > 0; | 398 | const bool forks = argc > 0; |
391 | 399 | ||
392 | if (evlist == NULL) { | 400 | if (evlist == NULL) { |
@@ -444,7 +452,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
444 | 452 | ||
445 | trace->multiple_threads = evlist->threads->map[0] == -1 || evlist->threads->nr > 1; | 453 | trace->multiple_threads = evlist->threads->map[0] == -1 || evlist->threads->nr > 1; |
446 | again: | 454 | again: |
447 | before = nr_events; | 455 | before = trace->nr_events; |
448 | 456 | ||
449 | for (i = 0; i < evlist->nr_mmaps; i++) { | 457 | for (i = 0; i < evlist->nr_mmaps; i++) { |
450 | union perf_event *event; | 458 | union perf_event *event; |
@@ -454,7 +462,7 @@ again: | |||
454 | tracepoint_handler handler; | 462 | tracepoint_handler handler; |
455 | struct perf_sample sample; | 463 | struct perf_sample sample; |
456 | 464 | ||
457 | ++nr_events; | 465 | ++trace->nr_events; |
458 | 466 | ||
459 | err = perf_evlist__parse_sample(evlist, event, &sample); | 467 | err = perf_evlist__parse_sample(evlist, event, &sample); |
460 | if (err) { | 468 | if (err) { |
@@ -495,7 +503,7 @@ again: | |||
495 | } | 503 | } |
496 | } | 504 | } |
497 | 505 | ||
498 | if (nr_events == before) { | 506 | if (trace->nr_events == before) { |
499 | if (done) | 507 | if (done) |
500 | goto out_delete_evlist; | 508 | goto out_delete_evlist; |
501 | 509 | ||