aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-08-16 13:24:21 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-16 13:42:31 -0400
commit2cec19d9d0716f8d68f1c5a87667d0387d4d252d (patch)
treeaf5de5945e4b1aa53c2e97028c18281471ffa1c6 /tools/perf/builtin-annotate.c
parent0d31b82dd5c54a0b1e1d789427abdcc180bc4602 (diff)
perf tools: Factorize the dprintf definition
We have two users of dprintf: report and annotate. Another one is coming with perf trace. Then factorize it into the debug file. While at it, rename dprintf() to dump_printf() so that it doesn't conflicts with its libc homograph. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Mike Galbraith <efault@gmx.de> LKML-Reference: <1250443461-28130-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 32ff9838351e..820e7ccec62d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -34,10 +34,6 @@ static char *sort_order = default_sort_order;
34static int input; 34static int input;
35static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; 35static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
36 36
37static int dump_trace = 0;
38#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)
39
40
41static int full_paths; 37static int full_paths;
42 38
43static int print_line; 39static int print_line;
@@ -507,14 +503,14 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
507 503
508 thread = threads__findnew(event->ip.pid, &threads, &last_match); 504 thread = threads__findnew(event->ip.pid, &threads, &last_match);
509 505
510 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n", 506 dump_printf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
511 (void *)(offset + head), 507 (void *)(offset + head),
512 (void *)(long)(event->header.size), 508 (void *)(long)(event->header.size),
513 event->header.misc, 509 event->header.misc,
514 event->ip.pid, 510 event->ip.pid,
515 (void *)(long)ip); 511 (void *)(long)ip);
516 512
517 dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid); 513 dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
518 514
519 if (thread == NULL) { 515 if (thread == NULL) {
520 fprintf(stderr, "problem processing %d event, skipping it.\n", 516 fprintf(stderr, "problem processing %d event, skipping it.\n",
@@ -528,7 +524,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
528 524
529 dso = kernel_dso; 525 dso = kernel_dso;
530 526
531 dprintf(" ...... dso: %s\n", dso->name); 527 dump_printf(" ...... dso: %s\n", dso->name);
532 528
533 } else if (event->header.misc & PERF_EVENT_MISC_USER) { 529 } else if (event->header.misc & PERF_EVENT_MISC_USER) {
534 530
@@ -549,12 +545,12 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
549 if ((long long)ip < 0) 545 if ((long long)ip < 0)
550 dso = kernel_dso; 546 dso = kernel_dso;
551 } 547 }
552 dprintf(" ...... dso: %s\n", dso ? dso->name : "<not found>"); 548 dump_printf(" ...... dso: %s\n", dso ? dso->name : "<not found>");
553 549
554 } else { 550 } else {
555 show = SHOW_HV; 551 show = SHOW_HV;
556 level = 'H'; 552 level = 'H';
557 dprintf(" ...... dso: [hypervisor]\n"); 553 dump_printf(" ...... dso: [hypervisor]\n");
558 } 554 }
559 555
560 if (show & show_mask) { 556 if (show & show_mask) {
@@ -582,7 +578,7 @@ process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
582 578
583 thread = threads__findnew(event->mmap.pid, &threads, &last_match); 579 thread = threads__findnew(event->mmap.pid, &threads, &last_match);
584 580
585 dprintf("%p [%p]: PERF_EVENT_MMAP %d: [%p(%p) @ %p]: %s\n", 581 dump_printf("%p [%p]: PERF_EVENT_MMAP %d: [%p(%p) @ %p]: %s\n",
586 (void *)(offset + head), 582 (void *)(offset + head),
587 (void *)(long)(event->header.size), 583 (void *)(long)(event->header.size),
588 event->mmap.pid, 584 event->mmap.pid,
@@ -592,7 +588,7 @@ process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
592 event->mmap.filename); 588 event->mmap.filename);
593 589
594 if (thread == NULL || map == NULL) { 590 if (thread == NULL || map == NULL) {
595 dprintf("problem processing PERF_EVENT_MMAP, skipping event.\n"); 591 dump_printf("problem processing PERF_EVENT_MMAP, skipping event.\n");
596 return 0; 592 return 0;
597 } 593 }
598 594
@@ -608,14 +604,14 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head)
608 struct thread *thread; 604 struct thread *thread;
609 605
610 thread = threads__findnew(event->comm.pid, &threads, &last_match); 606 thread = threads__findnew(event->comm.pid, &threads, &last_match);
611 dprintf("%p [%p]: PERF_EVENT_COMM: %s:%d\n", 607 dump_printf("%p [%p]: PERF_EVENT_COMM: %s:%d\n",
612 (void *)(offset + head), 608 (void *)(offset + head),
613 (void *)(long)(event->header.size), 609 (void *)(long)(event->header.size),
614 event->comm.comm, event->comm.pid); 610 event->comm.comm, event->comm.pid);
615 611
616 if (thread == NULL || 612 if (thread == NULL ||
617 thread__set_comm(thread, event->comm.comm)) { 613 thread__set_comm(thread, event->comm.comm)) {
618 dprintf("problem processing PERF_EVENT_COMM, skipping event.\n"); 614 dump_printf("problem processing PERF_EVENT_COMM, skipping event.\n");
619 return -1; 615 return -1;
620 } 616 }
621 total_comm++; 617 total_comm++;
@@ -631,13 +627,13 @@ process_fork_event(event_t *event, unsigned long offset, unsigned long head)
631 627
632 thread = threads__findnew(event->fork.pid, &threads, &last_match); 628 thread = threads__findnew(event->fork.pid, &threads, &last_match);
633 parent = threads__findnew(event->fork.ppid, &threads, &last_match); 629 parent = threads__findnew(event->fork.ppid, &threads, &last_match);
634 dprintf("%p [%p]: PERF_EVENT_FORK: %d:%d\n", 630 dump_printf("%p [%p]: PERF_EVENT_FORK: %d:%d\n",
635 (void *)(offset + head), 631 (void *)(offset + head),
636 (void *)(long)(event->header.size), 632 (void *)(long)(event->header.size),
637 event->fork.pid, event->fork.ppid); 633 event->fork.pid, event->fork.ppid);
638 634
639 if (!thread || !parent || thread__fork(thread, parent)) { 635 if (!thread || !parent || thread__fork(thread, parent)) {
640 dprintf("problem processing PERF_EVENT_FORK, skipping event.\n"); 636 dump_printf("problem processing PERF_EVENT_FORK, skipping event.\n");
641 return -1; 637 return -1;
642 } 638 }
643 total_fork++; 639 total_fork++;
@@ -1022,14 +1018,14 @@ more:
1022 1018
1023 size = event->header.size; 1019 size = event->header.size;
1024 1020
1025 dprintf("%p [%p]: event: %d\n", 1021 dump_printf("%p [%p]: event: %d\n",
1026 (void *)(offset + head), 1022 (void *)(offset + head),
1027 (void *)(long)event->header.size, 1023 (void *)(long)event->header.size,
1028 event->header.type); 1024 event->header.type);
1029 1025
1030 if (!size || process_event(event, offset, head) < 0) { 1026 if (!size || process_event(event, offset, head) < 0) {
1031 1027
1032 dprintf("%p [%p]: skipping unknown header type: %d\n", 1028 dump_printf("%p [%p]: skipping unknown header type: %d\n",
1033 (void *)(offset + head), 1029 (void *)(offset + head),
1034 (void *)(long)(event->header.size), 1030 (void *)(long)(event->header.size),
1035 event->header.type); 1031 event->header.type);
@@ -1055,11 +1051,11 @@ more:
1055 rc = EXIT_SUCCESS; 1051 rc = EXIT_SUCCESS;
1056 close(input); 1052 close(input);
1057 1053
1058 dprintf(" IP events: %10ld\n", total); 1054 dump_printf(" IP events: %10ld\n", total);
1059 dprintf(" mmap events: %10ld\n", total_mmap); 1055 dump_printf(" mmap events: %10ld\n", total_mmap);
1060 dprintf(" comm events: %10ld\n", total_comm); 1056 dump_printf(" comm events: %10ld\n", total_comm);
1061 dprintf(" fork events: %10ld\n", total_fork); 1057 dump_printf(" fork events: %10ld\n", total_fork);
1062 dprintf(" unknown events: %10ld\n", total_unknown); 1058 dump_printf(" unknown events: %10ld\n", total_unknown);
1063 1059
1064 if (dump_trace) 1060 if (dump_trace)
1065 return 0; 1061 return 0;