cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

debug.h (2690B)


      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 */