summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2010-03-02 12:45:27 -0500
committerWilliam Cohen <wcohen@redhat.com>2010-03-02 12:45:27 -0500
commit42f13348b90fa59532a0c8159dc390cd7a50de0f (patch)
tree1898ec87db7d3f1bbbf8c8364eca84ae8c35e1d9 /doc
parenta32a85bc4348426e1879274ae501da6ff496dce3 (diff)
downloadsystemtap-steved-42f13348b90fa59532a0c8159dc390cd7a50de0f.tar.gz
systemtap-steved-42f13348b90fa59532a0c8159dc390cd7a50de0f.tar.xz
systemtap-steved-42f13348b90fa59532a0c8159dc390cd7a50de0f.zip
Revise the embedded-C.stp example to something more portable.
Diffstat (limited to 'doc')
-rw-r--r--doc/tutorial.tex35
-rw-r--r--doc/tutorial/embedded-C.stp29
2 files changed, 28 insertions, 36 deletions
diff --git a/doc/tutorial.tex b/doc/tutorial.tex
index ed710d92..2553f711 100644
--- a/doc/tutorial.tex
+++ b/doc/tutorial.tex
@@ -958,33 +958,30 @@ give up, do not block.
\begin{verbatim}
# cat embedded-C.stp
%{
-#include <linux/utsname.h>
+#include <linux/sched.h>
+#include <linux/list.h>
%}
-function utsname:string (field:long)
-%{
- if (down_read_trylock (& uts_sem))
- {
- const char *f =
- (THIS->field == 0 ? system_utsname.sysname :
- THIS->field == 1 ? system_utsname.nodename :
- THIS->field == 2 ? system_utsname.release :
- THIS->field == 3 ? system_utsname.version :
- THIS->field == 4 ? system_utsname.machine :
- THIS->field == 5 ? system_utsname.domainname : "");
- strlcpy (THIS->__retvalue, f, MAXSTRINGLEN);
- up_read (& uts_sem);
- }
+function task_execname_by_pid:string (pid:long) %{
+ struct task_struct *p;
+ struct list_head *_p, *_n;
+ list_for_each_safe(_p, _n, &current->tasks) {
+ p = list_entry(_p, struct task_struct, tasks);
+ if (p->pid == (int)THIS->pid)
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", p->comm);
+ }
%}
probe begin
{
- printf ("%s %s\n", utsname(0), utsname(2))
- exit ()
+ printf("%s(%d)\n", task_execname_by_pid(target()), target())
+ exit()
}
-# stap -g embedded-C.stp
-Linux 2.6.15
+# pgrep emacs
+16641
+# stap -g embedded-C.stp -x 16641
+emacs(16641)
\end{verbatim}
\end{boxedminipage}
\caption{Embedded C function.}
diff --git a/doc/tutorial/embedded-C.stp b/doc/tutorial/embedded-C.stp
index 6834d728..a03ece59 100644
--- a/doc/tutorial/embedded-C.stp
+++ b/doc/tutorial/embedded-C.stp
@@ -1,25 +1,20 @@
%{
-#include <linux/utsname.h>
+#include <linux/sched.h>
+#include <linux/list.h>
%}
-function utsname:string (field:long)
-%{
- if (down_read_trylock (& uts_sem))
- {
- const char *f =
- (THIS->field == 0 ? system_utsname.sysname :
- THIS->field == 1 ? system_utsname.nodename :
- THIS->field == 2 ? system_utsname.release :
- THIS->field == 3 ? system_utsname.version :
- THIS->field == 4 ? system_utsname.machine :
- THIS->field == 5 ? system_utsname.domainname : "");
- strlcpy (THIS->__retvalue, f, MAXSTRINGLEN);
- up_read (& uts_sem);
- }
+function task_execname_by_pid:string (pid:long) %{
+ struct task_struct *p;
+ struct list_head *_p, *_n;
+ list_for_each_safe(_p, _n, &current->tasks) {
+ p = list_entry(_p, struct task_struct, tasks);
+ if (p->pid == (int)THIS->pid)
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", p->comm);
+ }
%}
probe begin
{
- printf ("%s %s\n", utsname(0), utsname(2))
- exit ()
+ printf("%s(%d)\n", task_execname_by_pid(target()), target())
+ exit()
}