diff options
author | John Kacur <jkacur@redhat.com> | 2009-11-24 09:35:01 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-24 10:37:01 -0500 |
commit | e74328d3a17ed75ffdf72b86f289965823a47240 (patch) | |
tree | 03b0db84b69f2cb3dce994db0d058804a8748fb1 /tools/perf/builtin-annotate.c | |
parent | c9c7ccaf3a2686ed3a44d69bb1f8b55eeead8a4e (diff) |
perf tools: Use common process_event functions for annotate and report
Prevent bit-rot in perf-annotate by using common functions where
possible. Here we create process_events.[ch] to hold the common
functions.
Signed-off-by: John Kacur <jkacur@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: acme@redhat.com
LKML-Reference: <1259073301-11506-3-git-send-email-jkacur@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r-- | tools/perf/builtin-annotate.c | 56 |
1 files changed, 2 insertions, 54 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 6b13a1ecf1e7..59b6123abec2 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "util/thread.h" | 24 | #include "util/thread.h" |
25 | #include "util/sort.h" | 25 | #include "util/sort.h" |
26 | #include "util/hist.h" | 26 | #include "util/hist.h" |
27 | #include "util/process_events.h" | ||
27 | 28 | ||
28 | static char const *input_name = "perf.data"; | 29 | static char const *input_name = "perf.data"; |
29 | 30 | ||
@@ -202,32 +203,6 @@ got_map: | |||
202 | } | 203 | } |
203 | 204 | ||
204 | static int | 205 | static int |
205 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | ||
206 | { | ||
207 | struct map *map = map__new(&event->mmap, NULL, 0); | ||
208 | struct thread *thread = threads__findnew(event->mmap.pid); | ||
209 | |||
210 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n", | ||
211 | (void *)(offset + head), | ||
212 | (void *)(long)(event->header.size), | ||
213 | event->mmap.pid, | ||
214 | (void *)(long)event->mmap.start, | ||
215 | (void *)(long)event->mmap.len, | ||
216 | (void *)(long)event->mmap.pgoff, | ||
217 | event->mmap.filename); | ||
218 | |||
219 | if (thread == NULL || map == NULL) { | ||
220 | dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n"); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | thread__insert_map(thread, map); | ||
225 | total_mmap++; | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int | ||
231 | process_comm_event(event_t *event, unsigned long offset, unsigned long head) | 206 | process_comm_event(event_t *event, unsigned long offset, unsigned long head) |
232 | { | 207 | { |
233 | struct thread *thread = threads__findnew(event->comm.pid); | 208 | struct thread *thread = threads__findnew(event->comm.pid); |
@@ -248,33 +223,6 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head) | |||
248 | } | 223 | } |
249 | 224 | ||
250 | static int | 225 | static int |
251 | process_fork_event(event_t *event, unsigned long offset, unsigned long head) | ||
252 | { | ||
253 | struct thread *thread = threads__findnew(event->fork.pid); | ||
254 | struct thread *parent = threads__findnew(event->fork.ppid); | ||
255 | |||
256 | dump_printf("%p [%p]: PERF_RECORD_FORK: %d:%d\n", | ||
257 | (void *)(offset + head), | ||
258 | (void *)(long)(event->header.size), | ||
259 | event->fork.pid, event->fork.ppid); | ||
260 | |||
261 | /* | ||
262 | * A thread clone will have the same PID for both | ||
263 | * parent and child. | ||
264 | */ | ||
265 | if (thread == parent) | ||
266 | return 0; | ||
267 | |||
268 | if (!thread || !parent || thread__fork(thread, parent)) { | ||
269 | dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); | ||
270 | return -1; | ||
271 | } | ||
272 | total_fork++; | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | |||
277 | static int | ||
278 | process_event(event_t *event, unsigned long offset, unsigned long head) | 226 | process_event(event_t *event, unsigned long offset, unsigned long head) |
279 | { | 227 | { |
280 | switch (event->header.type) { | 228 | switch (event->header.type) { |
@@ -288,7 +236,7 @@ process_event(event_t *event, unsigned long offset, unsigned long head) | |||
288 | return process_comm_event(event, offset, head); | 236 | return process_comm_event(event, offset, head); |
289 | 237 | ||
290 | case PERF_RECORD_FORK: | 238 | case PERF_RECORD_FORK: |
291 | return process_fork_event(event, offset, head); | 239 | return process_task_event(event, offset, head); |
292 | /* | 240 | /* |
293 | * We dont process them right now but they are fine: | 241 | * We dont process them right now but they are fine: |
294 | */ | 242 | */ |