Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/* For debugging general purposes */
3#ifndef __PERF_DEBUG_H
4#define __PERF_DEBUG_H
5
6#include <stdarg.h>
7#include <stdbool.h>
8#include <stdio.h>
9#include <linux/compiler.h>
10
11extern int verbose;
12extern int debug_peo_args;
13extern bool quiet, dump_trace;
14extern int debug_ordered_events;
15extern int debug_data_convert;
16
17#ifndef pr_fmt
18#define pr_fmt(fmt) fmt
19#endif
20
21#define pr_err(fmt, ...) \
22 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
23#define pr_warning(fmt, ...) \
24 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
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})
32#define pr_info(fmt, ...) \
33 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
34#define pr_debug(fmt, ...) \
35 eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
36#define pr_debugN(n, fmt, ...) \
37 eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
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
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
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
56#define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */
57
58union perf_event;
59
60int dump_printf(const char *fmt, ...) __printf(1, 2);
61void trace_event(union perf_event *event);
62
63int ui__error(const char *format, ...) __printf(1, 2);
64int ui__warning(const char *format, ...) __printf(1, 2);
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})
72
73void pr_stat(const char *fmt, ...);
74
75int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4);
76int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5);
77int veprintf(int level, int var, const char *fmt, va_list args);
78
79int perf_debug_option(const char *str);
80void debug_set_file(FILE *file);
81void debug_set_display_time(bool set);
82void perf_debug_setup(void);
83int perf_quiet_option(void);
84
85void dump_stack(void);
86void sighandler_dump_stack(int sig);
87
88#endif /* __PERF_DEBUG_H */
1/* SPDX-License-Identifier: GPL-2.0 */
2/* For debugging general purposes */
3#ifndef __PERF_DEBUG_H
4#define __PERF_DEBUG_H
5
6#include <stdarg.h>
7#include <stdbool.h>
8#include <linux/compiler.h>
9
10extern int verbose;
11extern int debug_peo_args;
12extern bool quiet, dump_trace;
13extern int debug_ordered_events;
14extern int debug_data_convert;
15
16#ifndef pr_fmt
17#define pr_fmt(fmt) fmt
18#endif
19
20#define pr_err(fmt, ...) \
21 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
22#define pr_warning(fmt, ...) \
23 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
24#define pr_info(fmt, ...) \
25 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
26#define pr_debug(fmt, ...) \
27 eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
28#define pr_debugN(n, fmt, ...) \
29 eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
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
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
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
48#define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */
49
50union perf_event;
51
52int dump_printf(const char *fmt, ...) __printf(1, 2);
53void trace_event(union perf_event *event);
54
55int ui__error(const char *format, ...) __printf(1, 2);
56int ui__warning(const char *format, ...) __printf(1, 2);
57
58void pr_stat(const char *fmt, ...);
59
60int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4);
61int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5);
62int veprintf(int level, int var, const char *fmt, va_list args);
63
64int perf_debug_option(const char *str);
65void perf_debug_setup(void);
66int perf_quiet_option(void);
67
68void dump_stack(void);
69void sighandler_dump_stack(int sig);
70
71#endif /* __PERF_DEBUG_H */