xHCI: Cleanup isoc transfer ring when TD length mismatch found
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / tools / perf / util / debug.c
blob26817daa2961b5dc3eb0f6181238dc707fa7bdc9
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"
15 int verbose;
16 bool dump_trace = false, quiet = false;
18 int eprintf(int level, const char *fmt, ...)
20 va_list args;
21 int ret = 0;
23 if (verbose >= level) {
24 va_start(args, fmt);
25 if (use_browser > 0)
26 ret = ui_helpline__show_help(fmt, args);
27 else
28 ret = vfprintf(stderr, fmt, args);
29 va_end(args);
32 return ret;
35 int dump_printf(const char *fmt, ...)
37 va_list args;
38 int ret = 0;
40 if (dump_trace) {
41 va_start(args, fmt);
42 ret = vprintf(fmt, args);
43 va_end(args);
46 return ret;
49 #ifdef NO_NEWT_SUPPORT
50 int ui__warning(const char *format, ...)
52 va_list args;
54 va_start(args, format);
55 vfprintf(stderr, format, args);
56 va_end(args);
57 return 0;
59 #endif
61 int ui__error_paranoid(void)
63 return ui__error("Permission error - are you root?\n"
64 "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
65 " -1 - Not paranoid at all\n"
66 " 0 - Disallow raw tracepoint access for unpriv\n"
67 " 1 - Disallow cpu events for unpriv\n"
68 " 2 - Disallow kernel profiling for unpriv\n");
71 void trace_event(union perf_event *event)
73 unsigned char *raw_event = (void *)event;
74 const char *color = PERF_COLOR_BLUE;
75 int i, j;
77 if (!dump_trace)
78 return;
80 printf(".");
81 color_fprintf(stdout, color, "\n. ... raw event: size %d bytes\n",
82 event->header.size);
84 for (i = 0; i < event->header.size; i++) {
85 if ((i & 15) == 0) {
86 printf(".");
87 color_fprintf(stdout, color, " %04x: ", i);
90 color_fprintf(stdout, color, " %02x", raw_event[i]);
92 if (((i & 15) == 15) || i == event->header.size-1) {
93 color_fprintf(stdout, color, " ");
94 for (j = 0; j < 15-(i & 15); j++)
95 color_fprintf(stdout, color, " ");
96 for (j = i & ~15; j <= i; j++) {
97 color_fprintf(stdout, color, "%c",
98 isprint(raw_event[j]) ?
99 raw_event[j] : '.');
101 color_fprintf(stdout, color, "\n");
104 printf(".\n");