signal.h 4.6 KB

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