diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-annotate.c | 1 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 1 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 39 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 2 | ||||
-rw-r--r-- | tools/perf/perf.h | 1 | ||||
-rw-r--r-- | tools/perf/util/color.c | 10 | ||||
-rw-r--r-- | tools/perf/util/color.h | 1 | ||||
-rw-r--r-- | tools/perf/util/debug.c | 58 | ||||
-rw-r--r-- | tools/perf/util/debug.h | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 2 |
11 files changed, 76 insertions, 42 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 6d751516616d..96d421f7161d 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "util/string.h" | 17 | #include "util/string.h" |
18 | 18 | ||
19 | #include "perf.h" | 19 | #include "perf.h" |
20 | #include "util/debug.h" | ||
20 | 21 | ||
21 | #include "util/parse-options.h" | 22 | #include "util/parse-options.h" |
22 | #include "util/parse-events.h" | 23 | #include "util/parse-events.h" |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 65b4115e417d..6a5db675ee4f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include "util/header.h" | 17 | #include "util/header.h" |
18 | #include "util/event.h" | 18 | #include "util/event.h" |
19 | #include "util/debug.h" | ||
19 | 20 | ||
20 | #include <unistd.h> | 21 | #include <unistd.h> |
21 | #include <sched.h> | 22 | #include <sched.h> |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c6326deb1636..1e3ad22d53dc 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "util/values.h" | 20 | #include "util/values.h" |
21 | 21 | ||
22 | #include "perf.h" | 22 | #include "perf.h" |
23 | #include "util/debug.h" | ||
23 | #include "util/header.h" | 24 | #include "util/header.h" |
24 | 25 | ||
25 | #include "util/parse-options.h" | 26 | #include "util/parse-options.h" |
@@ -39,8 +40,6 @@ static char *field_sep; | |||
39 | static int input; | 40 | static int input; |
40 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 41 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
41 | 42 | ||
42 | #define cdprintf(x...) do { if (dump_trace) color_fprintf(stdout, color, x); } while (0) | ||
43 | |||
44 | static int full_paths; | 43 | static int full_paths; |
45 | static int show_nr_samples; | 44 | static int show_nr_samples; |
46 | 45 | ||
@@ -1285,42 +1284,6 @@ process_lost_event(event_t *event, unsigned long offset, unsigned long head) | |||
1285 | return 0; | 1284 | return 0; |
1286 | } | 1285 | } |
1287 | 1286 | ||
1288 | static void trace_event(event_t *event) | ||
1289 | { | ||
1290 | unsigned char *raw_event = (void *)event; | ||
1291 | const char *color = PERF_COLOR_BLUE; | ||
1292 | int i, j; | ||
1293 | |||
1294 | if (!dump_trace) | ||
1295 | return; | ||
1296 | |||
1297 | dump_printf("."); | ||
1298 | cdprintf("\n. ... raw event: size %d bytes\n", event->header.size); | ||
1299 | |||
1300 | for (i = 0; i < event->header.size; i++) { | ||
1301 | if ((i & 15) == 0) { | ||
1302 | dump_printf("."); | ||
1303 | cdprintf(" %04x: ", i); | ||
1304 | } | ||
1305 | |||
1306 | cdprintf(" %02x", raw_event[i]); | ||
1307 | |||
1308 | if (((i & 15) == 15) || i == event->header.size-1) { | ||
1309 | cdprintf(" "); | ||
1310 | for (j = 0; j < 15-(i & 15); j++) | ||
1311 | cdprintf(" "); | ||
1312 | for (j = 0; j < (i & 15); j++) { | ||
1313 | if (isprint(raw_event[i-15+j])) | ||
1314 | cdprintf("%c", raw_event[i-15+j]); | ||
1315 | else | ||
1316 | cdprintf("."); | ||
1317 | } | ||
1318 | cdprintf("\n"); | ||
1319 | } | ||
1320 | } | ||
1321 | dump_printf(".\n"); | ||
1322 | } | ||
1323 | |||
1324 | static int | 1287 | static int |
1325 | process_read_event(event_t *event, unsigned long offset, unsigned long head) | 1288 | process_read_event(event_t *event, unsigned long offset, unsigned long head) |
1326 | { | 1289 | { |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 4b9dd4af61a6..1a2626230660 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -42,6 +42,8 @@ | |||
42 | #include "util/util.h" | 42 | #include "util/util.h" |
43 | #include "util/parse-options.h" | 43 | #include "util/parse-options.h" |
44 | #include "util/parse-events.h" | 44 | #include "util/parse-events.h" |
45 | #include "util/event.h" | ||
46 | #include "util/debug.h" | ||
45 | 47 | ||
46 | #include <sys/prctl.h> | 48 | #include <sys/prctl.h> |
47 | #include <math.h> | 49 | #include <math.h> |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 06f763e4b35b..62b55ecab2c6 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include "util/parse-options.h" | 27 | #include "util/parse-options.h" |
28 | #include "util/parse-events.h" | 28 | #include "util/parse-events.h" |
29 | 29 | ||
30 | #include "util/debug.h" | ||
31 | |||
30 | #include <assert.h> | 32 | #include <assert.h> |
31 | #include <fcntl.h> | 33 | #include <fcntl.h> |
32 | 34 | ||
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index f5509213f030..e5148e2b6134 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -48,7 +48,6 @@ | |||
48 | 48 | ||
49 | #include "../../include/linux/perf_counter.h" | 49 | #include "../../include/linux/perf_counter.h" |
50 | #include "util/types.h" | 50 | #include "util/types.h" |
51 | #include "util/debug.h" | ||
52 | 51 | ||
53 | /* | 52 | /* |
54 | * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all | 53 | * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all |
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index e47fdeb85391..e88bca55a599 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c | |||
@@ -166,7 +166,7 @@ int perf_color_default_config(const char *var, const char *value, void *cb) | |||
166 | return perf_default_config(var, value, cb); | 166 | return perf_default_config(var, value, cb); |
167 | } | 167 | } |
168 | 168 | ||
169 | static int color_vfprintf(FILE *fp, const char *color, const char *fmt, | 169 | static int __color_vfprintf(FILE *fp, const char *color, const char *fmt, |
170 | va_list args, const char *trail) | 170 | va_list args, const char *trail) |
171 | { | 171 | { |
172 | int r = 0; | 172 | int r = 0; |
@@ -191,6 +191,10 @@ static int color_vfprintf(FILE *fp, const char *color, const char *fmt, | |||
191 | return r; | 191 | return r; |
192 | } | 192 | } |
193 | 193 | ||
194 | int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args) | ||
195 | { | ||
196 | return __color_vfprintf(fp, color, fmt, args, NULL); | ||
197 | } | ||
194 | 198 | ||
195 | 199 | ||
196 | int color_fprintf(FILE *fp, const char *color, const char *fmt, ...) | 200 | int color_fprintf(FILE *fp, const char *color, const char *fmt, ...) |
@@ -199,7 +203,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...) | |||
199 | int r; | 203 | int r; |
200 | 204 | ||
201 | va_start(args, fmt); | 205 | va_start(args, fmt); |
202 | r = color_vfprintf(fp, color, fmt, args, NULL); | 206 | r = color_vfprintf(fp, color, fmt, args); |
203 | va_end(args); | 207 | va_end(args); |
204 | return r; | 208 | return r; |
205 | } | 209 | } |
@@ -209,7 +213,7 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...) | |||
209 | va_list args; | 213 | va_list args; |
210 | int r; | 214 | int r; |
211 | va_start(args, fmt); | 215 | va_start(args, fmt); |
212 | r = color_vfprintf(fp, color, fmt, args, "\n"); | 216 | r = __color_vfprintf(fp, color, fmt, args, "\n"); |
213 | va_end(args); | 217 | va_end(args); |
214 | return r; | 218 | return r; |
215 | } | 219 | } |
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index 43d0d1b67c45..58d597564b99 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h | |||
@@ -32,6 +32,7 @@ int perf_color_default_config(const char *var, const char *value, void *cb); | |||
32 | int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty); | 32 | int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty); |
33 | void color_parse(const char *value, const char *var, char *dst); | 33 | void color_parse(const char *value, const char *var, char *dst); |
34 | void color_parse_mem(const char *value, int len, const char *var, char *dst); | 34 | void color_parse_mem(const char *value, int len, const char *var, char *dst); |
35 | int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args); | ||
35 | int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); | 36 | int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); |
36 | int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); | 37 | int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); |
37 | int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); | 38 | int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 8318fdee4778..e8ca98fe0bd4 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -1,10 +1,15 @@ | |||
1 | /* For general debugging purposes */ | 1 | /* For general debugging purposes */ |
2 | 2 | ||
3 | #include "../perf.h" | 3 | #include "../perf.h" |
4 | |||
4 | #include <string.h> | 5 | #include <string.h> |
5 | #include <stdarg.h> | 6 | #include <stdarg.h> |
6 | #include <stdio.h> | 7 | #include <stdio.h> |
7 | 8 | ||
9 | #include "color.h" | ||
10 | #include "event.h" | ||
11 | #include "debug.h" | ||
12 | |||
8 | int verbose = 0; | 13 | int verbose = 0; |
9 | int dump_trace = 0; | 14 | int dump_trace = 0; |
10 | 15 | ||
@@ -35,3 +40,56 @@ int dump_printf(const char *fmt, ...) | |||
35 | 40 | ||
36 | return ret; | 41 | return ret; |
37 | } | 42 | } |
43 | |||
44 | static int dump_printf_color(const char *fmt, const char *color, ...) | ||
45 | { | ||
46 | va_list args; | ||
47 | int ret = 0; | ||
48 | |||
49 | if (dump_trace) { | ||
50 | va_start(args, color); | ||
51 | ret = color_vfprintf(stdout, color, fmt, args); | ||
52 | va_end(args); | ||
53 | } | ||
54 | |||
55 | return ret; | ||
56 | } | ||
57 | |||
58 | |||
59 | void trace_event(event_t *event) | ||
60 | { | ||
61 | unsigned char *raw_event = (void *)event; | ||
62 | const char *color = PERF_COLOR_BLUE; | ||
63 | int i, j; | ||
64 | |||
65 | if (!dump_trace) | ||
66 | return; | ||
67 | |||
68 | dump_printf("."); | ||
69 | dump_printf_color("\n. ... raw event: size %d bytes\n", color, | ||
70 | event->header.size); | ||
71 | |||
72 | for (i = 0; i < event->header.size; i++) { | ||
73 | if ((i & 15) == 0) { | ||
74 | dump_printf("."); | ||
75 | dump_printf_color(" %04x: ", color, i); | ||
76 | } | ||
77 | |||
78 | dump_printf_color(" %02x", color, raw_event[i]); | ||
79 | |||
80 | if (((i & 15) == 15) || i == event->header.size-1) { | ||
81 | dump_printf_color(" ", color); | ||
82 | for (j = 0; j < 15-(i & 15); j++) | ||
83 | dump_printf_color(" ", color); | ||
84 | for (j = 0; j < (i & 15); j++) { | ||
85 | if (isprint(raw_event[i-15+j])) | ||
86 | dump_printf_color("%c", color, | ||
87 | raw_event[i-15+j]); | ||
88 | else | ||
89 | dump_printf_color(".", color); | ||
90 | } | ||
91 | dump_printf_color("\n", color); | ||
92 | } | ||
93 | } | ||
94 | dump_printf(".\n"); | ||
95 | } | ||
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index a683bd571f1c..437eea58ce40 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -5,3 +5,4 @@ extern int dump_trace; | |||
5 | 5 | ||
6 | 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))); | 7 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
8 | void trace_event(event_t *event); | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 3159d47ae1cc..fd3d9c8e90fc 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -3,6 +3,8 @@ | |||
3 | #include "string.h" | 3 | #include "string.h" |
4 | #include "symbol.h" | 4 | #include "symbol.h" |
5 | 5 | ||
6 | #include "debug.h" | ||
7 | |||
6 | #include <libelf.h> | 8 | #include <libelf.h> |
7 | #include <gelf.h> | 9 | #include <gelf.h> |
8 | #include <elf.h> | 10 | #include <elf.h> |