aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/debug.c')
-rw-r--r--tools/perf/util/debug.c75
1 files changed, 48 insertions, 27 deletions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index ff7e86ad1b06..8c4212abd19b 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -106,40 +106,61 @@ int dump_printf(const char *fmt, ...)
106 return ret; 106 return ret;
107} 107}
108 108
109static void trace_event_printer(enum binary_printer_ops op,
110 unsigned int val, void *extra)
111{
112 const char *color = PERF_COLOR_BLUE;
113 union perf_event *event = (union perf_event *)extra;
114 unsigned char ch = (unsigned char)val;
115
116 switch (op) {
117 case BINARY_PRINT_DATA_BEGIN:
118 printf(".");
119 color_fprintf(stdout, color, "\n. ... raw event: size %d bytes\n",
120 event->header.size);
121 break;
122 case BINARY_PRINT_LINE_BEGIN:
123 printf(".");
124 break;
125 case BINARY_PRINT_ADDR:
126 color_fprintf(stdout, color, " %04x: ", val);
127 break;
128 case BINARY_PRINT_NUM_DATA:
129 color_fprintf(stdout, color, " %02x", val);
130 break;
131 case BINARY_PRINT_NUM_PAD:
132 color_fprintf(stdout, color, " ");
133 break;
134 case BINARY_PRINT_SEP:
135 color_fprintf(stdout, color, " ");
136 break;
137 case BINARY_PRINT_CHAR_DATA:
138 color_fprintf(stdout, color, "%c",
139 isprint(ch) ? ch : '.');
140 break;
141 case BINARY_PRINT_CHAR_PAD:
142 color_fprintf(stdout, color, " ");
143 break;
144 case BINARY_PRINT_LINE_END:
145 color_fprintf(stdout, color, "\n");
146 break;
147 case BINARY_PRINT_DATA_END:
148 printf("\n");
149 break;
150 default:
151 break;
152 }
153}
154
109void trace_event(union perf_event *event) 155void trace_event(union perf_event *event)
110{ 156{
111 unsigned char *raw_event = (void *)event; 157 unsigned char *raw_event = (void *)event;
112 const char *color = PERF_COLOR_BLUE;
113 int i, j;
114 158
115 if (!dump_trace) 159 if (!dump_trace)
116 return; 160 return;
117 161
118 printf("."); 162 print_binary(raw_event, event->header.size, 16,
119 color_fprintf(stdout, color, "\n. ... raw event: size %d bytes\n", 163 trace_event_printer, event);
120 event->header.size);
121
122 for (i = 0; i < event->header.size; i++) {
123 if ((i & 15) == 0) {
124 printf(".");
125 color_fprintf(stdout, color, " %04x: ", i);
126 }
127
128 color_fprintf(stdout, color, " %02x", raw_event[i]);
129
130 if (((i & 15) == 15) || i == event->header.size-1) {
131 color_fprintf(stdout, color, " ");
132 for (j = 0; j < 15-(i & 15); j++)
133 color_fprintf(stdout, color, " ");
134 for (j = i & ~15; j <= i; j++) {
135 color_fprintf(stdout, color, "%c",
136 isprint(raw_event[j]) ?
137 raw_event[j] : '.');
138 }
139 color_fprintf(stdout, color, "\n");
140 }
141 }
142 printf(".\n");
143} 164}
144 165
145static struct debug_variable { 166static struct debug_variable {