signal.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM signal
  3. #if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_SIGNAL_H
  5. #include <linux/signal.h>
  6. #include <linux/sched.h>
  7. #include <linux/tracepoint.h>
  8. #define TP_STORE_SIGINFO(__entry, info) \
  9. do { \
  10. if (info == SEND_SIG_NOINFO || \
  11. info == SEND_SIG_FORCED) { \
  12. __entry->errno = 0; \
  13. __entry->code = SI_USER; \
  14. } else if (info == SEND_SIG_PRIV) { \
  15. __entry->errno = 0; \
  16. __entry->code = SI_KERNEL; \
  17. } else { \
  18. __entry->errno = info->si_errno; \
  19. __entry->code = info->si_code; \
  20. } \
  21. } while (0)
  22. #ifndef TRACE_HEADER_MULTI_READ
  23. enum {
  24. TRACE_SIGNAL_DELIVERED,
  25. TRACE_SIGNAL_IGNORED,
  26. TRACE_SIGNAL_ALREADY_PENDING,
  27. TRACE_SIGNAL_OVERFLOW_FAIL,
  28. TRACE_SIGNAL_LOSE_INFO,
  29. };
  30. #endif
  31. /**
  32. * signal_generate - called when a signal is generated
  33. * @sig: signal number
  34. * @info: pointer to struct siginfo
  35. * @task: pointer to struct task_struct
  36. * @group: shared or private
  37. * @result: TRACE_SIGNAL_*
  38. *
  39. * Current process sends a 'sig' signal to 'task' process with
  40. * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
  41. * 'info' is not a pointer and you can't access its field. Instead,
  42. * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
  43. * means that si_code is SI_KERNEL.
  44. */
  45. TRACE_EVENT(signal_generate,
  46. TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
  47. int group, int result),
  48. TP_ARGS(sig, info, task, group, result),
  49. TP_STRUCT__entry(
  50. __field( int, sig )
  51. __field( int, errno )
  52. __field( int, code )
  53. __array( char, comm, TASK_COMM_LEN )
  54. __field( pid_t, pid )
  55. __field( int, group )
  56. __field( int, result )
  57. ),
  58. TP_fast_assign(
  59. __entry->sig = sig;
  60. TP_STORE_SIGINFO(__entry, info);
  61. memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
  62. __entry->pid = task->pid;
  63. __entry->group = group;
  64. __entry->result = result;
  65. ),
  66. TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
  67. __entry->sig, __entry->errno, __entry->code,
  68. __entry->comm, __entry->pid, __entry->group,
  69. __entry->result)
  70. );
  71. /**
  72. * signal_deliver - called when a signal is delivered
  73. * @sig: signal number
  74. * @info: pointer to struct siginfo
  75. * @ka: pointer to struct k_sigaction
  76. *
  77. * A 'sig' signal is delivered to current process with 'info' siginfo,
  78. * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
  79. * SIG_DFL.
  80. * Note that some signals reported by signal_generate tracepoint can be
  81. * lost, ignored or modified (by debugger) before hitting this tracepoint.
  82. * This means, this can show which signals are actually delivered, but
  83. * matching generated signals and delivered signals may not be correct.
  84. */
  85. TRACE_EVENT(signal_deliver,
  86. TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
  87. TP_ARGS(sig, info, ka),
  88. TP_STRUCT__entry(
  89. __field( int, sig )
  90. __field( int, errno )
  91. __field( int, code )
  92. __field( unsigned long, sa_handler )
  93. __field( unsigned long, sa_flags )
  94. ),
  95. TP_fast_assign(
  96. __entry->sig = sig;
  97. TP_STORE_SIGINFO(__entry, info);
  98. __entry->sa_handler = (unsigned long)ka->sa.sa_handler;
  99. __entry->sa_flags = ka->sa.sa_flags;
  100. ),
  101. TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
  102. __entry->sig, __entry->errno, __entry->code,
  103. __entry->sa_handler, __entry->sa_flags)
  104. );
  105. #endif /* _TRACE_SIGNAL_H */
  106. /* This part must be outside protection */
  107. #include <trace/define_trace.h>