diff options
Diffstat (limited to 'tools/perf/builtin-trace.c')
| -rw-r--r-- | tools/perf/builtin-trace.c | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 75972fd073df..a7750256c408 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -16,38 +16,10 @@ | |||
| 16 | 16 | ||
| 17 | static char const *input_name = "perf.data"; | 17 | static char const *input_name = "perf.data"; |
| 18 | 18 | ||
| 19 | static unsigned long total = 0; | ||
| 20 | static unsigned long total_comm = 0; | ||
| 21 | |||
| 22 | static struct perf_header *header; | 19 | static struct perf_header *header; |
| 23 | static u64 sample_type; | 20 | static u64 sample_type; |
| 24 | 21 | ||
| 25 | static char *cwd; | 22 | static int process_sample_event(event_t *event) |
| 26 | static int cwdlen; | ||
| 27 | |||
| 28 | |||
| 29 | static int | ||
| 30 | process_comm_event(event_t *event, unsigned long offset, unsigned long head) | ||
| 31 | { | ||
| 32 | struct thread *thread = threads__findnew(event->comm.pid); | ||
| 33 | |||
| 34 | dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n", | ||
| 35 | (void *)(offset + head), | ||
| 36 | (void *)(long)(event->header.size), | ||
| 37 | event->comm.comm, event->comm.pid); | ||
| 38 | |||
| 39 | if (thread == NULL || | ||
| 40 | thread__set_comm(thread, event->comm.comm)) { | ||
| 41 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); | ||
| 42 | return -1; | ||
| 43 | } | ||
| 44 | total_comm++; | ||
| 45 | |||
| 46 | return 0; | ||
| 47 | } | ||
| 48 | |||
| 49 | static int | ||
| 50 | process_sample_event(event_t *event, unsigned long offset, unsigned long head) | ||
| 51 | { | 23 | { |
| 52 | u64 ip = event->ip.ip; | 24 | u64 ip = event->ip.ip; |
| 53 | u64 timestamp = -1; | 25 | u64 timestamp = -1; |
| @@ -72,9 +44,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
| 72 | more_data += sizeof(u64); | 44 | more_data += sizeof(u64); |
| 73 | } | 45 | } |
| 74 | 46 | ||
| 75 | dump_printf("%p [%p]: PERF_RECORD_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n", | 47 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
| 76 | (void *)(offset + head), | ||
| 77 | (void *)(long)(event->header.size), | ||
| 78 | event->header.misc, | 48 | event->header.misc, |
| 79 | event->ip.pid, event->ip.tid, | 49 | event->ip.pid, event->ip.tid, |
| 80 | (void *)(long)ip, | 50 | (void *)(long)ip, |
| @@ -101,7 +71,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
| 101 | */ | 71 | */ |
| 102 | print_event(cpu, raw->data, raw->size, timestamp, thread->comm); | 72 | print_event(cpu, raw->data, raw->size, timestamp, thread->comm); |
| 103 | } | 73 | } |
| 104 | total += period; | 74 | event__stats.total += period; |
| 105 | 75 | ||
| 106 | return 0; | 76 | return 0; |
| 107 | } | 77 | } |
| @@ -122,7 +92,7 @@ static int sample_type_check(u64 type) | |||
| 122 | 92 | ||
| 123 | static struct perf_file_handler file_handler = { | 93 | static struct perf_file_handler file_handler = { |
| 124 | .process_sample_event = process_sample_event, | 94 | .process_sample_event = process_sample_event, |
| 125 | .process_comm_event = process_comm_event, | 95 | .process_comm_event = event__process_comm, |
| 126 | .sample_type_check = sample_type_check, | 96 | .sample_type_check = sample_type_check, |
| 127 | }; | 97 | }; |
| 128 | 98 | ||
| @@ -132,7 +102,7 @@ static int __cmd_trace(void) | |||
| 132 | register_perf_file_handler(&file_handler); | 102 | register_perf_file_handler(&file_handler); |
| 133 | 103 | ||
| 134 | return mmap_dispatch_perf_file(&header, input_name, | 104 | return mmap_dispatch_perf_file(&header, input_name, |
| 135 | 0, 0, &cwdlen, &cwd); | 105 | 0, 0, &event__cwdlen, &event__cwd); |
| 136 | } | 106 | } |
| 137 | 107 | ||
| 138 | static const char * const annotate_usage[] = { | 108 | static const char * const annotate_usage[] = { |
