Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
cd84c2ac | 2 | /* For debugging general purposes */ |
8b40f521 JK |
3 | #ifndef __PERF_DEBUG_H |
4 | #define __PERF_DEBUG_H | |
cd84c2ac | 5 | |
b22bb139 | 6 | #include <stdarg.h> |
c0555642 | 7 | #include <stdbool.h> |
8abceacf | 8 | #include <stdio.h> |
afaed6d3 | 9 | #include <linux/compiler.h> |
8f41146a | 10 | |
cd84c2ac | 11 | extern int verbose; |
0bdfbd04 | 12 | extern int debug_kmaps; |
ccd26741 | 13 | extern int debug_peo_args; |
b44308f5 | 14 | extern bool quiet, dump_trace; |
cee3ab9c | 15 | extern int debug_ordered_events; |
edbe9817 | 16 | extern int debug_data_convert; |
90429524 | 17 | extern int debug_type_profile; |
cd84c2ac | 18 | |
84f5d36f JO |
19 | #ifndef pr_fmt |
20 | #define pr_fmt(fmt) fmt | |
21 | #endif | |
22 | ||
23 | #define pr_err(fmt, ...) \ | |
c95688aa | 24 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
84f5d36f | 25 | #define pr_warning(fmt, ...) \ |
c95688aa | 26 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
1094795e JC |
27 | #define pr_warning_once(fmt, ...) ({ \ |
28 | static int __warned; \ | |
29 | if (unlikely(!__warned)) { \ | |
30 | pr_warning(fmt, ##__VA_ARGS__); \ | |
31 | __warned = 1; \ | |
32 | } \ | |
33 | }) | |
84f5d36f | 34 | #define pr_info(fmt, ...) \ |
c95688aa | 35 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
84f5d36f | 36 | #define pr_debug(fmt, ...) \ |
c95688aa | 37 | eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
84f5d36f | 38 | #define pr_debugN(n, fmt, ...) \ |
c95688aa | 39 | eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
84f5d36f JO |
40 | #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__) |
41 | #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__) | |
42 | #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__) | |
43 | ||
ccd26741 RB |
44 | /* Special macro to print perf_event_open arguments/return value. */ |
45 | #define pr_debug2_peo(fmt, ...) { \ | |
46 | if (debug_peo_args) \ | |
47 | pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ | |
48 | else \ | |
49 | pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ | |
50 | } | |
51 | ||
cee3ab9c JO |
52 | #define pr_time_N(n, var, t, fmt, ...) \ |
53 | eprintf_time(n, var, t, fmt, ##__VA_ARGS__) | |
54 | ||
55 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) | |
56 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) | |
57 | ||
c8b5f2c9 | 58 | #define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */ |
b2348e1d | 59 | |
8520a98d ACM |
60 | union perf_event; |
61 | ||
afaed6d3 | 62 | int dump_printf(const char *fmt, ...) __printf(1, 2); |
8115d60c | 63 | void trace_event(union perf_event *event); |
567e5479 | 64 | |
afaed6d3 ACM |
65 | int ui__error(const char *format, ...) __printf(1, 2); |
66 | int ui__warning(const char *format, ...) __printf(1, 2); | |
1094795e JC |
67 | #define ui__warning_once(format, ...) ({ \ |
68 | static int __warned; \ | |
69 | if (unlikely(!__warned)) { \ | |
70 | ui__warning(format, ##__VA_ARGS__); \ | |
71 | __warned = 1; \ | |
72 | } \ | |
73 | }) | |
068ffaa8 | 74 | |
f772abc6 JO |
75 | void pr_stat(const char *fmt, ...); |
76 | ||
afaed6d3 ACM |
77 | int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4); |
78 | int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5); | |
0af0885e | 79 | int veprintf(int level, int var, const char *fmt, va_list args); |
84f5d36f | 80 | |
bbb2cea7 | 81 | int perf_debug_option(const char *str); |
ec49230c | 82 | FILE *debug_file(void); |
8abceacf | 83 | void debug_set_file(FILE *file); |
bcbd79d1 | 84 | void debug_set_display_time(bool set); |
dd629cc0 | 85 | void perf_debug_setup(void); |
80df1988 | 86 | int perf_quiet_option(void); |
bbb2cea7 | 87 | |
8c2b7cac ACM |
88 | void dump_stack(void); |
89 | void sighandler_dump_stack(int sig); | |
90 | ||
8b40f521 | 91 | #endif /* __PERF_DEBUG_H */ |