Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Declarations for error reporting tracepoints.
0004  *
0005  * Copyright (C) 2021, Google LLC.
0006  */
0007 #undef TRACE_SYSTEM
0008 #define TRACE_SYSTEM error_report
0009 
0010 #if !defined(_TRACE_ERROR_REPORT_H) || defined(TRACE_HEADER_MULTI_READ)
0011 #define _TRACE_ERROR_REPORT_H
0012 
0013 #include <linux/tracepoint.h>
0014 
0015 #ifndef __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
0016 #define __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
0017 
0018 enum error_detector {
0019     ERROR_DETECTOR_KFENCE,
0020     ERROR_DETECTOR_KASAN,
0021     ERROR_DETECTOR_WARN,
0022 };
0023 
0024 #endif /* __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY */
0025 
0026 #define error_detector_list         \
0027     EM(ERROR_DETECTOR_KFENCE, "kfence") \
0028     EM(ERROR_DETECTOR_KASAN, "kasan")   \
0029     EMe(ERROR_DETECTOR_WARN, "warning")
0030 /* Always end the list with an EMe. */
0031 
0032 #undef EM
0033 #undef EMe
0034 
0035 #define EM(a, b)    TRACE_DEFINE_ENUM(a);
0036 #define EMe(a, b)   TRACE_DEFINE_ENUM(a);
0037 
0038 error_detector_list
0039 
0040 #undef EM
0041 #undef EMe
0042 
0043 #define EM(a, b) { a, b },
0044 #define EMe(a, b) { a, b }
0045 
0046 #define show_error_detector_list(val) \
0047     __print_symbolic(val, error_detector_list)
0048 
0049 DECLARE_EVENT_CLASS(error_report_template,
0050             TP_PROTO(enum error_detector error_detector, unsigned long id),
0051             TP_ARGS(error_detector, id),
0052             TP_STRUCT__entry(__field(enum error_detector, error_detector)
0053                          __field(unsigned long, id)),
0054             TP_fast_assign(__entry->error_detector = error_detector;
0055                    __entry->id = id;),
0056             TP_printk("[%s] %lx",
0057                   show_error_detector_list(__entry->error_detector),
0058                   __entry->id));
0059 
0060 /**
0061  * error_report_end - called after printing the error report
0062  * @error_detector: short string describing the error detection tool
0063  * @id:         pseudo-unique descriptor identifying the report
0064  *          (e.g. the memory access address)
0065  *
0066  * This event occurs right after a debugging tool finishes printing the error
0067  * report.
0068  */
0069 DEFINE_EVENT(error_report_template, error_report_end,
0070          TP_PROTO(enum error_detector error_detector, unsigned long id),
0071          TP_ARGS(error_detector, id));
0072 
0073 #endif /* _TRACE_ERROR_REPORT_H */
0074 
0075 /* This part must be outside protection */
0076 #include <trace/define_trace.h>