diff options
author | Mark Wielaard <mjw@redhat.com> | 2009-03-17 16:58:35 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-03-17 16:58:35 +0100 |
commit | bf33ee46c8fff4d181b7f28521f12175bd32ec77 (patch) | |
tree | 5e0a9e1047af60389eee36da54182b52d3d53ee7 /tapset/task.stp | |
parent | 524c6f82b0a3c010d0fd6a67b1afcfbf55b789a6 (diff) | |
parent | 30cb532a560ed152b86506b80490e99195970271 (diff) | |
download | systemtap-steved-bf33ee46c8fff4d181b7f28521f12175bd32ec77.tar.gz systemtap-steved-bf33ee46c8fff4d181b7f28521f12175bd32ec77.tar.xz systemtap-steved-bf33ee46c8fff4d181b7f28521f12175bd32ec77.zip |
Merge branch 'master' into pr6866
Resolved conflicts:
runtime/task_finder.c: name vs path.
Diffstat (limited to 'tapset/task.stp')
-rw-r--r-- | tapset/task.stp | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/tapset/task.stp b/tapset/task.stp index 684cef93..f1a10b0a 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -43,35 +43,55 @@ function task_parent:long (task:long) %{ /* pure */ // 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 = kread(&(t->state)); - CATCH_DEREF_FAULT(); -%} +function task_state:long (task:long) +{ + return @cast(task, "task_struct", "kernel")->state +} // 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); - CATCH_DEREF_FAULT(); -%} +function task_execname:string (task:long) +{ + return kernel_string(@cast(task, "task_struct", "kernel")->comm) +} // 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 = kread(&(t->tgid)); +function task_pid:long (task:long) +{ + return @cast(task, "task_struct", "kernel")->tgid +} + + +// Return the task of the given process id +function pid2task:long (pid:long) %{ /* pure */ + struct task_struct *t = NULL; + pid_t t_pid = (pid_t)(long)THIS->pid; + rcu_read_lock(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) + t = find_task_by_vpid (t_pid); +#else + t = find_task_by_pid (t_pid); +#endif + rcu_read_unlock(); + THIS->__retvalue = (long)t; CATCH_DEREF_FAULT(); %} +// Return the name of the given process id +function pid2execname:string (pid:long) { + tsk = pid2task(pid) + if (tsk) + return task_execname(tsk) + return "" +} + // 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 = kread(&(t->pid)); - CATCH_DEREF_FAULT(); -%} +function task_tid:long (task:long) +{ + return @cast(task, "task_struct", "kernel")->pid +} // Return the group id of the given task @@ -156,22 +176,14 @@ function task_nice:long (task:long) %{ /* pure */ // Return the scheduled cpu for the given task function task_cpu:long (task:long) +{ %( kernel_v >= "2.6.22" %? -%{ /* pure */ - struct task_struct *t = (struct task_struct *)(long)THIS->task; - struct thread_info *ti = kread(&(t->stack)); - THIS->__retvalue = kread(&(ti->cpu)); - CATCH_DEREF_FAULT(); -%} + ti = @cast(task, "task_struct", "kernel")->stack %: -%{ /* pure */ - struct task_struct *t = (struct task_struct *)(long)THIS->task; - struct thread_info *ti = kread(&(t->thread_info)); - THIS->__retvalue = kread(&(ti->cpu)); - CATCH_DEREF_FAULT(); -%} + ti = @cast(task, "task_struct", "kernel")->thread_info %) - + return @cast(ti, "thread_info", "kernel")->cpu +} // Return the number of open file handlers for the given task function task_open_file_handles:long (task:long) |