summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjistone <jistone>2006-05-10 00:45:41 +0000
committerjistone <jistone>2006-05-10 00:45:41 +0000
commiteeee7059dc4d88e4950e93504357e1f4ce140912 (patch)
treec6fca356d218fc428778710205233c30e8db550e
parent5db55886abcbc480423dddf13762639705642e37 (diff)
downloadsystemtap-steved-eeee7059dc4d88e4950e93504357e1f4ce140912.tar.gz
systemtap-steved-eeee7059dc4d88e4950e93504357e1f4ce140912.tar.xz
systemtap-steved-eeee7059dc4d88e4950e93504357e1f4ce140912.zip
2006-05-09 Josh Stone <joshua.i.stone@intel.com>
* task.stp: functions to retrieve task information * process.stp: tapset for process-related events
-rw-r--r--tapset/ChangeLog2
-rw-r--r--tapset/process.stp181
-rw-r--r--tapset/task.stp156
3 files changed, 339 insertions, 0 deletions
diff --git a/tapset/ChangeLog b/tapset/ChangeLog
index f30af435..542e71bd 100644
--- a/tapset/ChangeLog
+++ b/tapset/ChangeLog
@@ -1,6 +1,8 @@
2006-05-09 Josh Stone <joshua.i.stone@intel.com>
* context.stp (probefunc): remove use of labels
+ * task.stp: functions to retrieve task information
+ * process.stp: tapset for process-related events
2006-05-08 Josh Stone <joshua.i.stone@intel.com>
diff --git a/tapset/process.stp b/tapset/process.stp
new file mode 100644
index 00000000..6f983603
--- /dev/null
+++ b/tapset/process.stp
@@ -0,0 +1,181 @@
+// process tapset
+// Copyright (C) 2006 Intel Corporation.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+
+function _IS_ERR:long(ptr) %{
+ THIS->__retvalue = IS_ERR((const void *)(long)THIS->ptr);
+%}
+
+
+/* probe process.create
+ *
+ * Fires whenever a new process is successfully created, either as a result of
+ * one of the fork syscall variants, or a new kernel thread.
+ *
+ * Context:
+ * Parent of the created process.
+ *
+ * Arguments:
+ * task - a handle to the newly created process.
+ */
+probe process.create = kernel.function("copy_process").return {
+ task = retval()
+ if (_IS_ERR(task)) next
+}
+
+
+/* probe process.start
+ *
+ * Fires immediately before a new process begins execution.
+ *
+ * Context:
+ * Newly created process.
+ */
+probe process.start = kernel.function("schedule_tail") { }
+
+
+/* probe process.exec
+ *
+ * Fires whenever a process attempts to exec to a new program.
+ *
+ * Context:
+ * The caller of exec.
+ *
+ * Arguments:
+ * filename - the path to the new executable
+ */
+probe process.exec =
+ kernel.function("do_execve")
+%( arch != "i586" %? %( arch != "i686" %?
+ , kernel.function("compat_do_execve")
+%) %)
+{
+ filename = kernel_string($filename)
+}
+
+
+/* probe process.exec.complete
+ *
+ * Fires at the completion of an exec call.
+ *
+ * Context:
+ * On success, the context of the new executable.
+ * On failure, remains in the context of the caller.
+ *
+ * Arguments:
+ * errno - the error number resulting from the exec
+ * success - a boolean indicating whether the exec was successful
+ */
+probe process.exec.complete =
+ kernel.function("do_execve").return
+%( arch != "i586" %? %( arch != "i686" %?
+ , kernel.function("compat_do_execve").return
+%) %)
+{
+ errno = retval()
+ success = (errno >= 0)
+}
+
+
+/* probe process.exit
+ *
+ * Fires when a process terminates. This will always be followed by a
+ * process.release, though the latter may be delayed if the process waits in a
+ * zombie state.
+ *
+ * Context:
+ * The process which is terminating.
+ *
+ * Arguments:
+ * code - the exit code of the process
+ */
+probe process.exit = kernel.function("do_exit") {
+ code = $code
+}
+
+
+/* probe process.release
+ *
+ * Fires when a process is released from the kernel. This always follows a
+ * process.exit, though it may be delayed somewhat if the process waits in a
+ * zombie state.
+ *
+ * Context:
+ * The context of the parent, if it wanted notification of this process'
+ * termination, else the context of the process itself.
+ *
+ * Arguments:
+ * task - a task handle to the process being released
+ */
+probe process.release = kernel.function("release_task") {
+ task = $p
+}
+
+
+/* probe process.signal.send
+ *
+ * Fires when a process sends a signal to another process. This does not
+ * include ignored signals.
+ *
+ * Context:
+ * The signal's sender.
+ *
+ * Arguments:
+ * signal - the number of the signal
+ * signal_name - a string representation of the signal
+ * task - a task handle to the signal recipient
+ * shared - indicates whether this signal is shared by the thread group
+ */
+probe process.signal.send = _process.signal.send.* {
+ signal = $sig
+ signal_name = _signal_name($sig)
+}
+
+probe _process.signal.send.part1 =
+ kernel.function("__group_send_sig_info"),
+ kernel.function("send_group_sigqueue")
+{
+ task = $p
+ shared = 1
+}
+
+probe _process.signal.send.part2 =
+ kernel.function("send_sigqueue")
+{
+ task = $p
+ shared = 0
+}
+
+probe _process.signal.send.part3 =
+ kernel.function("specific_send_sig_info")
+{
+ task = $t
+ shared = 0
+}
+
+
+/* probe process.signal.handle
+ *
+ * Fires when a process handles a signal.
+ *
+ * Context:
+ * The signal recipient.
+ *
+ * Arguments:
+ * signal - the number of the signal
+ * signal_name - a string representation of the signal
+ */
+/* FIXME - handle_signal is sometimes inlined, depending on the whims of the
+ * compiler. On FC5 it is inlined, but on RHEL4 it is not. Until we have a
+ * nice way for tapsets to specify "possibly inlined", we can't include this
+ * probe point.
+probe process.signal.handle = kernel.function("handle_signal") {
+ signal = $sig
+ signal_name = _signal_name($sig)
+}
+*/
diff --git a/tapset/task.stp b/tapset/task.stp
new file mode 100644
index 00000000..cbf61f3a
--- /dev/null
+++ b/tapset/task.stp
@@ -0,0 +1,156 @@
+// task information tapset
+// Copyright (C) 2006 Intel Corporation.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+
+// Return the task_struct representing the current process
+function task_current:long () %{ /* pure */
+ THIS->__retvalue = (long)current;
+%}
+
+
+// Return the parent task_struct of the given task
+function task_parent:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->parent), &(t->parent));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the state of the given task, one of:
+// TASK_RUNNING 0
+// TASK_INTERRUPTIBLE 1
+// TASK_UNINTERRUPTIBLE 2
+// TASK_STOPPED 4
+// TASK_TRACED 8
+// EXIT_ZOMBIE 16
+// EXIT_DEAD 32
+function task_state:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->state), &(t->state));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the name of the given task
+function task_execname:string (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ deref_string(THIS->__retvalue, t->comm, MAXSTRINGLEN);
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the process id of the given task
+function task_pid:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->tgid), &(t->tgid));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the thread id of the given task
+function task_tid:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->pid), &(t->pid));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the group id of the given task
+function task_gid:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->gid), &(t->gid));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the effective group id of the given task
+function task_egid:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->egid), &(t->egid));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the user id of the given task
+function task_uid:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->uid), &(t->uid));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the effective user id of the given task
+function task_euid:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ THIS->__retvalue = deref(sizeof(t->euid), &(t->euid));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the priority value of the given task
+function task_prio:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ int prio = deref(sizeof(t->prio), &(t->prio));
+ THIS->__retvalue = prio - MAX_RT_PRIO;
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the nice value of the given task
+function task_nice:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ int static_prio = deref(sizeof(t->static_prio), &(t->static_prio));
+ THIS->__retvalue = static_prio - MAX_RT_PRIO - 20;
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}
+
+
+// Return the scheduled cpu for the given task
+function task_cpu:long (task:long) %{ /* pure */
+ struct task_struct *t = (struct task_struct *)(long)THIS->task;
+ struct thread_info *ti =
+ (struct thread_info *)deref(sizeof(t->thread_info), &(t->thread_info));
+ THIS->__retvalue = deref(sizeof(ti->cpu), &(ti->cpu));
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference fault";
+ }
+%}