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> |
Jiri Olsa | 8abceac | 2020-12-12 11:43:51 +0100 | [diff] [blame] | 8 | #include <stdio.h> |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 9 | #include <linux/compiler.h> |
Arnaldo Carvalho de Melo | 8f41146 | 2009-11-16 16:32:42 -0200 | [diff] [blame] | 10 | |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 11 | extern int verbose; |
Ravi Bangoria | ccd2674 | 2019-11-08 15:11:28 +0530 | [diff] [blame] | 12 | extern int debug_peo_args; |
Arnaldo Carvalho de Melo | b44308f | 2010-10-26 15:20:09 -0200 | [diff] [blame] | 13 | extern bool quiet, dump_trace; |
Jiri Olsa | cee3ab9 | 2014-07-11 14:49:54 +0200 | [diff] [blame] | 14 | extern int debug_ordered_events; |
Jiri Olsa | edbe981 | 2015-02-20 23:17:00 +0100 | [diff] [blame] | 15 | extern int debug_data_convert; |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 16 | |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 17 | #ifndef pr_fmt |
| 18 | #define pr_fmt(fmt) fmt |
| 19 | #endif |
| 20 | |
| 21 | #define pr_err(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 22 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 23 | #define pr_warning(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 24 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
James Clark | 1094795e | 2021-07-29 16:58:00 +0100 | [diff] [blame] | 25 | #define pr_warning_once(fmt, ...) ({ \ |
| 26 | static int __warned; \ |
| 27 | if (unlikely(!__warned)) { \ |
| 28 | pr_warning(fmt, ##__VA_ARGS__); \ |
| 29 | __warned = 1; \ |
| 30 | } \ |
| 31 | }) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 32 | #define pr_info(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 33 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 34 | #define pr_debug(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 35 | eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 36 | #define pr_debugN(n, fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 37 | eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 38 | #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__) |
| 39 | #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__) |
| 40 | #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__) |
| 41 | |
Ravi Bangoria | ccd2674 | 2019-11-08 15:11:28 +0530 | [diff] [blame] | 42 | /* Special macro to print perf_event_open arguments/return value. */ |
| 43 | #define pr_debug2_peo(fmt, ...) { \ |
| 44 | if (debug_peo_args) \ |
| 45 | pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ |
| 46 | else \ |
| 47 | pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ |
| 48 | } |
| 49 | |
Jiri Olsa | cee3ab9 | 2014-07-11 14:49:54 +0200 | [diff] [blame] | 50 | #define pr_time_N(n, var, t, fmt, ...) \ |
| 51 | eprintf_time(n, var, t, fmt, ##__VA_ARGS__) |
| 52 | |
| 53 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 54 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 55 | |
Arnaldo Carvalho de Melo | c8b5f2c | 2016-07-06 11:56:20 -0300 | [diff] [blame] | 56 | #define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */ |
Masami Hiramatsu | b2348e1 | 2014-08-14 02:22:32 +0000 | [diff] [blame] | 57 | |
Arnaldo Carvalho de Melo | 8520a98 | 2019-08-29 16:18:59 -0300 | [diff] [blame] | 58 | union perf_event; |
| 59 | |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 60 | int dump_printf(const char *fmt, ...) __printf(1, 2); |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 61 | void trace_event(union perf_event *event); |
Arnaldo Carvalho de Melo | 567e547 | 2010-03-12 21:05:10 -0300 | [diff] [blame] | 62 | |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 63 | int ui__error(const char *format, ...) __printf(1, 2); |
| 64 | int ui__warning(const char *format, ...) __printf(1, 2); |
James Clark | 1094795e | 2021-07-29 16:58:00 +0100 | [diff] [blame] | 65 | #define ui__warning_once(format, ...) ({ \ |
| 66 | static int __warned; \ |
| 67 | if (unlikely(!__warned)) { \ |
| 68 | ui__warning(format, ##__VA_ARGS__); \ |
| 69 | __warned = 1; \ |
| 70 | } \ |
| 71 | }) |
Arnaldo Carvalho de Melo | 068ffaa | 2010-11-27 02:41:01 -0200 | [diff] [blame] | 72 | |
Jiri Olsa | f772abc | 2013-12-03 14:09:25 +0100 | [diff] [blame] | 73 | void pr_stat(const char *fmt, ...); |
| 74 | |
Arnaldo Carvalho de Melo | afaed6d | 2017-06-16 11:57:54 -0300 | [diff] [blame] | 75 | int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4); |
| 76 | 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] | 77 | int veprintf(int level, int var, const char *fmt, va_list args); |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 78 | |
Jiri Olsa | bbb2cea | 2014-07-17 12:55:00 +0200 | [diff] [blame] | 79 | int perf_debug_option(const char *str); |
Jiri Olsa | 8abceac | 2020-12-12 11:43:51 +0100 | [diff] [blame] | 80 | void debug_set_file(FILE *file); |
Jiri Olsa | bcbd79d | 2021-01-02 23:04:22 +0100 | [diff] [blame] | 81 | void debug_set_display_time(bool set); |
Jiri Olsa | dd629cc | 2016-02-14 17:03:45 +0100 | [diff] [blame] | 82 | void perf_debug_setup(void); |
Namhyung Kim | 80df198 | 2017-02-17 17:17:37 +0900 | [diff] [blame] | 83 | int perf_quiet_option(void); |
Jiri Olsa | bbb2cea | 2014-07-17 12:55:00 +0200 | [diff] [blame] | 84 | |
Arnaldo Carvalho de Melo | 8c2b7ca | 2017-04-19 16:21:59 -0300 | [diff] [blame] | 85 | void dump_stack(void); |
| 86 | void sighandler_dump_stack(int sig); |
| 87 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 88 | #endif /* __PERF_DEBUG_H */ |