diff options
author | Wenji Huang <wenji.huang@oracle.com> | 2009-03-16 18:21:41 -0400 |
---|---|---|
committer | Wenji Huang <wenji.huang@oracle.com> | 2009-03-16 18:21:41 -0400 |
commit | bdca08879745471fdb86991a8e7276900aaaf066 (patch) | |
tree | f2d1b87801978be65f6e7c27b71a04da4036ee67 /tapset/task.stp | |
parent | 924a2ea21d0276229a752e58e5c5c1a9346648be (diff) | |
download | systemtap-steved-bdca08879745471fdb86991a8e7276900aaaf066.tar.gz systemtap-steved-bdca08879745471fdb86991a8e7276900aaaf066.tar.xz systemtap-steved-bdca08879745471fdb86991a8e7276900aaaf066.zip |
Add pid-based data lookup function.
Two functions pid2task and pid2execname.
Diffstat (limited to 'tapset/task.stp')
-rw-r--r-- | tapset/task.stp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tapset/task.stp b/tapset/task.stp index 07337156..f1a10b0a 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -63,6 +63,30 @@ function task_pid:long (task:long) } +// 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) { |