diff options
-rw-r--r-- | tools/perf/builtin-annotate.c | 40 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 56 | ||||
-rw-r--r-- | tools/perf/util/debug.c | 15 | ||||
-rw-r--r-- | tools/perf/util/debug.h | 2 |
4 files changed, 62 insertions, 51 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; | |||
34 | static int input; | 34 | static int input; |
35 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 35 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
36 | 36 | ||
37 | static int dump_trace = 0; | ||
38 | #define dprintf(x...) do { if (dump_trace) printf(x); } while (0) | ||
39 | |||
40 | |||
41 | static int full_paths; | 37 | static int full_paths; |
42 | 38 | ||
43 | static int print_line; | 39 | static 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; |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 3b9d24dc0eda..e104ed3c8418 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -43,8 +43,6 @@ static char *field_sep; | |||
43 | static int input; | 43 | static int input; |
44 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 44 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
45 | 45 | ||
46 | static int dump_trace = 0; | ||
47 | #define dprintf(x...) do { if (dump_trace) printf(x); } while (0) | ||
48 | #define cdprintf(x...) do { if (dump_trace) color_fprintf(stdout, color, x); } while (0) | 46 | #define cdprintf(x...) do { if (dump_trace) color_fprintf(stdout, color, x); } while (0) |
49 | 47 | ||
50 | static int full_paths; | 48 | static int full_paths; |
@@ -713,8 +711,8 @@ got_map: | |||
713 | if ((long long)ip < 0) | 711 | if ((long long)ip < 0) |
714 | dso = kernel_dso; | 712 | dso = kernel_dso; |
715 | } | 713 | } |
716 | dprintf(" ...... dso: %s\n", dso ? dso->name : "<not found>"); | 714 | dump_printf(" ...... dso: %s\n", dso ? dso->name : "<not found>"); |
717 | dprintf(" ...... map: %Lx -> %Lx\n", *ipp, ip); | 715 | dump_printf(" ...... map: %Lx -> %Lx\n", *ipp, ip); |
718 | *ipp = ip; | 716 | *ipp = ip; |
719 | 717 | ||
720 | if (dsop) | 718 | if (dsop) |
@@ -1108,7 +1106,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
1108 | more_data += sizeof(u64); | 1106 | more_data += sizeof(u64); |
1109 | } | 1107 | } |
1110 | 1108 | ||
1111 | dprintf("%p [%p]: PERF_EVENT_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n", | 1109 | dump_printf("%p [%p]: PERF_EVENT_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n", |
1112 | (void *)(offset + head), | 1110 | (void *)(offset + head), |
1113 | (void *)(long)(event->header.size), | 1111 | (void *)(long)(event->header.size), |
1114 | event->header.misc, | 1112 | event->header.misc, |
@@ -1121,7 +1119,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
1121 | 1119 | ||
1122 | chain = (void *)more_data; | 1120 | chain = (void *)more_data; |
1123 | 1121 | ||
1124 | dprintf("... chain: nr:%Lu\n", chain->nr); | 1122 | dump_printf("... chain: nr:%Lu\n", chain->nr); |
1125 | 1123 | ||
1126 | if (validate_chain(chain, event) < 0) { | 1124 | if (validate_chain(chain, event) < 0) { |
1127 | eprintf("call-chain problem with event, skipping it.\n"); | 1125 | eprintf("call-chain problem with event, skipping it.\n"); |
@@ -1130,11 +1128,11 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
1130 | 1128 | ||
1131 | if (dump_trace) { | 1129 | if (dump_trace) { |
1132 | for (i = 0; i < chain->nr; i++) | 1130 | for (i = 0; i < chain->nr; i++) |
1133 | dprintf("..... %2d: %016Lx\n", i, chain->ips[i]); | 1131 | dump_printf("..... %2d: %016Lx\n", i, chain->ips[i]); |
1134 | } | 1132 | } |
1135 | } | 1133 | } |
1136 | 1134 | ||
1137 | dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 1135 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
1138 | 1136 | ||
1139 | if (thread == NULL) { | 1137 | if (thread == NULL) { |
1140 | eprintf("problem processing %d event, skipping it.\n", | 1138 | eprintf("problem processing %d event, skipping it.\n", |
@@ -1153,7 +1151,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
1153 | 1151 | ||
1154 | dso = kernel_dso; | 1152 | dso = kernel_dso; |
1155 | 1153 | ||
1156 | dprintf(" ...... dso: %s\n", dso->name); | 1154 | dump_printf(" ...... dso: %s\n", dso->name); |
1157 | 1155 | ||
1158 | } else if (cpumode == PERF_EVENT_MISC_USER) { | 1156 | } else if (cpumode == PERF_EVENT_MISC_USER) { |
1159 | 1157 | ||
@@ -1166,7 +1164,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
1166 | 1164 | ||
1167 | dso = hypervisor_dso; | 1165 | dso = hypervisor_dso; |
1168 | 1166 | ||
1169 | dprintf(" ...... dso: [hypervisor]\n"); | 1167 | dump_printf(" ...... dso: [hypervisor]\n"); |
1170 | } | 1168 | } |
1171 | 1169 | ||
1172 | if (show & show_mask) { | 1170 | if (show & show_mask) { |
@@ -1197,7 +1195,7 @@ process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | |||
1197 | 1195 | ||
1198 | thread = threads__findnew(event->mmap.pid, &threads, &last_match); | 1196 | thread = threads__findnew(event->mmap.pid, &threads, &last_match); |
1199 | 1197 | ||
1200 | dprintf("%p [%p]: PERF_EVENT_MMAP %d/%d: [%p(%p) @ %p]: %s\n", | 1198 | dump_printf("%p [%p]: PERF_EVENT_MMAP %d/%d: [%p(%p) @ %p]: %s\n", |
1201 | (void *)(offset + head), | 1199 | (void *)(offset + head), |
1202 | (void *)(long)(event->header.size), | 1200 | (void *)(long)(event->header.size), |
1203 | event->mmap.pid, | 1201 | event->mmap.pid, |
@@ -1208,7 +1206,7 @@ process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | |||
1208 | event->mmap.filename); | 1206 | event->mmap.filename); |
1209 | 1207 | ||
1210 | if (thread == NULL || map == NULL) { | 1208 | if (thread == NULL || map == NULL) { |
1211 | dprintf("problem processing PERF_EVENT_MMAP, skipping event.\n"); | 1209 | dump_printf("problem processing PERF_EVENT_MMAP, skipping event.\n"); |
1212 | return 0; | 1210 | return 0; |
1213 | } | 1211 | } |
1214 | 1212 | ||
@@ -1225,14 +1223,14 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head) | |||
1225 | 1223 | ||
1226 | thread = threads__findnew(event->comm.pid, &threads, &last_match); | 1224 | thread = threads__findnew(event->comm.pid, &threads, &last_match); |
1227 | 1225 | ||
1228 | dprintf("%p [%p]: PERF_EVENT_COMM: %s:%d\n", | 1226 | dump_printf("%p [%p]: PERF_EVENT_COMM: %s:%d\n", |
1229 | (void *)(offset + head), | 1227 | (void *)(offset + head), |
1230 | (void *)(long)(event->header.size), | 1228 | (void *)(long)(event->header.size), |
1231 | event->comm.comm, event->comm.pid); | 1229 | event->comm.comm, event->comm.pid); |
1232 | 1230 | ||
1233 | if (thread == NULL || | 1231 | if (thread == NULL || |
1234 | thread__set_comm(thread, event->comm.comm)) { | 1232 | thread__set_comm(thread, event->comm.comm)) { |
1235 | dprintf("problem processing PERF_EVENT_COMM, skipping event.\n"); | 1233 | dump_printf("problem processing PERF_EVENT_COMM, skipping event.\n"); |
1236 | return -1; | 1234 | return -1; |
1237 | } | 1235 | } |
1238 | total_comm++; | 1236 | total_comm++; |
@@ -1249,7 +1247,7 @@ process_task_event(event_t *event, unsigned long offset, unsigned long head) | |||
1249 | thread = threads__findnew(event->fork.pid, &threads, &last_match); | 1247 | thread = threads__findnew(event->fork.pid, &threads, &last_match); |
1250 | parent = threads__findnew(event->fork.ppid, &threads, &last_match); | 1248 | parent = threads__findnew(event->fork.ppid, &threads, &last_match); |
1251 | 1249 | ||
1252 | dprintf("%p [%p]: PERF_EVENT_%s: (%d:%d):(%d:%d)\n", | 1250 | dump_printf("%p [%p]: PERF_EVENT_%s: (%d:%d):(%d:%d)\n", |
1253 | (void *)(offset + head), | 1251 | (void *)(offset + head), |
1254 | (void *)(long)(event->header.size), | 1252 | (void *)(long)(event->header.size), |
1255 | event->header.type == PERF_EVENT_FORK ? "FORK" : "EXIT", | 1253 | event->header.type == PERF_EVENT_FORK ? "FORK" : "EXIT", |
@@ -1267,7 +1265,7 @@ process_task_event(event_t *event, unsigned long offset, unsigned long head) | |||
1267 | return 0; | 1265 | return 0; |
1268 | 1266 | ||
1269 | if (!thread || !parent || thread__fork(thread, parent)) { | 1267 | if (!thread || !parent || thread__fork(thread, parent)) { |
1270 | dprintf("problem processing PERF_EVENT_FORK, skipping event.\n"); | 1268 | dump_printf("problem processing PERF_EVENT_FORK, skipping event.\n"); |
1271 | return -1; | 1269 | return -1; |
1272 | } | 1270 | } |
1273 | total_fork++; | 1271 | total_fork++; |
@@ -1278,7 +1276,7 @@ process_task_event(event_t *event, unsigned long offset, unsigned long head) | |||
1278 | static int | 1276 | static int |
1279 | process_lost_event(event_t *event, unsigned long offset, unsigned long head) | 1277 | process_lost_event(event_t *event, unsigned long offset, unsigned long head) |
1280 | { | 1278 | { |
1281 | dprintf("%p [%p]: PERF_EVENT_LOST: id:%Ld: lost:%Ld\n", | 1279 | dump_printf("%p [%p]: PERF_EVENT_LOST: id:%Ld: lost:%Ld\n", |
1282 | (void *)(offset + head), | 1280 | (void *)(offset + head), |
1283 | (void *)(long)(event->header.size), | 1281 | (void *)(long)(event->header.size), |
1284 | event->lost.id, | 1282 | event->lost.id, |
@@ -1298,12 +1296,12 @@ static void trace_event(event_t *event) | |||
1298 | if (!dump_trace) | 1296 | if (!dump_trace) |
1299 | return; | 1297 | return; |
1300 | 1298 | ||
1301 | dprintf("."); | 1299 | dump_printf("."); |
1302 | cdprintf("\n. ... raw event: size %d bytes\n", event->header.size); | 1300 | cdprintf("\n. ... raw event: size %d bytes\n", event->header.size); |
1303 | 1301 | ||
1304 | for (i = 0; i < event->header.size; i++) { | 1302 | for (i = 0; i < event->header.size; i++) { |
1305 | if ((i & 15) == 0) { | 1303 | if ((i & 15) == 0) { |
1306 | dprintf("."); | 1304 | dump_printf("."); |
1307 | cdprintf(" %04x: ", i); | 1305 | cdprintf(" %04x: ", i); |
1308 | } | 1306 | } |
1309 | 1307 | ||
@@ -1322,7 +1320,7 @@ static void trace_event(event_t *event) | |||
1322 | cdprintf("\n"); | 1320 | cdprintf("\n"); |
1323 | } | 1321 | } |
1324 | } | 1322 | } |
1325 | dprintf(".\n"); | 1323 | dump_printf(".\n"); |
1326 | } | 1324 | } |
1327 | 1325 | ||
1328 | static struct perf_header *header; | 1326 | static struct perf_header *header; |
@@ -1359,7 +1357,7 @@ process_read_event(event_t *event, unsigned long offset, unsigned long head) | |||
1359 | event->read.value); | 1357 | event->read.value); |
1360 | } | 1358 | } |
1361 | 1359 | ||
1362 | dprintf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n", | 1360 | dump_printf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n", |
1363 | (void *)(offset + head), | 1361 | (void *)(offset + head), |
1364 | (void *)(long)(event->header.size), | 1362 | (void *)(long)(event->header.size), |
1365 | event->read.pid, | 1363 | event->read.pid, |
@@ -1540,14 +1538,14 @@ more: | |||
1540 | 1538 | ||
1541 | size = event->header.size; | 1539 | size = event->header.size; |
1542 | 1540 | ||
1543 | dprintf("\n%p [%p]: event: %d\n", | 1541 | dump_printf("\n%p [%p]: event: %d\n", |
1544 | (void *)(offset + head), | 1542 | (void *)(offset + head), |
1545 | (void *)(long)event->header.size, | 1543 | (void *)(long)event->header.size, |
1546 | event->header.type); | 1544 | event->header.type); |
1547 | 1545 | ||
1548 | if (!size || process_event(event, offset, head) < 0) { | 1546 | if (!size || process_event(event, offset, head) < 0) { |
1549 | 1547 | ||
1550 | dprintf("%p [%p]: skipping unknown header type: %d\n", | 1548 | dump_printf("%p [%p]: skipping unknown header type: %d\n", |
1551 | (void *)(offset + head), | 1549 | (void *)(offset + head), |
1552 | (void *)(long)(event->header.size), | 1550 | (void *)(long)(event->header.size), |
1553 | event->header.type); | 1551 | event->header.type); |
@@ -1577,12 +1575,12 @@ done: | |||
1577 | rc = EXIT_SUCCESS; | 1575 | rc = EXIT_SUCCESS; |
1578 | close(input); | 1576 | close(input); |
1579 | 1577 | ||
1580 | dprintf(" IP events: %10ld\n", total); | 1578 | dump_printf(" IP events: %10ld\n", total); |
1581 | dprintf(" mmap events: %10ld\n", total_mmap); | 1579 | dump_printf(" mmap events: %10ld\n", total_mmap); |
1582 | dprintf(" comm events: %10ld\n", total_comm); | 1580 | dump_printf(" comm events: %10ld\n", total_comm); |
1583 | dprintf(" fork events: %10ld\n", total_fork); | 1581 | dump_printf(" fork events: %10ld\n", total_fork); |
1584 | dprintf(" lost events: %10ld\n", total_lost); | 1582 | dump_printf(" lost events: %10ld\n", total_lost); |
1585 | dprintf(" unknown events: %10ld\n", total_unknown); | 1583 | dump_printf(" unknown events: %10ld\n", total_unknown); |
1586 | 1584 | ||
1587 | if (dump_trace) | 1585 | if (dump_trace) |
1588 | return 0; | 1586 | return 0; |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 7cb8464abe61..8318fdee4778 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | 7 | ||
8 | int verbose = 0; | 8 | int verbose = 0; |
9 | int dump_trace = 0; | ||
9 | 10 | ||
10 | int eprintf(const char *fmt, ...) | 11 | int eprintf(const char *fmt, ...) |
11 | { | 12 | { |
@@ -20,3 +21,17 @@ int eprintf(const char *fmt, ...) | |||
20 | 21 | ||
21 | return ret; | 22 | return ret; |
22 | } | 23 | } |
24 | |||
25 | int dump_printf(const char *fmt, ...) | ||
26 | { | ||
27 | va_list args; | ||
28 | int ret = 0; | ||
29 | |||
30 | if (dump_trace) { | ||
31 | va_start(args, fmt); | ||
32 | ret = vprintf(fmt, args); | ||
33 | va_end(args); | ||
34 | } | ||
35 | |||
36 | return ret; | ||
37 | } | ||
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 2ae9090108d3..a683bd571f1c 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -1,5 +1,7 @@ | |||
1 | /* For debugging general purposes */ | 1 | /* For debugging general purposes */ |
2 | 2 | ||
3 | extern int verbose; | 3 | extern int verbose; |
4 | extern int dump_trace; | ||
4 | 5 | ||
5 | int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 6 | int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
7 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | ||