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_kmaps;
13extern int debug_peo_args;
14extern bool quiet, dump_trace;
15extern int debug_ordered_events;
16extern int debug_data_convert;
17extern int debug_type_profile;
18
19#ifndef pr_fmt
20#define pr_fmt(fmt) fmt
21#endif
22
23#define pr_err(fmt, ...) \
24 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
25#define pr_warning(fmt, ...) \
26 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
27#define pr_warning_once(fmt, ...) ({ \
28 static int __warned; \
29 if (unlikely(!__warned)) { \
30 pr_warning(fmt, ##__VA_ARGS__); \
31 __warned = 1; \
32 } \
33})
34#define pr_info(fmt, ...) \
35 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
36#define pr_debug(fmt, ...) \
37 eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
38#define pr_debugN(n, fmt, ...) \
39 eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
40#define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
41#define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
42#define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
43
44/* Special macro to print perf_event_open arguments/return value. */
45#define pr_debug2_peo(fmt, ...) { \
46 if (debug_peo_args) \
47 pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \
48 else \
49 pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \
50}
51
52#define pr_time_N(n, var, t, fmt, ...) \
53 eprintf_time(n, var, t, fmt, ##__VA_ARGS__)
54
55#define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
56#define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
57
58#define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */
59
60union perf_event;
61
62int dump_printf(const char *fmt, ...) __printf(1, 2);
63void trace_event(union perf_event *event);
64
65int ui__error(const char *format, ...) __printf(1, 2);
66int ui__warning(const char *format, ...) __printf(1, 2);
67#define ui__warning_once(format, ...) ({ \
68 static int __warned; \
69 if (unlikely(!__warned)) { \
70 ui__warning(format, ##__VA_ARGS__); \
71 __warned = 1; \
72 } \
73})
74
75void pr_stat(const char *fmt, ...);
76
77int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4);
78int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5);
79int veprintf(int level, int var, const char *fmt, va_list args);
80
81int perf_debug_option(const char *str);
82FILE *debug_file(void);
83void debug_set_file(FILE *file);
84void debug_set_display_time(bool set);
85void perf_debug_setup(void);
86int perf_quiet_option(void);
87
88void dump_stack(void);
89void sighandler_dump_stack(int sig);
90
91#endif /* __PERF_DEBUG_H */
1/* For debugging general purposes */
2#ifndef __PERF_DEBUG_H
3#define __PERF_DEBUG_H
4
5#include <stdbool.h>
6#include "event.h"
7
8extern int verbose;
9extern bool quiet, dump_trace;
10
11int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
12void trace_event(union perf_event *event);
13
14struct ui_progress;
15
16#ifdef NO_NEWT_SUPPORT
17static inline int ui_helpline__show_help(const char *format __used, va_list ap __used)
18{
19 return 0;
20}
21
22static inline void ui_progress__update(u64 curr __used, u64 total __used,
23 const char *title __used) {}
24
25#define ui__error(format, arg...) ui__warning(format, ##arg)
26#else
27extern char ui_helpline__last_msg[];
28int ui_helpline__show_help(const char *format, va_list ap);
29#include "../ui/progress.h"
30int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
31#endif
32
33int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
34int ui__error_paranoid(void);
35
36#endif /* __PERF_DEBUG_H */