Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
tools
perf
util
debug.c
Go to the documentation of this file.
1
/* For general debugging purposes */
2
3
#include "../perf.h"
4
5
#include <string.h>
6
#include <stdarg.h>
7
#include <
stdio.h
>
8
9
#include "
cache.h
"
10
#include "
color.h
"
11
#include "
event.h
"
12
#include "
debug.h
"
13
#include "
util.h
"
14
#include "
target.h
"
15
16
int
verbose
;
17
bool
dump_trace
=
false
,
quiet
=
false
;
18
19
int
eprintf
(
int
level
,
const
char
*
fmt
, ...)
20
{
21
va_list
args
;
22
int
ret
= 0;
23
24
if
(
verbose
>= level) {
25
va_start
(args, fmt);
26
if
(
use_browser
== 1)
27
ret =
ui_helpline__show_help
(fmt, args);
28
else
if
(
use_browser
== 2)
29
ret =
perf_gtk__show_helpline
(fmt, args);
30
else
31
ret =
vfprintf
(stderr, fmt, args);
32
va_end
(args);
33
}
34
35
return
ret
;
36
}
37
38
int
dump_printf
(
const
char
*
fmt
, ...)
39
{
40
va_list
args
;
41
int
ret
= 0;
42
43
if
(
dump_trace
) {
44
va_start
(args, fmt);
45
ret = vprintf(fmt, args);
46
va_end
(args);
47
}
48
49
return
ret
;
50
}
51
52
#if !defined(NEWT_SUPPORT) && !defined(GTK2_SUPPORT)
53
int
ui__warning
(
const
char
*
format
, ...)
54
{
55
va_list
args
;
56
57
va_start
(args, format);
58
vfprintf
(stderr, format, args);
59
va_end
(args);
60
return
0;
61
}
62
#endif
63
64
int
ui__error_paranoid
(
void
)
65
{
66
return
ui__error
(
"Permission error - are you root?\n"
67
"Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
68
" -1 - Not paranoid at all\n"
69
" 0 - Disallow raw tracepoint access for unpriv\n"
70
" 1 - Disallow cpu events for unpriv\n"
71
" 2 - Disallow kernel profiling for unpriv\n"
);
72
}
73
74
void
trace_event
(
union
perf_event
*
event
)
75
{
76
unsigned
char
*raw_event = (
void
*)event;
77
const
char
*
color
=
PERF_COLOR_BLUE
;
78
int
i
,
j
;
79
80
if
(!
dump_trace
)
81
return
;
82
83
printf
(
"."
);
84
color_fprintf
(stdout, color,
"\n. ... raw event: size %d bytes\n"
,
85
event->
header
.size);
86
87
for
(i = 0; i <
event
->header.size; i++) {
88
if
((i & 15) == 0) {
89
printf
(
"."
);
90
color_fprintf
(stdout, color,
" %04x: "
, i);
91
}
92
93
color_fprintf
(stdout, color,
" %02x"
, raw_event[i]);
94
95
if
(((i & 15) == 15) || i == event->
header
.size-1) {
96
color_fprintf
(stdout, color,
" "
);
97
for
(j = 0; j < 15-(i & 15); j++)
98
color_fprintf
(stdout, color,
" "
);
99
for
(j = i & ~15; j <=
i
; j++) {
100
color_fprintf
(stdout, color,
"%c"
,
101
isprint
(raw_event[j]) ?
102
raw_event[j] :
'.'
);
103
}
104
color_fprintf
(stdout, color,
"\n"
);
105
}
106
}
107
printf
(
".\n"
);
108
}
Generated on Thu Jan 10 2013 13:07:54 for Linux Kernel by
1.8.2