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.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index f9c7e3ad1aa7..155749d74350 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -12,8 +12,8 @@
12#include "debug.h" 12#include "debug.h"
13#include "util.h" 13#include "util.h"
14 14
15int verbose = 0; 15int verbose;
16bool dump_trace = false; 16bool dump_trace = false, quiet = false;
17 17
18int eprintf(int level, const char *fmt, ...) 18int eprintf(int level, const char *fmt, ...)
19{ 19{
@@ -46,22 +46,28 @@ int dump_printf(const char *fmt, ...)
46 return ret; 46 return ret;
47} 47}
48 48
49static int dump_printf_color(const char *fmt, const char *color, ...) 49#ifdef NO_NEWT_SUPPORT
50void ui__warning(const char *format, ...)
50{ 51{
51 va_list args; 52 va_list args;
52 int ret = 0;
53
54 if (dump_trace) {
55 va_start(args, color);
56 ret = color_vfprintf(stdout, color, fmt, args);
57 va_end(args);
58 }
59 53
60 return ret; 54 va_start(args, format);
55 vfprintf(stderr, format, args);
56 va_end(args);
61} 57}
58#endif
62 59
60void ui__warning_paranoid(void)
61{
62 ui__warning("Permission error - are you root?\n"
63 "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
64 " -1 - Not paranoid at all\n"
65 " 0 - Disallow raw tracepoint access for unpriv\n"
66 " 1 - Disallow cpu events for unpriv\n"
67 " 2 - Disallow kernel profiling for unpriv\n");
68}
63 69
64void trace_event(event_t *event) 70void trace_event(union perf_event *event)
65{ 71{
66 unsigned char *raw_event = (void *)event; 72 unsigned char *raw_event = (void *)event;
67 const char *color = PERF_COLOR_BLUE; 73 const char *color = PERF_COLOR_BLUE;
@@ -70,29 +76,29 @@ void trace_event(event_t *event)
70 if (!dump_trace) 76 if (!dump_trace)
71 return; 77 return;
72 78
73 dump_printf("."); 79 printf(".");
74 dump_printf_color("\n. ... raw event: size %d bytes\n", color, 80 color_fprintf(stdout, color, "\n. ... raw event: size %d bytes\n",
75 event->header.size); 81 event->header.size);
76 82
77 for (i = 0; i < event->header.size; i++) { 83 for (i = 0; i < event->header.size; i++) {
78 if ((i & 15) == 0) { 84 if ((i & 15) == 0) {
79 dump_printf("."); 85 printf(".");
80 dump_printf_color(" %04x: ", color, i); 86 color_fprintf(stdout, color, " %04x: ", i);
81 } 87 }
82 88
83 dump_printf_color(" %02x", color, raw_event[i]); 89 color_fprintf(stdout, color, " %02x", raw_event[i]);
84 90
85 if (((i & 15) == 15) || i == event->header.size-1) { 91 if (((i & 15) == 15) || i == event->header.size-1) {
86 dump_printf_color(" ", color); 92 color_fprintf(stdout, color, " ");
87 for (j = 0; j < 15-(i & 15); j++) 93 for (j = 0; j < 15-(i & 15); j++)
88 dump_printf_color(" ", color); 94 color_fprintf(stdout, color, " ");
89 for (j = i & ~15; j <= i; j++) { 95 for (j = i & ~15; j <= i; j++) {
90 dump_printf_color("%c", color, 96 color_fprintf(stdout, color, "%c",
91 isprint(raw_event[j]) ? 97 isprint(raw_event[j]) ?
92 raw_event[j] : '.'); 98 raw_event[j] : '.');
93 } 99 }
94 dump_printf_color("\n", color); 100 color_fprintf(stdout, color, "\n");
95 } 101 }
96 } 102 }
97 dump_printf(".\n"); 103 printf(".\n");
98} 104}