Merge remote-tracking branches 'asoc/topic/txx9', 'asoc/topic/wm8750', 'asoc/topic...
[cascardo/linux.git] / tools / perf / util / debug.h
1 /* For debugging general purposes */
2 #ifndef __PERF_DEBUG_H
3 #define __PERF_DEBUG_H
4
5 #include <stdbool.h>
6 #include <string.h>
7 #include "event.h"
8 #include "../ui/helpline.h"
9 #include "../ui/progress.h"
10 #include "../ui/util.h"
11
12 extern int verbose;
13 extern bool quiet, dump_trace;
14 extern int debug_ordered_events;
15
16 #ifndef pr_fmt
17 #define pr_fmt(fmt) fmt
18 #endif
19
20 #define pr_err(fmt, ...) \
21         eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
22 #define pr_warning(fmt, ...) \
23         eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
24 #define pr_info(fmt, ...) \
25         eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
26 #define pr_debug(fmt, ...) \
27         eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
28 #define pr_debugN(n, fmt, ...) \
29         eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
30 #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
31 #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
32 #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
33
34 #define pr_time_N(n, var, t, fmt, ...) \
35         eprintf_time(n, var, t, fmt, ##__VA_ARGS__)
36
37 #define pr_oe_time(t, fmt, ...)  pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
38 #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
39
40 #define STRERR_BUFSIZE  128     /* For the buffer size of strerror_r */
41
42 int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
43 void trace_event(union perf_event *event);
44
45 int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
46 int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
47
48 void pr_stat(const char *fmt, ...);
49
50 int eprintf(int level, int var, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
51 int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
52
53 int perf_debug_option(const char *str);
54
55 #endif  /* __PERF_DEBUG_H */