Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 2 | /* For debugging general purposes */ |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 3 | #ifndef __PERF_DEBUG_H |
| 4 | #define __PERF_DEBUG_H |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 5 | |
Arnaldo Carvalho de Melo | b22bb13 | 2019-09-03 09:57:50 -0300 | [diff] [blame] | 6 | #include <stdarg.h> |
Ian Munsie | c055564 | 2010-04-13 18:37:33 +1000 | [diff] [blame] | 7 | #include <stdbool.h> |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 8 | #include <linux/compiler.h> |
Arnaldo Carvalho de Melo | 8f41146 | 2009-11-16 16:32:42 -0200 | [diff] [blame] | 9 | |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 10 | extern int verbose; |
Ravi Bangoria | ccd2674 | 2019-11-08 15:11:28 +0530 | [diff] [blame] | 11 | extern int debug_peo_args; |
Arnaldo Carvalho de Melo | b44308f | 2010-10-26 15:20:09 -0200 | [diff] [blame] | 12 | extern bool quiet, dump_trace; |
Jiri Olsa | cee3ab9 | 2014-07-11 14:49:54 +0200 | [diff] [blame] | 13 | extern int debug_ordered_events; |
Jiri Olsa | edbe981 | 2015-02-20 23:17:00 +0100 | [diff] [blame] | 14 | extern int debug_data_convert; |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 15 | |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 16 | #ifndef pr_fmt |
| 17 | #define pr_fmt(fmt) fmt |
| 18 | #endif |
| 19 | |
| 20 | #define pr_err(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 21 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 22 | #define pr_warning(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 23 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 24 | #define pr_info(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 25 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 26 | #define pr_debug(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 27 | eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 28 | #define pr_debugN(n, fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 29 | eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 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 | |
Ravi Bangoria | ccd2674 | 2019-11-08 15:11:28 +0530 | [diff] [blame] | 34 | /* Special macro to print perf_event_open arguments/return value. */ |
| 35 | #define pr_debug2_peo(fmt, ...) { \ |
| 36 | if (debug_peo_args) \ |
| 37 | pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ |
| 38 | else \ |
| 39 | pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ |
| 40 | } |
| 41 | |
Jiri Olsa | cee3ab9 | 2014-07-11 14:49:54 +0200 | [diff] [blame] | 42 | #define pr_time_N(n, var, t, fmt, ...) \ |
| 43 | eprintf_time(n, var, t, fmt, ##__VA_ARGS__) |
| 44 | |
| 45 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 46 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 47 | |
Arnaldo Carvalho de Melo | c8b5f2c | 2016-07-06 11:56:20 -0300 | [diff] [blame] | 48 | #define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */ |
Masami Hiramatsu | b2348e1 | 2014-08-14 02:22:32 +0000 | [diff] [blame] | 49 | |
Arnaldo Carvalho de Melo | 8520a98 | 2019-08-29 16:18:59 -0300 | [diff] [blame] | 50 | union perf_event; |
| 51 | |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 52 | int dump_printf(const char *fmt, ...) __printf(1, 2); |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 53 | void trace_event(union perf_event *event); |
Arnaldo Carvalho de Melo | 567e547 | 2010-03-12 21:05:10 -0300 | [diff] [blame] | 54 | |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 55 | int ui__error(const char *format, ...) __printf(1, 2); |
| 56 | int ui__warning(const char *format, ...) __printf(1, 2); |
Arnaldo Carvalho de Melo | 068ffaa | 2010-11-27 02:41:01 -0200 | [diff] [blame] | 57 | |
Jiri Olsa | f772abc | 2013-12-03 14:09:25 +0100 | [diff] [blame] | 58 | void pr_stat(const char *fmt, ...); |
| 59 | |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 60 | int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4); |
| 61 | int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5); |
Wang Nan | 0af0885 | 2015-07-31 10:35:33 -0300 | [diff] [blame] | 62 | int veprintf(int level, int var, const char *fmt, va_list args); |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 63 | |
Jiri Olsa | bbb2cea | 2014-07-17 12:55:00 +0200 | [diff] [blame] | 64 | int perf_debug_option(const char *str); |
Jiri Olsa | dd629cc | 2016-02-14 17:03:45 +0100 | [diff] [blame] | 65 | void perf_debug_setup(void); |
Namhyung Kim | 80df198 | 2017-02-17 17:17:37 +0900 | [diff] [blame] | 66 | int perf_quiet_option(void); |
Jiri Olsa | bbb2cea | 2014-07-17 12:55:00 +0200 | [diff] [blame] | 67 | |
Arnaldo Carvalho de Melo | 8c2b7ca | 2017-04-19 16:21:59 -0300 | [diff] [blame] | 68 | void dump_stack(void); |
| 69 | void sighandler_dump_stack(int sig); |
| 70 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 71 | #endif /* __PERF_DEBUG_H */ |