x86/xen: resume timer irqs early
[linux/fpc-iii.git] / tools / perf / util / debug.c
blob399e74c34c1aa5220ecc29bd0d33cca2d2a3ac82
1 /* For general debugging purposes */
3 #include "../perf.h"
5 #include <string.h>
6 #include <stdarg.h>
7 #include <stdio.h>
9 #include "cache.h"
10 #include "color.h"
11 #include "event.h"
12 #include "debug.h"
13 #include "util.h"
14 #include "target.h"
16 int verbose;
17 bool dump_trace = false, quiet = false;
19 int eprintf(int level, const char *fmt, ...)
21 va_list args;
22 int ret = 0;
24 if (verbose >= level) {
25 va_start(args, fmt);
26 if (use_browser >= 1)
27 ui_helpline__vshow(fmt, args);
28 else
29 ret = vfprintf(stderr, fmt, args);
30 va_end(args);
33 return ret;
36 int dump_printf(const char *fmt, ...)
38 va_list args;
39 int ret = 0;
41 if (dump_trace) {
42 va_start(args, fmt);
43 ret = vprintf(fmt, args);
44 va_end(args);
47 return ret;
50 void trace_event(union perf_event *event)
52 unsigned char *raw_event = (void *)event;
53 const char *color = PERF_COLOR_BLUE;
54 int i, j;
56 if (!dump_trace)
57 return;
59 printf(".");
60 color_fprintf(stdout, color, "\n. ... raw event: size %d bytes\n",
61 event->header.size);
63 for (i = 0; i < event->header.size; i++) {
64 if ((i & 15) == 0) {
65 printf(".");
66 color_fprintf(stdout, color, " %04x: ", i);
69 color_fprintf(stdout, color, " %02x", raw_event[i]);
71 if (((i & 15) == 15) || i == event->header.size-1) {
72 color_fprintf(stdout, color, " ");
73 for (j = 0; j < 15-(i & 15); j++)
74 color_fprintf(stdout, color, " ");
75 for (j = i & ~15; j <= i; j++) {
76 color_fprintf(stdout, color, "%c",
77 isprint(raw_event[j]) ?
78 raw_event[j] : '.');
80 color_fprintf(stdout, color, "\n");
83 printf(".\n");