summaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-trace.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-27 16:29:22 -0200
committerIngo Molnar <mingo@elte.hu>2009-11-27 20:22:01 +0100
commit62daacb51a2bf8480e6f6b3696b03f102fc15eb0 (patch)
tree5b9ed87005a5e59bcc95dd9a42e3d09d6481362d /tools/perf/builtin-trace.c
parent1de8e24520ffdcf2a90c842eed937f59079a2abd (diff)
downloadlinux-62daacb51a2bf8480e6f6b3696b03f102fc15eb0.tar.gz
linux-62daacb51a2bf8480e6f6b3696b03f102fc15eb0.tar.bz2
linux-62daacb51a2bf8480e6f6b3696b03f102fc15eb0.zip
perf tools: Reorganize event processing routines, lotsa dups killed
While implementing event__preprocess_sample, that will do all of the symbol lookup in one convenient function, I noticed that util/process_event.[ch] were not being used at all, then started looking if there were other functions that could be shared and... All those functions really don't need to receive offset + head, the only thing they did was common to all of them, so do it at one place instead. Stats about number of each type of event processed now is done in a central place. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: John Kacur <jkacur@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1259346563-12568-11-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r--tools/perf/builtin-trace.c40
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 @@
static char const *input_name = "perf.data";
-static unsigned long total = 0;
-static unsigned long total_comm = 0;
-
static struct perf_header *header;
static u64 sample_type;
-static char *cwd;
-static int cwdlen;
-
-
-static int
-process_comm_event(event_t *event, unsigned long offset, unsigned long head)
-{
- struct thread *thread = threads__findnew(event->comm.pid);
-
- dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n",
- (void *)(offset + head),
- (void *)(long)(event->header.size),
- event->comm.comm, event->comm.pid);
-
- if (thread == NULL ||
- thread__set_comm(thread, event->comm.comm)) {
- dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
- return -1;
- }
- total_comm++;
-
- return 0;
-}
-
-static int
-process_sample_event(event_t *event, unsigned long offset, unsigned long head)
+static int process_sample_event(event_t *event)
{
u64 ip = event->ip.ip;
u64 timestamp = -1;
@@ -72,9 +44,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
more_data += sizeof(u64);
}
- dump_printf("%p [%p]: PERF_RECORD_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n",
- (void *)(offset + head),
- (void *)(long)(event->header.size),
+ dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
event->header.misc,
event->ip.pid, event->ip.tid,
(void *)(long)ip,
@@ -101,7 +71,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
*/
print_event(cpu, raw->data, raw->size, timestamp, thread->comm);
}
- total += period;
+ event__stats.total += period;
return 0;
}
@@ -122,7 +92,7 @@ static int sample_type_check(u64 type)
static struct perf_file_handler file_handler = {
.process_sample_event = process_sample_event,
- .process_comm_event = process_comm_event,
+ .process_comm_event = event__process_comm,
.sample_type_check = sample_type_check,
};
@@ -132,7 +102,7 @@ static int __cmd_trace(void)
register_perf_file_handler(&file_handler);
return mmap_dispatch_perf_file(&header, input_name,
- 0, 0, &cwdlen, &cwd);
+ 0, 0, &event__cwdlen, &event__cwd);
}
static const char * const annotate_usage[] = {