Index: src/tapset/signal.stp =================================================================== --- src.orig/tapset/signal.stp +++ src/tapset/signal.stp @@ -16,24 +16,23 @@ // -/* probe signal.send - * - * Fires when a signal is sent to a process. - * +/** + * probe signal.send- Fires when a signal is sent to a process. + * Arguments: + * @sig: The number of the signal + * @sig_name: A string representation of the signal + * @sig_pid: The process ID of the signal recipient + * @pid_name: The name of the signal recipient + * @si_code: Indicates the signal type + * @task: A task handle to the signal recipient + * @sinfo: The address of siginfo struct + * @shared: Indicates whether the signal is shared by the thread group + * @send2queue- Indicates whether the signal is sent to an existing sigqueue + * @name: The name of the function used to send out the signal + * * Context: * The signal's sender. * - * Arguments: - * sig - the number of the signal - * sig_name - a string representation of the signal - * sig_pid - pid of the signal recipient process - * pid_name - name of the signal recipient process - * si_code - indicates the signal type. - * task - a task handle to the signal recipient - * sinfo - the address of siginfo struct. - * shared - indicates whether this signal is shared by the thread group - * send2queue- indicates whether this signal is sent to an existing sigqueue - * name - name of the function used to send out this signal */ probe signal.send = _signal.send.* { @@ -84,21 +83,17 @@ probe _signal.send.part4 = kernel.functi %( kernel_v > "2.6.25" %? probe _signal.send.part1 = kernel.function("send_signal") { - name = "__group_send_sig_info" - sig = $sig - task = $t - sinfo = $info - shared = 1 - send2queue = 0 -} - -probe _signal.send.part4 = kernel.function("send_signal") -{ - name = "specific_send_sig_info" + if ($group == 1) { + name = "__group_send_sig_info" + shared = 1 + } + else if ($group == 0) { + name = "specific_send_sig_info" + shared = 0 + } sig = $sig task = $t sinfo = $info - shared = 0 send2queue = 0 } %) @@ -118,27 +113,78 @@ probe _signal.send.part3 = kernel.functi send2queue = 1 } -/* probe signal.send.return +/** + * probe signal.send.return - Fires when a signal sent to a process returns. + * @retstr: The return value to either __group_send_sig_info, + * specific_send_sig_info, or send_sigqueue. + * Refer to the Description of this probe for more information about the return + * values of each function call. + * @shared: Indicates whether the sent signal is shared by the thread group. + * @send2queue: Indicates whether the sent signal was sent to an existing sigqueue + * @name: The name of the function used to send out the signal. + * + * Context: + * The signal's sender. (correct?) + * + * __group_send_sig_info and specific_send_sig_info return values: + * + * 0 - The signal is sucessfully sent to a process, + * which means that + * <1> the signal was ignored by the receiving process, + * <2> this is a non-RT signal and the system already has one queued, and + * <3> the signal was successfully added to the sigqueue of the receiving process. + * + * -EAGAIN - The sigqueue of the receiving process is + * overflowing, the signal was RT, and the signal was sent by a user using something other + * than kill() + * + * send_group_sigqueue and send_sigqueue return values: + * + * 0 - The signal was either sucessfully added into the + * sigqueue of the receiving process, or a SI_TIMER entry is already + * queued (in which case, the overrun count will be simply incremented). + * + * 1 - The signal was ignored by the receiving process. + * + * + * -1 - (send_sigqueue only) The task was marked + * exiting, allowing * posix_timer_event to redirect it to the group + * leader. + * */ probe signal.send.return = _signal.send.*.return { retstr = returnstr(1) } -/* - * Return values for "__group_send_sig_info" and "specific_send_sig_info" - * - * - return 0 if the signal is sucessfully sent to a process, - * which means the following: - * <1> the signal is ignored by receiving process - * <2> this is a non-RT signal and we already have one queued - * <3> the signal is successfully added into the sigqueue of - * receiving process - * - * - return -EAGAIN if the sigqueue is overflow the signal was RT - * and sent by user using something other than kill() - * - */ +// Return values for "__group_send_sig_info" and "specific_send_sig_info" +// +// - return 0 if the signal is sucessfully sent to a process, +// which means the following: +// <1> the signal is ignored by receiving process +// <2> this is a non-RT signal and we already have one queued +// <3> the signal is successfully added into the sigqueue of +// receiving process +// +// - return -EAGAIN if the sigqueue is overflow the signal was RT +// and sent by user using something other than kill() + +%( kernel_v > "2.6.25" %? +probe _signal.send.part1.return = kernel.function("send_signal").return +{ + if ($group == 1) { + name = "__group_send_sig_info" + shared = 1 + } + else if ($group == 0) { + name = "specific_send_sig_info" + shared = 0 + } + send2queue = 0 +} +%) + +%( kernel_v <= "2.6.25" %? probe _signal.send.part1.return = kernel.function("__group_send_sig_info").return { name = "__group_send_sig_info" @@ -153,15 +199,12 @@ probe _signal.send.part4.return = kernel send2queue = 0 } -%( kernel_v <= "2.6.25" %? -/* - * - return 0 if the signal is either sucessfully added into the - * sigqueue of receiving process or a SI_TIMER entry is already - * queued so just increment the overrun count - * - * - return 1 if this signal is ignored by receiving process - * - */ +// - return 0 if the signal is either sucessfully added into the +// sigqueue of receiving process or a SI_TIMER entry is already +// queued so just increment the overrun count +// +// - return 1 if this signal is ignored by receiving process + probe _signal.send.part2.return = kernel.function("send_group_sigqueue").return { name = "send_group_sigqueue" @@ -170,17 +213,14 @@ probe _signal.send.part2.return = kernel } %) -/* - * - return 0 if the signal is either sucessfully added into the - * sigqueue of receiving process or a SI_TIMER entry is already - * queued so just increment the overrun count - * - * - return 1 if this signal is ignored by receiving process - * - * - return -1 if the task is marked exiting, so posix_timer_event - * can redirect it to the group leader - * - */ +// - return 0 if the signal is either sucessfully added into the +// sigqueue of receiving process or a SI_TIMER entry is already +// queued so just increment the overrun count +// +// - return 1 if this signal is ignored by receiving process +// +// - return -1 if the task is marked exiting, so posix_timer_event +// can redirect it to the group leader probe _signal.send.part3.return = kernel.function("send_sigqueue").return { @@ -211,26 +251,25 @@ probe signal.checkperm = kernel.function si_code="SI_KERNEL (SIGFPE, SIGSEGV, SIGTRAP, SIGCHLD, SIGPOLL)" else if (sinfo <= 0) si_code="SI_USER or SI_TIMER or SI_ASYNCIO" -} +} probe signal.checkperm.return = kernel.function("check_kill_permission").return { name = "signal.checkperm" retstr = returnstr(1) } - -/* probe signal.wakeup - * - * Wake up the process for new active signals. - * - * Argument: - * sig_pid: pid of the process to be woke up - * pid_name: name of the process to be woke up - * resume: indicate whether to wake up a task in STOPPED or - TRACED state - * state_mask: a string representation indicates the mask - * of task states that can be woken + +/** + * probe signal.wakeup - Wakes up a sleeping process, making it ready for new active signals + * @sig_pid: PID of the process you wish to wake + * @pid_name: Name of the process you wish to wake + * @resume: Indicates whether to wake up a task in a STOPPED or + * TRACED state + * @state_mask: A string representation indicating the mask + * of task states you wish to wake. Possible values are TASK_INTERRUPTIBLE, + * TASK_STOPPED, TASK_TRACED, + * and TASK_INTERRUPTIBLE. */ probe signal.wakeup = kernel.function("signal_wake_up") { @@ -245,9 +284,7 @@ probe signal.wakeup = kernel.function("s } -/* probe signal.ignored - * - * Checks whether the signal is ignored or not. +/* probe signal.ignored - Checks whether a signal is ignored or not. * */ probe signal.check_ignored = kernel.function("sig_ignored") @@ -268,7 +305,7 @@ probe signal.check_ignored.return = kern /* probe signal.handle_stop * * For now, just comment it out since at the time handle_stop_signal() - * is called, it doesn't know whether current signal is STOP/COUNT. + * is called, it doesn't know whether current signal is STOP/COUNT. * So the calling of handle_stop_signal() doesn't mean that the Kernel * is now processing the STOP/COUNT signal * @@ -389,7 +426,7 @@ probe signal.send_sig_queue.return = /* probe signal.pending * - * Used to examine the set of signals that are pending for + * Used to examine the set of signals that are pending for * delivery to the calling thread * * long do_sigpending(void __user *set, unsigned long sigsetsize) @@ -417,8 +454,8 @@ probe signal.pending.return = kernel.fun * sinfo : address of siginfo table. * ka_addr : Address of the k_sigaction table associated with the signal * oldset_addr : Address of a bit mask array of blocked signals - * regs : Address in the Kernel Mode stack area - * + * regs : Address in the Kernel Mode stack area + * */ probe signal.handle = kernel.function("handle_signal") { @@ -431,7 +468,7 @@ probe signal.handle = kernel.function("h regs = $regs // Check whether the signal is a User Mode or Kernel mode Signal. - + if (sinfo == 0 && sig_code <= 0) sig_mode = "User Mode Signal" else if (sinfo >= 1) @@ -528,7 +565,7 @@ probe signal.procmask.return = kernel.fu /* * probe signal.flush - * + * * Flush all pending signals for a task. * * void flush_signals(struct task_struct *t) @@ -539,16 +576,16 @@ probe signal.flush = kernel.function("fl task = $t sig_pid = $t->pid pid_name = kernel_string($t->comm) -} +} function get_sa_flags:long (act:long) %{ /* pure */ - struct k_sigaction *act = (struct k_sigaction *)((long)THIS->act); + struct k_sigaction *act = (struct k_sigaction *)((long)THIS->act); THIS->__retvalue = kread(&act->sa.sa_flags); CATCH_DEREF_FAULT(); %} function get_sa_handler:long (act:long) %{ /* pure */ - struct k_sigaction *act = (struct k_sigaction *)((long)THIS->act); + struct k_sigaction *act = (struct k_sigaction *)((long)THIS->act); THIS->__retvalue = (long)kread(&act->sa.sa_handler); CATCH_DEREF_FAULT(); %} @@ -630,13 +667,10 @@ function sa_handler_str(handler) { /* * Signals start from 1 not 0. */ -function signal_str(num) { - return __sig[num] -} - global __sig[64] -probe begin(-1) { +function signal_str(num) { + if (!(64 in __sig)) { __sig[1] = "HUP" __sig[2] = "INT" __sig[3] = "QUIT" @@ -701,4 +735,6 @@ probe begin(-1) { __sig[62] = "RTMIN+30" __sig[63] = "RTMIN+31" __sig[64] = "RTMIN+32" + } + return __sig[num] }