error_report.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Declarations for error reporting tracepoints.
  4. *
  5. * Copyright (C) 2021, Google LLC.
  6. */
  7. #undef TRACE_SYSTEM
  8. #define TRACE_SYSTEM error_report
  9. #if !defined(_TRACE_ERROR_REPORT_H) || defined(TRACE_HEADER_MULTI_READ)
  10. #define _TRACE_ERROR_REPORT_H
  11. #include <linux/tracepoint.h>
  12. #ifndef __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
  13. #define __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
  14. enum error_detector {
  15. ERROR_DETECTOR_KFENCE,
  16. ERROR_DETECTOR_KASAN,
  17. ERROR_DETECTOR_WARN,
  18. };
  19. #endif /* __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY */
  20. #define error_detector_list \
  21. EM(ERROR_DETECTOR_KFENCE, "kfence") \
  22. EM(ERROR_DETECTOR_KASAN, "kasan") \
  23. EMe(ERROR_DETECTOR_WARN, "warning")
  24. /* Always end the list with an EMe. */
  25. #undef EM
  26. #undef EMe
  27. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  28. #define EMe(a, b) TRACE_DEFINE_ENUM(a);
  29. error_detector_list
  30. #undef EM
  31. #undef EMe
  32. #define EM(a, b) { a, b },
  33. #define EMe(a, b) { a, b }
  34. #define show_error_detector_list(val) \
  35. __print_symbolic(val, error_detector_list)
  36. DECLARE_EVENT_CLASS(error_report_template,
  37. TP_PROTO(enum error_detector error_detector, unsigned long id),
  38. TP_ARGS(error_detector, id),
  39. TP_STRUCT__entry(__field(enum error_detector, error_detector)
  40. __field(unsigned long, id)),
  41. TP_fast_assign(__entry->error_detector = error_detector;
  42. __entry->id = id;),
  43. TP_printk("[%s] %lx",
  44. show_error_detector_list(__entry->error_detector),
  45. __entry->id));
  46. /**
  47. * error_report_end - called after printing the error report
  48. * @error_detector: short string describing the error detection tool
  49. * @id: pseudo-unique descriptor identifying the report
  50. * (e.g. the memory access address)
  51. *
  52. * This event occurs right after a debugging tool finishes printing the error
  53. * report.
  54. */
  55. DEFINE_EVENT(error_report_template, error_report_end,
  56. TP_PROTO(enum error_detector error_detector, unsigned long id),
  57. TP_ARGS(error_detector, id));
  58. #endif /* _TRACE_ERROR_REPORT_H */
  59. /* This part must be outside protection */
  60. #include <trace/define_trace.h>