signal.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. /**
  23. * signal_generate - called when a signal is generated
  24. * @sig: signal number
  25. * @info: pointer to struct siginfo
  26. * @task: pointer to struct task_struct
  27. *
  28. * Current process sends a 'sig' signal to 'task' process with
  29. * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
  30. * 'info' is not a pointer and you can't access its field. Instead,
  31. * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
  32. * means that si_code is SI_KERNEL.
  33. */
  34. TRACE_EVENT(signal_generate,
  35. TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
  36. TP_ARGS(sig, info, task),
  37. TP_STRUCT__entry(
  38. __field( int, sig )
  39. __field( int, errno )
  40. __field( int, code )
  41. __array( char, comm, TASK_COMM_LEN )
  42. __field( pid_t, pid )
  43. ),
  44. TP_fast_assign(
  45. __entry->sig = sig;
  46. TP_STORE_SIGINFO(__entry, info);
  47. memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
  48. __entry->pid = task->pid;
  49. ),
  50. TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d",
  51. __entry->sig, __entry->errno, __entry->code,
  52. __entry->comm, __entry->pid)
  53. );
  54. /**
  55. * signal_deliver - called when a signal is delivered
  56. * @sig: signal number
  57. * @info: pointer to struct siginfo
  58. * @ka: pointer to struct k_sigaction
  59. *
  60. * A 'sig' signal is delivered to current process with 'info' siginfo,
  61. * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
  62. * SIG_DFL.
  63. * Note that some signals reported by signal_generate tracepoint can be
  64. * lost, ignored or modified (by debugger) before hitting this tracepoint.
  65. * This means, this can show which signals are actually delivered, but
  66. * matching generated signals and delivered signals may not be correct.
  67. */
  68. TRACE_EVENT(signal_deliver,
  69. TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
  70. TP_ARGS(sig, info, ka),
  71. TP_STRUCT__entry(
  72. __field( int, sig )
  73. __field( int, errno )
  74. __field( int, code )
  75. __field( unsigned long, sa_handler )
  76. __field( unsigned long, sa_flags )
  77. ),
  78. TP_fast_assign(
  79. __entry->sig = sig;
  80. TP_STORE_SIGINFO(__entry, info);
  81. __entry->sa_handler = (unsigned long)ka->sa.sa_handler;
  82. __entry->sa_flags = ka->sa.sa_flags;
  83. ),
  84. TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
  85. __entry->sig, __entry->errno, __entry->code,
  86. __entry->sa_handler, __entry->sa_flags)
  87. );
  88. DECLARE_EVENT_CLASS(signal_queue_overflow,
  89. TP_PROTO(int sig, int group, struct siginfo *info),
  90. TP_ARGS(sig, group, info),
  91. TP_STRUCT__entry(
  92. __field( int, sig )
  93. __field( int, group )
  94. __field( int, errno )
  95. __field( int, code )
  96. ),
  97. TP_fast_assign(
  98. __entry->sig = sig;
  99. __entry->group = group;
  100. TP_STORE_SIGINFO(__entry, info);
  101. ),
  102. TP_printk("sig=%d group=%d errno=%d code=%d",
  103. __entry->sig, __entry->group, __entry->errno, __entry->code)
  104. );
  105. /**
  106. * signal_overflow_fail - called when signal queue is overflow
  107. * @sig: signal number
  108. * @group: signal to process group or not (bool)
  109. * @info: pointer to struct siginfo
  110. *
  111. * Kernel fails to generate 'sig' signal with 'info' siginfo, because
  112. * siginfo queue is overflow, and the signal is dropped.
  113. * 'group' is not 0 if the signal will be sent to a process group.
  114. * 'sig' is always one of RT signals.
  115. */
  116. DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,
  117. TP_PROTO(int sig, int group, struct siginfo *info),
  118. TP_ARGS(sig, group, info)
  119. );
  120. /**
  121. * signal_lose_info - called when siginfo is lost
  122. * @sig: signal number
  123. * @group: signal to process group or not (bool)
  124. * @info: pointer to struct siginfo
  125. *
  126. * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
  127. * queue is overflow.
  128. * 'group' is not 0 if the signal will be sent to a process group.
  129. * 'sig' is always one of non-RT signals.
  130. */
  131. DEFINE_EVENT(signal_queue_overflow, signal_lose_info,
  132. TP_PROTO(int sig, int group, struct siginfo *info),
  133. TP_ARGS(sig, group, info)
  134. );
  135. #endif /* _TRACE_SIGNAL_H */
  136. /* This part must be outside protection */
  137. #include <trace/define_trace.h>