blob: 77445dfc5c7d2657445942807338f993b8ec2d21 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +02002/* For debugging general purposes */
John Kacur8b40f522009-09-24 18:02:18 +02003#ifndef __PERF_DEBUG_H
4#define __PERF_DEBUG_H
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +02005
Ian Munsiec0555642010-04-13 18:37:33 +10006#include <stdbool.h>
Masami Hiramatsub2348e12014-08-14 02:22:32 +00007#include <string.h>
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -03008#include <linux/compiler.h>
Arnaldo Carvalho de Melo8f411462009-11-16 16:32:42 -02009#include "event.h"
Namhyung Kim0985a942012-08-16 17:14:54 +090010#include "../ui/helpline.h"
Namhyung Kim75291422012-11-15 01:47:40 +090011#include "../ui/progress.h"
12#include "../ui/util.h"
Arnaldo Carvalho de Melo8f411462009-11-16 16:32:42 -020013
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020014extern int verbose;
Arnaldo Carvalho de Melob44308f2010-10-26 15:20:09 -020015extern bool quiet, dump_trace;
Jiri Olsacee3ab92014-07-11 14:49:54 +020016extern int debug_ordered_events;
Jiri Olsaedbe9812015-02-20 23:17:00 +010017extern int debug_data_convert;
Frederic Weisbeckercd84c2a2009-08-12 10:03:49 +020018
Jiri Olsa84f5d362014-07-14 23:46:48 +020019#ifndef pr_fmt
20#define pr_fmt(fmt) fmt
21#endif
22
23#define pr_err(fmt, ...) \
Jiri Olsac95688a2014-07-14 23:46:49 +020024 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
Jiri Olsa84f5d362014-07-14 23:46:48 +020025#define pr_warning(fmt, ...) \
Jiri Olsac95688a2014-07-14 23:46:49 +020026 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
Jiri Olsa84f5d362014-07-14 23:46:48 +020027#define pr_info(fmt, ...) \
Jiri Olsac95688a2014-07-14 23:46:49 +020028 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
Jiri Olsa84f5d362014-07-14 23:46:48 +020029#define pr_debug(fmt, ...) \
Jiri Olsac95688a2014-07-14 23:46:49 +020030 eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
Jiri Olsa84f5d362014-07-14 23:46:48 +020031#define pr_debugN(n, fmt, ...) \
Jiri Olsac95688a2014-07-14 23:46:49 +020032 eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
Jiri Olsa84f5d362014-07-14 23:46:48 +020033#define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
34#define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
35#define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
36
Jiri Olsacee3ab92014-07-11 14:49:54 +020037#define pr_time_N(n, var, t, fmt, ...) \
38 eprintf_time(n, var, t, fmt, ##__VA_ARGS__)
39
40#define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
41#define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)
42
Arnaldo Carvalho de Meloc8b5f2c2016-07-06 11:56:20 -030043#define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */
Masami Hiramatsub2348e12014-08-14 02:22:32 +000044
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -030045int dump_printf(const char *fmt, ...) __printf(1, 2);
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -020046void trace_event(union perf_event *event);
Arnaldo Carvalho de Melo567e5472010-03-12 21:05:10 -030047
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -030048int ui__error(const char *format, ...) __printf(1, 2);
49int ui__warning(const char *format, ...) __printf(1, 2);
Arnaldo Carvalho de Melo068ffaa2010-11-27 02:41:01 -020050
Jiri Olsaf772abc2013-12-03 14:09:25 +010051void pr_stat(const char *fmt, ...);
52
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -030053int eprintf(int level, int var, const char *fmt, ...) __printf(3, 4);
54int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5);
Wang Nan0af08852015-07-31 10:35:33 -030055int veprintf(int level, int var, const char *fmt, va_list args);
Jiri Olsa84f5d362014-07-14 23:46:48 +020056
Jiri Olsabbb2cea2014-07-17 12:55:00 +020057int perf_debug_option(const char *str);
Jiri Olsadd629cc2016-02-14 17:03:45 +010058void perf_debug_setup(void);
Namhyung Kim80df1982017-02-17 17:17:37 +090059int perf_quiet_option(void);
Jiri Olsabbb2cea2014-07-17 12:55:00 +020060
Arnaldo Carvalho de Melo8c2b7ca2017-04-19 16:21:59 -030061void dump_stack(void);
62void sighandler_dump_stack(int sig);
63
John Kacur8b40f522009-09-24 18:02:18 +020064#endif /* __PERF_DEBUG_H */