^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* For debugging general purposes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #ifndef __PERF_DEBUG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #define __PERF_DEBUG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <stdarg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) extern int verbose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) extern int debug_peo_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) extern bool quiet, dump_trace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) extern int debug_ordered_events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern int debug_data_convert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifndef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define pr_fmt(fmt) fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define pr_err(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define pr_warning(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define pr_info(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define pr_debug(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define pr_debugN(n, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* Special macro to print perf_event_open arguments/return value. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define pr_debug2_peo(fmt, ...) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (debug_peo_args) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define pr_time_N(n, var, t, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) eprintf_time(n, var, t, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) union perf_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int dump_printf(const char *fmt, ...) __printf(1, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void trace_event(union perf_event *event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int ui__error(const char *format, ...) __printf(1, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int ui__warning(const char *format, ...) __printf(1, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void pr_stat(const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int veprintf(int level, int var, const char *fmt, va_list args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int perf_debug_option(const char *str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) void perf_debug_setup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int perf_quiet_option(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void dump_stack(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void sighandler_dump_stack(int sig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #endif /* __PERF_DEBUG_H */