xref: /kernel/linux/linux-5.10/tools/perf/util/debug.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* For debugging general purposes */
38c2ecf20Sopenharmony_ci#ifndef __PERF_DEBUG_H
48c2ecf20Sopenharmony_ci#define __PERF_DEBUG_H
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <stdarg.h>
78c2ecf20Sopenharmony_ci#include <stdbool.h>
88c2ecf20Sopenharmony_ci#include <linux/compiler.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciextern int verbose;
118c2ecf20Sopenharmony_ciextern int debug_peo_args;
128c2ecf20Sopenharmony_ciextern bool quiet, dump_trace;
138c2ecf20Sopenharmony_ciextern int debug_ordered_events;
148c2ecf20Sopenharmony_ciextern int debug_data_convert;
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifndef pr_fmt
178c2ecf20Sopenharmony_ci#define pr_fmt(fmt) fmt
188c2ecf20Sopenharmony_ci#endif
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define pr_err(fmt, ...) \
218c2ecf20Sopenharmony_ci	eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
228c2ecf20Sopenharmony_ci#define pr_warning(fmt, ...) \
238c2ecf20Sopenharmony_ci	eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
248c2ecf20Sopenharmony_ci#define pr_info(fmt, ...) \
258c2ecf20Sopenharmony_ci	eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
268c2ecf20Sopenharmony_ci#define pr_debug(fmt, ...) \
278c2ecf20Sopenharmony_ci	eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
288c2ecf20Sopenharmony_ci#define pr_debugN(n, fmt, ...) \
298c2ecf20Sopenharmony_ci	eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
308c2ecf20Sopenharmony_ci#define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
318c2ecf20Sopenharmony_ci#define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
328c2ecf20Sopenharmony_ci#define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* Special macro to print perf_event_open arguments/return value. */
358c2ecf20Sopenharmony_ci#define pr_debug2_peo(fmt, ...) {				\
368c2ecf20Sopenharmony_ci	if (debug_peo_args)						\
378c2ecf20Sopenharmony_ci		pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__);	\
388c2ecf20Sopenharmony_ci	else							\
398c2ecf20Sopenharmony_ci		pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__);	\
408c2ecf20Sopenharmony_ci}
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define pr_time_N(n, var, t, fmt, ...) \
438c2ecf20Sopenharmony_ci	eprintf_time(n, var, t, fmt, ##__VA_ARGS__)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define pr_oe_time(t, fmt, ...)  pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
468c2ecf20Sopenharmony_ci#define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define STRERR_BUFSIZE	128	/* For the buffer size of str_error_r */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciunion perf_event;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciint dump_printf(const char *fmt, ...) __printf(1, 2);
538c2ecf20Sopenharmony_civoid trace_event(union perf_event *event);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciint ui__error(const char *format, ...) __printf(1, 2);
568c2ecf20Sopenharmony_ciint ui__warning(const char *format, ...) __printf(1, 2);
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_civoid pr_stat(const char *fmt, ...);
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciint eprintf(int level, int var, const char *fmt, ...) __printf(3, 4);
618c2ecf20Sopenharmony_ciint eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5);
628c2ecf20Sopenharmony_ciint veprintf(int level, int var, const char *fmt, va_list args);
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ciint perf_debug_option(const char *str);
658c2ecf20Sopenharmony_civoid perf_debug_setup(void);
668c2ecf20Sopenharmony_ciint perf_quiet_option(void);
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_civoid dump_stack(void);
698c2ecf20Sopenharmony_civoid sighandler_dump_stack(int sig);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#endif	/* __PERF_DEBUG_H */
72