summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-annotate.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-annotate.c
parent1de8e24520ffdcf2a90c842eed937f59079a2abd (diff)
downloadlinux-3.10-62daacb51a2bf8480e6f6b3696b03f102fc15eb0.tar.gz
linux-3.10-62daacb51a2bf8480e6f6b3696b03f102fc15eb0.tar.bz2
linux-3.10-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-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c63
1 files changed, 15 insertions, 48 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 3ebd70b1ef9..7d39bd2b19b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -19,12 +19,12 @@
#include "perf.h"
#include "util/debug.h"
+#include "util/event.h"
#include "util/parse-options.h"
#include "util/parse-events.h"
#include "util/thread.h"
#include "util/sort.h"
#include "util/hist.h"
-#include "util/process_events.h"
static char const *input_name = "perf.data";
@@ -136,8 +136,7 @@ static int hist_entry__add(struct thread *thread, struct map *map,
return 0;
}
-static int
-process_sample_event(event_t *event, unsigned long offset, unsigned long head)
+static int process_sample_event(event_t *event)
{
char level;
u64 ip = event->ip.ip;
@@ -145,12 +144,8 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
struct symbol *sym = NULL;
struct thread *thread = threads__findnew(event->ip.pid);
- dump_printf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
- (void *)(offset + head),
- (void *)(long)(event->header.size),
- event->header.misc,
- event->ip.pid,
- (void *)(long)ip);
+ dump_printf("(IP, %d): %d: %p\n", event->header.misc,
+ event->ip.pid, (void *)(long)ip);
if (thread == NULL) {
fprintf(stderr, "problem processing %d event, skipping it.\n",
@@ -198,46 +193,24 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
"skipping event\n");
return -1;
}
- total++;
return 0;
}
-static int
-process_comm_event(event_t *event, unsigned long offset, unsigned long head)
+static int event__process(event_t *self)
{
- 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_event(event_t *event, unsigned long offset, unsigned long head)
-{
- switch (event->header.type) {
+ switch (self->header.type) {
case PERF_RECORD_SAMPLE:
- return process_sample_event(event, offset, head);
+ return process_sample_event(self);
case PERF_RECORD_MMAP:
- return process_mmap_event(event, offset, head);
+ return event__process_mmap(self);
case PERF_RECORD_COMM:
- return process_comm_event(event, offset, head);
+ return event__process_comm(self);
case PERF_RECORD_FORK:
- return process_task_event(event, offset, head);
+ return event__process_task(self);
/*
* We dont process them right now but they are fine:
*/
@@ -621,15 +594,12 @@ more:
(void *)(long)event->header.size,
event->header.type);
- if (!size || process_event(event, offset, head) < 0) {
+ if (!size || event__process(event) < 0) {
dump_printf("%p [%p]: skipping unknown header type: %d\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->header.type);
-
- total_unknown++;
-
/*
* assume we lost track of the stream, check alignment, and
* increment a single u64 in the hope to catch on again 'soon'.
@@ -649,14 +619,11 @@ more:
rc = EXIT_SUCCESS;
close(input);
- dump_printf(" IP events: %10ld\n", total);
- dump_printf(" mmap events: %10ld\n", total_mmap);
- dump_printf(" comm events: %10ld\n", total_comm);
- dump_printf(" fork events: %10ld\n", total_fork);
- dump_printf(" unknown events: %10ld\n", total_unknown);
- if (dump_trace)
+ if (dump_trace) {
+ event__print_totals();
return 0;
+ }
if (verbose > 3)
threads__fprintf(stdout);
@@ -665,7 +632,7 @@ more:
dsos__fprintf(stdout);
collapse__resort();
- output__resort(total);
+ output__resort(event__total[0]);
find_annotations();