Debian Codegraph @

doc/tutorial/embedded-C.stp

raw
1 %{
2 #include <linux/sched.h>
3 #include <linux/list.h>
4 %}
5
6 function task_execname_by_pid:string (pid:long) %{
7 struct task_struct *p;
8 struct list_head *_p, *_n;
9 list_for_each_safe(_p, _n, &current->tasks) {
10 p = list_entry(_p, struct task_struct, tasks);
11 if (p->pid == (int)STAP_ARG_pid)
12 snprintf(STAP_RETVALUE, MAXSTRINGLEN, "%s", p->comm);
13 }
14 %}
15
16 probe begin
17 {
18 printf("%s(%d)\n", task_execname_by_pid(target()), target())
19 exit()
20 }