Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 1 | /* For debugging general purposes */ |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 2 | #ifndef __PERF_DEBUG_H |
| 3 | #define __PERF_DEBUG_H |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 4 | |
Ian Munsie | c055564 | 2010-04-13 18:37:33 +1000 | [diff] [blame] | 5 | #include <stdbool.h> |
Masami Hiramatsu | b2348e1 | 2014-08-14 02:22:32 +0000 | [diff] [blame] | 6 | #include <string.h> |
Arnaldo Carvalho de Melo | 8f41146 | 2009-11-16 16:32:42 -0200 | [diff] [blame] | 7 | #include "event.h" |
Namhyung Kim | 0985a94 | 2012-08-16 17:14:54 +0900 | [diff] [blame] | 8 | #include "../ui/helpline.h" |
Namhyung Kim | 7529142 | 2012-11-15 01:47:40 +0900 | [diff] [blame] | 9 | #include "../ui/progress.h" |
| 10 | #include "../ui/util.h" |
Arnaldo Carvalho de Melo | 8f41146 | 2009-11-16 16:32:42 -0200 | [diff] [blame] | 11 | |
Frederic Weisbecker | cd84c2a | 2009-08-12 10:03:49 +0200 | [diff] [blame] | 12 | extern int verbose; |
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__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 25 | #define pr_info(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 26 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 27 | #define pr_debug(fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 28 | eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 29 | #define pr_debugN(n, fmt, ...) \ |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 30 | eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__) |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 31 | #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__) |
| 32 | #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__) |
| 33 | #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__) |
| 34 | |
Jiri Olsa | cee3ab9 | 2014-07-11 14:49:54 +0200 | [diff] [blame] | 35 | #define pr_time_N(n, var, t, fmt, ...) \ |
| 36 | eprintf_time(n, var, t, fmt, ##__VA_ARGS__) |
| 37 | |
| 38 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 39 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
| 40 | |
Masami Hiramatsu | b2348e1 | 2014-08-14 02:22:32 +0000 | [diff] [blame] | 41 | #define STRERR_BUFSIZE 128 /* For the buffer size of strerror_r */ |
| 42 | |
Frederic Weisbecker | 2cec19d | 2009-08-16 19:24:21 +0200 | [diff] [blame] | 43 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 44 | void trace_event(union perf_event *event); |
Arnaldo Carvalho de Melo | 567e547 | 2010-03-12 21:05:10 -0300 | [diff] [blame] | 45 | |
Namhyung Kim | f9f526e | 2012-09-28 18:32:03 +0900 | [diff] [blame] | 46 | int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2))); |
Arnaldo Carvalho de Melo | 4610e41 | 2011-10-26 12:04:37 -0200 | [diff] [blame] | 47 | int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); |
Arnaldo Carvalho de Melo | 068ffaa | 2010-11-27 02:41:01 -0200 | [diff] [blame] | 48 | |
Jiri Olsa | f772abc | 2013-12-03 14:09:25 +0100 | [diff] [blame] | 49 | void pr_stat(const char *fmt, ...); |
| 50 | |
Jiri Olsa | c95688a | 2014-07-14 23:46:49 +0200 | [diff] [blame] | 51 | int eprintf(int level, int var, const char *fmt, ...) __attribute__((format(printf, 3, 4))); |
Jiri Olsa | cee3ab9 | 2014-07-11 14:49:54 +0200 | [diff] [blame] | 52 | int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __attribute__((format(printf, 4, 5))); |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 53 | |
Jiri Olsa | bbb2cea | 2014-07-17 12:55:00 +0200 | [diff] [blame] | 54 | int perf_debug_option(const char *str); |
| 55 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 56 | #endif /* __PERF_DEBUG_H */ |