summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--doc/SystemTap_Tapset_Reference/tapsets.tmpl25
-rw-r--r--doc/Tapset_Reference_Guide/en-US/Introduction.xml59
-rw-r--r--doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml117
-rwxr-xr-xdoc/Tapset_Reference_Guide/publicanize.sh25
-rw-r--r--includes/sys/sdt.h159
-rw-r--r--tapset/nfs.stp165
-rw-r--r--tapset/rpc.stp94
-rw-r--r--tapset/scsi.stp10
-rw-r--r--tapset/signal.stp18
-rw-r--r--tapset/socket.stp68
-rw-r--r--tapset/task.stp54
-rw-r--r--tapset/vfs.stp208
13 files changed, 576 insertions, 428 deletions
diff --git a/AUTHORS b/AUTHORS
index 7afdd53e..6a20ef72 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,6 +2,7 @@ Ananth N Mavinakayanahalli
Anil Keshavamurthy
Anithra Janakiraman
Charles Spirakis
+Dan Horak
Dave Brolley
Dave Nomura
David Smith
@@ -24,6 +25,7 @@ Mark McLoughlin
Mark Wielaard
Martin Hunt
Masami Hiramatsu
+Maynard Johnson
Michael Meeks
Mike Mason
Nobuhiro Tachino
diff --git a/doc/SystemTap_Tapset_Reference/tapsets.tmpl b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
index d6b3b309..798cfb3b 100644
--- a/doc/SystemTap_Tapset_Reference/tapsets.tmpl
+++ b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
@@ -51,9 +51,9 @@
</para>
</legalnotice>
</bookinfo>
-
+<!-- pls dont remove marker comments, as they are used in publican conversion-->
<toc></toc>
-
+<!--starthere-->
<chapter id="introduction">
<title>Introduction</title>
<para>
@@ -98,7 +98,6 @@
the kernel. This is common among asynchronous events such as timers,
exit functions, and print functions.
</para>
-
<!--
<varlistentry>
<term></term>
@@ -111,11 +110,13 @@
</section>
</chapter>
-
+<!--endhere-->
+<!--markerforxi-->
+<!-- pls dont remove marker comments, as they are used in publican conversion-->
<chapter id="context_stp">
<title>Context Functions</title>
<para>
- The context functions provide additional information about the where
+ The context functions provide additional information about where
the event occurred.
These functions can provide information such as a backtrace
where the event occured
@@ -130,7 +131,7 @@
<title>Timestamp Functions</title>
<para>
Each timestamp function returns a value to indicate when
- the function is executed.
+ a function is executed.
Thus, these returned values can be used to indicate
when an event occurs, provide an ordering for events, or compute
the amount of time elapsed between to time stamps.
@@ -165,9 +166,11 @@
<title>Networking Tapset</title>
<para>
This family of probe points is used to probe the activities of
- network device.
+ the network device, TCP layer, and UDP layer.
</para>
!Itapset/networking.stp
+!Itapset/tcp.stp
+!Itapset/udp.stp
</chapter>
<chapter id="socket.stp">
@@ -178,14 +181,14 @@
</para>
!Itapset/socket.stp
</chapter>
-
+<!--
<chapter id="tcp.stp">
<title>TCP Tapset</title>
<para>
This family of probe points is used to probe TCP layer activities.
It contains the following probe points:
</para>
-!Itapset/tcp.stp
+
</chapter>
<chapter id="upd.stp">
@@ -194,9 +197,9 @@
This family of probe points is used to probe UDP layer activities.
It contains the following probe points:
</para>
-!Itapset/udp.stp
- </chapter>
+ </chapter>
+-->
<chapter id="process.stp">
<title>Process Tapset</title>
<para>
diff --git a/doc/Tapset_Reference_Guide/en-US/Introduction.xml b/doc/Tapset_Reference_Guide/en-US/Introduction.xml
new file mode 100644
index 00000000..633521e1
--- /dev/null
+++ b/doc/Tapset_Reference_Guide/en-US/Introduction.xml
@@ -0,0 +1,59 @@
+<?xml version='1.0'?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+
+<chapter id="introduction">
+ <title>Introduction</title>
+
+ <para>
+ SystemTap provides free software (GPL) infrastructure to simplify the
+ gathering of information about the running Linux system. This assists
+ diagnosis of a performance or functional problem. SystemTap eliminates the
+ need for the developer to go through the tedious and disruptive instrument,
+ recompile, install, and reboot sequence that may be otherwise required to
+ collect data.
+ </para>
+
+ <para>
+ SystemTap provides a simple command line interface and scripting language
+ for writing instrumentation for a live, running kernel. This instrumentation
+ uses probe points and functions provided in the <firstterm>tapset</firstterm> library.
+ </para>
+
+ <para>
+ Simply put, tapsets are scripts that encapsulate knowledge about a kernel subsystem
+ into pre-written probes and functions that can be used by other scripts.
+ Tapsets are analogous to libraries for C programs. They hide the
+ underlying details of a kernel area while exposing the key information
+ needed to manage and monitor that aspect of the kernel. They are typically
+ developed by kernel subject-matter experts.
+ </para>
+
+ <para>
+ A tapset exposes the high-level data and state transitions of a
+ subsystem. For the most part, good tapset developers assume that
+ SystemTap users know little to nothing about the kernel subsystem's
+ low-level details. As such, tapset developers write tapsets that help
+ ordinary SystemTap users write meaningful and useful SystemTap scripts.
+ </para>
+
+<!-- add xref to upcoming section on how to write Tapsets/Tapset Comments -->
+
+ <section id="docsgoals">
+ <title>Documentation Goals</title>
+
+ <para>
+ This guide aims to document SystemTap's most useful and common tapset entries; it
+ also contains guidelines on proper tapset development and documentation.
+ The tapset definitions contained in this guide are extracted automatically from
+ properly-formatted comments in the code of each tapset file. As such, any revisions
+ to the definitions in this guide should be applied directly to their respective
+ tapset file.
+ </para>
+
+<remark>add: "while users can read from code, it's easier to read from here!"</remark>
+<remark>add: target audience, expected proficiency of readers</remark>
+
+ </section>
+
+</chapter> \ No newline at end of file
diff --git a/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
new file mode 100644
index 00000000..26ea9896
--- /dev/null
+++ b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
@@ -0,0 +1,117 @@
+<?xml version='1.0'?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+
+<chapter id="Tapset_Dev_Guide">
+ <title>Tapset Development Guidelines</title>
+
+<para>
+ This chapter describes the upstream guidelines on proper tapset documentation. It also contains
+ information on how to properly document your tapsets, to ensure that they are properly
+ defined in this guide.
+</para>
+
+ <section id="Tapsetcontents">
+ <title>Writing Good Tapsets</title>
+
+<para>
+ The first step to writing good tapsets is to create a simple model of your subject area. For
+ example, a model of the process subsystem might include the following:
+</para>
+
+<formalpara>
+ <title>Key Data</title>
+ <para>
+ <itemizedlist>
+ <listitem><para>process ID</para></listitem>
+ <listitem><para>parent process ID</para></listitem>
+ <listitem><para>process group ID</para></listitem>
+ </itemizedlist>
+ </para>
+</formalpara>
+
+<formalpara>
+ <title>State Transitions</title>
+ <para>
+ <itemizedlist>
+ <listitem><para>forked</para></listitem>
+ <listitem><para>exec'd</para></listitem>
+ <listitem><para>running</para></listitem>
+ <listitem><para>stopped</para></listitem>
+ <listitem><para>terminated</para></listitem>
+ </itemizedlist>
+ </para>
+</formalpara>
+
+<note>
+ <title>Note</title>
+ <para>Both lists are examples, and are not meant to represent a complete list.</para>
+</note>
+
+<para>
+ Use your subsystem expertise to find probe points (function entries and
+ exits) that expose the elements of the model, then define probe aliases
+ for those points. Be aware that some state transitions can occur in more
+ than one place. In those cases, an alias can place a probe in multiple
+ locations.
+</para>
+
+<para>
+ For example, process execs can occur in either the <command>do_execve()</command> or the
+ <command>compat_do_execve()</command> functions. The following alias inserts probes at the
+ beginning of those functions:
+</para>
+
+<programlisting>
+probe process.exec = kernel.function("do_execve"),
+kernel.function("compat_do_execve")
+{<replaceable>probe body</replaceable>}
+</programlisting>
+
+<para>
+ Try to place probes on stable interfaces (i.e., functions
+ that are unlikely to change at the interface level) whenever possible. This will
+ make the tapset less likely to break due to kernel changes. Where
+ kernel version or architecture dependencies are unavoidable, use
+ preprocessor conditionals (see the <command>stap(1)</command> man page for details).
+</para>
+
+
+<para>
+ Fill in the probe bodies with the key data available at the probe points.
+ Function entry probes can access the entry parameters specified to
+ the function, while exit probes can access the entry parameters and the
+ return value. Convert the data into meaningful forms where appropriate
+ (e.g., bytes to kilobytes, state values to strings, etc).
+</para>
+
+<para>
+ You may need to use auxiliary functions to access or convert some of the data. Auxiliary
+ functions often use embedded C to do things that cannot be done in the
+ SystemTap language, like access structure fields in some contexts, follow
+ linked lists, etc. You can use auxiliary functions defined in other tapsets
+ or write your own.
+</para>
+
+<para>
+ In the following example, <command>copy_process()</command> returns a
+ pointer to the <command>task_struct</command> for the new process. Note
+ that the process ID of the new process is retrieved by calling
+ <command>task_pid()</command> and passing it the <command>task_struct</command>
+ pointer. In this case, the auxiliary function is an embedded C function
+ that's defined in the task tapset (<filename>task.stp</filename>).
+</para>
+
+<remark>info from here:http://sources.redhat.com/git/?p=systemtap.git;a=blob_plain;f=tapset/DEVGUIDE</remark>
+
+ </section>
+<!--
+ <section id="Tapset_Reference_Guide-Test-Section_2_Test">
+ <title>Section 2 Test</title>
+ <para>
+ Test of a section
+ </para>
+ </section>
+-->
+</chapter>
+
diff --git a/doc/Tapset_Reference_Guide/publicanize.sh b/doc/Tapset_Reference_Guide/publicanize.sh
index 1139b34d..d4da6e02 100755
--- a/doc/Tapset_Reference_Guide/publicanize.sh
+++ b/doc/Tapset_Reference_Guide/publicanize.sh
@@ -1,10 +1,15 @@
#!/bin/bash
#copy the automated tapsets.xml
-cp ../SystemTap_Tapset_Reference/tapsets.xml en-US/Tapset_Reference_Guide.xml ;
+cp ../SystemTap_Tapset_Reference/tapsets.xml temp.xml ;
#remove all excess whitespace
-sed -i -e 's/^\s*//g' en-US/Tapset_Reference_Guide.xml ;
+sed -i -e 's/^\s*//g' temp.xml ;
+
+#remove marked Intro (starthere to endhere), then copy it to en-US
+sed '/starthere/,/endhere/d' temp.xml > Tapset_Reference_Guide.xml
+cp Tapset_Reference_Guide.xml en-US/Tapset_Reference_Guide.xml;
+rm Tapset_Reference_Guide.xml
#re-convert programlisting tags
sed -i -e 's/&lt;programlisting&gt;/<programlisting>/g' en-US/Tapset_Reference_Guide.xml;
@@ -22,15 +27,24 @@ perl -p -e 'undef $/;s|<para>\nYou should have received a copy of the GNU Genera
perl -p -e 'undef $/;s|<para>\nFor more details see the file COPYING in the source\ndistribution of Linux.\n</para>\n</legalnotice>\n</bookinfo>||msg' |
perl -p -e 'undef $/;s|<toc></toc>||msg' |
perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n\n\n\n||msg' |
+perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n||msg' |
perl -p -e 'undef $/;s|<programlisting>\n|<programlisting>\n<emphasis>function <\/emphasis>|msg' |
perl -p -e 'undef $/;s|<para>\n</para>||msg' |
perl -p -e 'undef $/;s|<para>\n\n</para>||msg' |
perl -p -e 'undef $/;s|<para>\n<programlisting>|<programlisting>|msg' |
perl -p -e 'undef $/;s|</programlisting>\n</para>|</programlisting>|msg' > clean.xml
+#replace Intro with my own
+perl -p -i -e 's|<!--markerforxi-->|<xi:include href="Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Tapset_Dev_Guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' clean.xml
+
+#for tapset name format section
+#perl -p -i -e 'undef $/;s|<screen>\nname:return \(parameters\)\ndefinition\n</screen>|<screen>\n<replaceable>function/probe</replaceable> tapset_name:return \(parameters\)\n</screen>|msg' clean.xml
+#perl -p -i -e 's|<para>In this guide, tapset definitions appear in the following format:</para>|<para>In this guide, the synopsis of each tapset appears in the following format:</para>|g' clean.xml
+#perl -p -i -e 's|<!-- markerforxi pls dont remove -->|<xi:include href="tapsetnameformat-lastpara.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="refentry-example.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' clean.xml
+
cp clean.xml en-US/Tapset_Reference_Guide.xml
rm clean.xml
-
+
# statements change synopsis tags, as they are still currently unfixed in publican-redhat
sed -i -e 's/refsynopsisdiv>/refsect1>/g' en-US/Tapset_Reference_Guide.xml;
sed -i -e 's/refsect1>/refsection>/g' en-US/Tapset_Reference_Guide.xml;
@@ -45,4 +59,7 @@ sed -i -e 's/&lt;remark&gt;/<remark>/g' en-US/Tapset_Reference_Guide.xml;
sed -i -e 's/&lt;\/remark&gt;/<\/remark>/g' en-US/Tapset_Reference_Guide.xml;
sed -i -e 's/&lt;command&gt;/<command>/g' en-US/Tapset_Reference_Guide.xml;
-sed -i -e 's/&lt;\/command&gt;/<\/command>/g' en-US/Tapset_Reference_Guide.xml; \ No newline at end of file
+sed -i -e 's/&lt;\/command&gt;/<\/command>/g' en-US/Tapset_Reference_Guide.xml;
+
+#useful marker script; moves content between starthere and endhere to file target
+#sed -n '/starthere/,/endhere/ s/.*/&/w target' Tapset_Reference_Guide.xml \ No newline at end of file
diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h
index ef0977ea..4ebf4fe0 100644
--- a/includes/sys/sdt.h
+++ b/includes/sys/sdt.h
@@ -33,88 +33,94 @@ static char probe ## _ ## probe_name [strlen(#probe)+1] \
= #probe; \
static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,(size_t)& probe ## _ ## probe_name[0],argc};
-#define STAP_LABEL_REF(probe) \
+// The goto _probe_ prevents the label from "drifting"
+#define STAP_LABEL_REF(probe, label) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto STAP_LABEL(probe,__LINE__);
+ goto label;
+// These baroque macros are used to create a unique label
#define STAP_CONCAT(a,b) a ## b
-#define STAP_LABEL(p,n) \
- STAP_CONCAT(_stapprobe1_ ## p ## _, n)
+#define STAP_LABEL_PREFIX(p) _stapprobe1_ ## p
+// __COUNTER__ is not present in gcc 4.1
+#if __GNUC__ == 4 && __GNUC_MINOR__ >= 3
+#define STAP_COUNTER STAP_CONCAT(__,COUNTER__)
+#else
+#define STAP_COUNTER STAP_CONCAT(__,LINE__)
+#endif
+#define STAP_LABEL(a,b) STAP_CONCAT(a,b)
-// The goto _probe_ prevents the label from "drifting"
-#define STAP_PROBE(provider,probe) \
- {__label__ STAP_LABEL(probe,__LINE__); \
-STAP_LABEL(probe,__LINE__): \
+#define STAP_PROBE_(probe,label) \
+do { \
+label: \
asm volatile ("nop"); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe) \
-}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE1(provider,probe,parm1) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE1_(probe,label,parm1) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
-STAP_LABEL(probe,__LINE__): \
- asm volatile ("nop /* %0 */" :: "g"( arg1)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+label: \
+ asm volatile ("nop /* %0 */" :: "X"( arg1)); \
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE2(provider,probe,parm1,parm2) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE2_(probe,label,parm1,parm2) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
-STAP_LABEL(probe,__LINE__): \
- asm volatile ("nop /* %0 %1 */" :: "g"(arg1), "g"(arg2)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+label: \
+ asm volatile ("nop /* %0 %1 */" :: "X"(arg1), "X"(arg2)); \
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE3(provider,probe,parm1,parm2,parm3) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE3_(probe,label,parm1,parm2,parm3) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
-STAP_LABEL(probe,__LINE__): \
- asm volatile ("nop /* %0 %1 %2 */" :: "g"(arg1), "g"(arg2), "g"(arg3)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+label: \
+ asm volatile ("nop /* %0 %1 %2 */" :: "X"(arg1), "X"(arg2), "X"(arg3)); \
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE4_(probe,label,parm1,parm2,parm3,parm4) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \
-STAP_LABEL(probe,__LINE__): \
- asm volatile ("nop /* %0 %1 %2 %3 */" :: "g"(arg1), "g"(arg2), "g"(arg3), "g"(arg4)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+label: \
+ asm volatile ("nop /* %0 %1 %2 %3 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4)); \
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE5_(probe,label,parm1,parm2,parm3,parm4,parm5) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \
volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \
-STAP_LABEL(probe,__LINE__): \
+label: \
asm volatile ("nop /* %0 %1 %2 %3 %4 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE6_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \
volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \
volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \
-STAP_LABEL(probe,__LINE__): \
+label: \
asm volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE7_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -122,13 +128,13 @@ STAP_LABEL(probe,__LINE__): \
volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \
volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \
volatile typeof((parm7)) arg7 __attribute__ ((unused)) = parm7; \
-STAP_LABEL(probe,__LINE__): \
+label: \
asm volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE8_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -137,13 +143,13 @@ STAP_LABEL(probe,__LINE__): \
volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \
volatile typeof((parm7)) arg7 __attribute__ ((unused)) = parm7; \
volatile typeof((parm8)) arg8 __attribute__ ((unused)) = parm8; \
-STAP_LABEL(probe,__LINE__): \
+label: \
asm volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE9_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -153,13 +159,13 @@ STAP_LABEL(probe,__LINE__): \
volatile typeof((parm7)) arg7 __attribute__ ((unused)) = parm7; \
volatile typeof((parm8)) arg8 __attribute__ ((unused)) = parm8; \
volatile typeof((parm9)) arg9 __attribute__ ((unused)) = parm9; \
-STAP_LABEL(probe,__LINE__): \
+label: \
asm volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
-#define STAP_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
- {__label__ STAP_LABEL(probe,__LINE__); \
+#define STAP_PROBE10_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
+do { \
volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -170,10 +176,33 @@ STAP_LABEL(probe,__LINE__): \
volatile typeof((parm8)) arg8 __attribute__ ((unused)) = parm8; \
volatile typeof((parm9)) arg9 __attribute__ ((unused)) = parm9; \
volatile typeof((parm10)) arg10 __attribute__ ((unused)) = parm9; \
-STAP_LABEL(probe,__LINE__): \
+label: \
asm volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9), "X"(arg10)); \
- STAP_PROBE_STRUCT(probe,(size_t)&& STAP_LABEL(probe,__LINE__)) \
- STAP_LABEL_REF(probe);}
+ STAP_PROBE_STRUCT(probe,(size_t)&& label) \
+ STAP_LABEL_REF(probe,label);} while (0)
+
+#define STAP_PROBE(provider,probe) \
+ STAP_PROBE_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER))
+#define STAP_PROBE1(provider,probe,...) \
+ STAP_PROBE1_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE2(provider,probe,...) \
+ STAP_PROBE2_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE3(provider,probe,...) \
+ STAP_PROBE3_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE4(provider,probe,...) \
+ STAP_PROBE4_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE5(provider,probe,...) \
+ STAP_PROBE5_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE6(provider,probe,...) \
+ STAP_PROBE6_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE7(provider,probe,...) \
+ STAP_PROBE7_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE8(provider,probe,...) \
+ STAP_PROBE8_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE9(provider,probe,...) \
+ STAP_PROBE9_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+#define STAP_PROBE10(provider,probe,...) \
+ STAP_PROBE10_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
#define DTRACE_PROBE(provider,probe) \
STAP_PROBE(provider,probe)
diff --git a/tapset/nfs.stp b/tapset/nfs.stp
index 474b091f..fe25eff2 100644
--- a/tapset/nfs.stp
+++ b/tapset/nfs.stp
@@ -135,69 +135,55 @@ function __nfs_wpages:long(inode:long) %{ /* pure */
%}
/*Get struct inode from struct page*/
-function __p2i :long(page:long) %{ /* pure */
- struct page *page = (struct page *)((long)THIS->page);
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
-
- if (mapping == NULL)
- THIS->__retvalue = 0;
+function __p2i :long(page:long)
+{
+ mapping = page? @cast(page, "page", "kernel")->mapping : 0
+ if (mapping == 0)
+ return 0
else
- THIS->__retvalue = (long)kread(&(mapping->host));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(mapping, "address_space", "kernel")->host
+}
/*Get i_flags from struct page*/
-function __p2i_flag : long (page:long) %{ /* pure */
- struct page *page = (struct page *)((long)THIS->page);
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- struct inode *host = mapping? kread(&(mapping->host)) : NULL;
-
- if (host == NULL)
- THIS->__retvalue = -1;
+function __p2i_flag : long (page:long)
+{
+ host = __p2i(page)
+ if (host == 0)
+ return -1
else
- THIS->__retvalue = kread(&(host->i_flags));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(host, "inode", "kernel")->i_flags
+}
/*Get i_state from struct page*/
-function __p2i_state :long (page:long) %{ /* pure */
- struct page *page = (struct page *)((long)THIS->page);
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- struct inode *host = mapping? kread(&(mapping->host)) : NULL;
-
- if (host == NULL)
- THIS->__retvalue = -1;
+function __p2i_state :long (page:long)
+{
+ host = __p2i(page)
+ if (host == 0)
+ return -1
else
- THIS->__retvalue = kread(&(host->i_state));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(host, "inode", "kernel")->i_state
+}
/*Get i_size from struct page*/
-function __p2i_size :long (page:long) %{ /* pure */
- struct page *page = (struct page *)((long)THIS->page);
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- struct inode *host = mapping? kread(&(mapping->host)) : NULL;
-
- if (host == NULL)
- THIS->__retvalue = -1;
+function __p2i_size :long (page:long)
+{
+ host = __p2i(page)
+ if (host == 0)
+ return -1
else
- THIS->__retvalue = kread(&(host->i_size));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(host, "inode", "kernel")->i_size
+}
/*Get s_flags from struct page*/
-function __p2sb_flag:long (page:long) %{ /* pure */
- struct page *page = (struct page *)((long)THIS->page);
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- struct inode *host = mapping? kread(&(mapping->host)) : NULL;
- struct super_block *i_sb = host? kread(&(host->i_sb)) : NULL;
-
- if (i_sb == NULL)
- THIS->__retvalue = -1;
+function __p2sb_flag:long (page:long)
+{
+ host = __p2i(page)
+ i_sb = host? @cast(host, "inode", "kernel")->i_sb : 0
+ if (i_sb == 0)
+ return -1
else
- THIS->__retvalue = kread(&(i_sb->s_flags));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(i_sb, "super_block", "kernel")->s_flags
+}
function __d_loff_t :long (ppos :long) %{ /* pure */
loff_t * ppos = (loff_t *) ((long)THIS->ppos);
@@ -209,53 +195,54 @@ function __d_loff_t :long (ppos :long) %{ /* pure */
CATCH_DEREF_FAULT();
%}
-function __file_inode:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL)
- THIS->__retvalue = 0;
+function __file_inode:long (file:long)
+{
+%( kernel_v >= "2.6.20" %?
+ dentry = file? @cast(file, "file", "kernel")->f_path->dentry : 0
+%:
+ dentry = file? @cast(file, "file", "kernel")->f_dentry : 0
+%)
+ if (dentry == 0)
+ return 0
else
- THIS->__retvalue = (long)kread(&(dentry->d_inode));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(dentry, "dentry", "kernel")->d_inode
+}
-function __file_id:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL)
- THIS->__retvalue = 0;
+function __file_id:long (file:long)
+{
+ d_inode = __file_inode(file)
+ if (d_inode == 0)
+ return 0
else {
- struct inode *d_inode = kread(&(dentry->d_inode));
- struct super_block *i_sb = kread(&(d_inode->i_sb));
- THIS->__retvalue = (long)&(i_sb->s_id);
+ i_sb = @cast(d_inode, "inode", "kernel")->i_sb
+ return @cast(i_sb, "super_block", "kernel")->s_id
}
- CATCH_DEREF_FAULT();
-%}
+}
-function __file_mode:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL)
- THIS->__retvalue = 0;
- else {
- struct inode *d_inode = kread(&(dentry->d_inode));
- THIS->__retvalue = kread(&(d_inode->i_mode));
- }
- CATCH_DEREF_FAULT();
-%}
+function __file_mode:long (file:long)
+{
+ d_inode = __file_inode(file)
+ if (d_inode == 0)
+ return 0
+ else
+ return @cast(d_inode, "inode", "kernel")->i_mode
+}
-function __file_parentname:string (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- struct dentry *d_parent = dentry? kread(&(dentry->d_parent)) : NULL;
- if (d_parent == NULL)
- strlcpy(THIS->__retvalue, "NULL", MAXSTRINGLEN);
+function __file_parentname:string (file:long)
+{
+%( kernel_v >= "2.6.20" %?
+ dentry = file? @cast(file, "file", "kernel")->f_path->dentry : 0
+%:
+ dentry = file? @cast(file, "file", "kernel")->f_dentry : 0
+%)
+ d_parent = dentry? @cast(dentry, "dentry", "kernel")->d_parent : 0
+ if (d_parent == 0)
+ return "NULL"
else {
- const unsigned char *name = kread(&(d_parent->d_name.name));
- deref_string(THIS->__retvalue, name, MAXSTRINGLEN);
+ name = @cast(d_parent, "dentry", "kernel")->d_name->name
+ return kernel_string(name)
}
- CATCH_DEREF_FAULT();
-%}
+}
/*
* Combination of generic_segment_checks and iov_length functions
diff --git a/tapset/rpc.stp b/tapset/rpc.stp
index f97117b5..e6eaed46 100644
--- a/tapset/rpc.stp
+++ b/tapset/rpc.stp
@@ -877,60 +877,52 @@ probe sunrpc.sched.delay.return = kernel.function("rpc_delay").return !,
*****************************************************************/
function xid_from_clnt:long(clnt:long)
-%{ /* pure */
- struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
- if (clnt == NULL)
- THIS->__retvalue = 0;
+{
+ if (clnt == 0)
+ return 0
else {
- struct rpc_xprt *cl_xprt = kread(&(clnt->cl_xprt));
- THIS->__retvalue = kread(&(cl_xprt->xid));
+ cl_xprt = @cast(clnt, "rpc_clnt", "kernel")->cl_xprt
+ return @cast(cl_xprt, "rpc_xprt", "kernel")->xid
}
- CATCH_DEREF_FAULT();
-%}
+}
function prog_from_clnt:long(clnt:long)
-%{ /* pure */
- struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
- if (clnt == NULL)
- THIS->__retvalue = 0;
+{
+ if (clnt == 0)
+ return 0
else {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
- THIS->__retvalue = kread(&(clnt->cl_prog));
-#else
- struct rpc_portmap *cl_pmap = kread(&(clnt->cl_pmap));
- THIS->__retvalue = kread(&(cl_pmap->pm_prog));
-#endif
+%(kernel_v >= "2.6.19" %?
+ return @cast(clnt, "rpc_clnt", "kernel")->cl_prog
+%:
+ cl_pmap = @cast(clnt, "rpc_clnt", "kernel")->cl_pmap
+ return @cast(cl_pmap, "rpc_portmap", "kernel")->pm_prog
+%)
}
- CATCH_DEREF_FAULT();
-%}
+}
function vers_from_clnt:long(clnt:long)
-%{ /* pure */
- struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
- if (clnt == NULL)
- THIS->__retvalue = 0;
- else {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
- THIS->__retvalue = kread(&(clnt->cl_vers));
-#else
- struct rpc_portmap *cl_pmap = kread(&(clnt->cl_pmap));
- THIS->__retvalue = kread(&(cl_pmap->pm_vers));
-#endif
- }
- CATCH_DEREF_FAULT();
-%}
+{
+ if (clnt == 0)
+ return 0
+ else {
+%(kernel_v >= "2.6.19" %?
+ return @cast(clnt, "rpc_clnt", "kernel")->cl_vers
+%:
+ cl_pmap = @cast(clnt, "rpc_clnt", "kernel")->cl_pmap
+ return @cast(cl_pmap, "rpc_portmap", "kernel")->pm_vers
+%)
+ }
+}
function prot_from_clnt:long(clnt:long)
-%{ /* pure */
- struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
- if (clnt == NULL)
- THIS->__retvalue = 0;
- else {
- struct rpc_xprt *cl_xprt = kread(&(clnt->cl_xprt));
- THIS->__retvalue = kread(&(cl_xprt->prot));
- }
- CATCH_DEREF_FAULT();
-%}
+{
+ if (clnt == 0)
+ return 0
+ else {
+ cl_xprt = @cast(clnt, "rpc_clnt", "kernel")->cl_xprt
+ return @cast(cl_xprt, "rpc_xprt", "kernel")->prot
+ }
+}
function port_from_clnt:long(clnt:long)
%{ /* pure */
@@ -975,16 +967,14 @@ function tasks_from_clnt:long(clnt:long)
%}
function proc_from_msg:long(msg:long)
-%{ /* pure */
- struct rpc_message *msg = (struct rpc_message *)(long)THIS->msg;
- if (msg == NULL)
- THIS->__retvalue = 0;
+{
+ if (msg == 0)
+ return 0
else {
- struct rpc_procinfo *rpc_proc = kread(&(msg->rpc_proc));
- THIS->__retvalue = kread(&(rpc_proc->p_proc));
+ rpc_proc = @cast(msg, "rpc_message", "kernel")->rpc_proc
+ return @cast(rpc_proc, "rpc_procinfo", "kernel")->p_proc
}
- CATCH_DEREF_FAULT();
-%}
+}
function vers_from_prog:long(program:long, vers:long)
%{ /* pure */
diff --git a/tapset/scsi.stp b/tapset/scsi.stp
index 76b9a114..b1b2d19b 100644
--- a/tapset/scsi.stp
+++ b/tapset/scsi.stp
@@ -136,9 +136,7 @@ function scsi_timer_pending:long(var:long)
%}
function get_devstate_from_req:long(var:long)
-%{ /* pure */
- struct request_queue *q = (struct request_queue *)((long)THIS->var);
- struct scsi_device *sdev = (struct scsi_device *)kread(&(q->queuedata));
- THIS->__retvalue = kread(&(sdev->sdev_state));
- CATCH_DEREF_FAULT();
-%}
+{
+ sdev = @cast(var, "request_queue", "kernel")->queuedata
+ return @cast(sdev, "scsi_device", "kernel")->sdev_state
+}
diff --git a/tapset/signal.stp b/tapset/signal.stp
index f40958e6..8fb6fe57 100644
--- a/tapset/signal.stp
+++ b/tapset/signal.stp
@@ -608,17 +608,15 @@ probe signal.flush = kernel.function("flush_signals")
pid_name = kernel_string($t->comm)
}
-function get_sa_flags:long (act:long) %{ /* pure */
- struct k_sigaction *act = (struct k_sigaction *)((long)THIS->act);
- THIS->__retvalue = kread(&act->sa.sa_flags);
- CATCH_DEREF_FAULT();
-%}
+function get_sa_flags:long (act:long)
+{
+ return @cast(act, "k_sigaction", "kernel")->sa->sa_flags
+}
-function get_sa_handler:long (act:long) %{ /* pure */
- struct k_sigaction *act = (struct k_sigaction *)((long)THIS->act);
- THIS->__retvalue = (long)kread(&act->sa.sa_handler);
- CATCH_DEREF_FAULT();
-%}
+function get_sa_handler:long (act:long)
+{
+ return @cast(act, "k_sigaction", "kernel")->sa->sa_handler
+}
// sa_mask contains the set of signals to be blocked when executing the
// signal handler. This function returns a string, delimited by ",".
diff --git a/tapset/socket.stp b/tapset/socket.stp
index 842dbfc4..3271d4f7 100644
--- a/tapset/socket.stp
+++ b/tapset/socket.stp
@@ -922,53 +922,43 @@ function _get_sock_size:long (iov:long, nr_segs:long)
%}
function _sock_prot_num:long (sock:long)
-%{ /* pure */
- struct socket *sktp = (struct socket *)(long)(THIS->sock);
- struct sock *skp = sktp? kread(&(sktp->sk)) : NULL;
- if (skp == NULL)
- THIS->__retvalue = -1;
+{
+ skp = sock? @cast(sock, "socket", "kernel")->sk : 0
+ if (skp == 0)
+ return -1
else
- THIS->__retvalue = kread(&(skp->sk_protocol));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(skp, "sock", "kernel")->sk_protocol
+}
function _sock_fam_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- const struct proto_ops *ops = sockp? kread(&(sockp->ops)) : NULL;
- if (ops == NULL)
- THIS->__retvalue = -1;
+{
+ ops = sock? @cast(sock, "socket", "kernel")->ops : 0
+ if (ops == 0)
+ return -1
else
- THIS->__retvalue = kread(&(ops->family));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(ops, "proto_ops", "kernel")->family
+}
function _sock_state_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- if (sockp == NULL)
- THIS->__retvalue = -1;
+{
+ if (sock == 0)
+ return -1
else
- THIS->__retvalue = kread(&(sockp->state));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(sock, "socket", "kernel")->state
+}
function _sock_type_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- if (sockp == NULL)
- THIS->__retvalue = -1;
- else
- THIS->__retvalue = kread(&(sockp->type));
- CATCH_DEREF_FAULT();
-%}
+{
+ if (sock == 0)
+ return -1
+ else
+ return @cast(sock, "socket", "kernel")->type
+}
function _sock_flags_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- if (sockp == NULL)
- THIS->__retvalue = -1;
- else
- THIS->__retvalue = kread(&(sockp->flags));
- CATCH_DEREF_FAULT();
-%}
+{
+ if (sock == 0)
+ return -1
+ else
+ return @cast(sock, "socket", "kernel")->flags
+}
diff --git a/tapset/task.stp b/tapset/task.stp
index 684cef93..07337156 100644
--- a/tapset/task.stp
+++ b/tapset/task.stp
@@ -43,35 +43,31 @@ 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));
- CATCH_DEREF_FAULT();
-%}
+function task_pid:long (task:long)
+{
+ return @cast(task, "task_struct", "kernel")->tgid
+}
// 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 +152,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)
diff --git a/tapset/vfs.stp b/tapset/vfs.stp
index 43603177..3bb9292d 100644
--- a/tapset/vfs.stp
+++ b/tapset/vfs.stp
@@ -51,136 +51,106 @@ function ppos_pos:long (ppos:long) %{ /* pure */
CATCH_DEREF_FAULT();
%}
-function __page_ino:long (page:long) %{ /* pure */
- struct page *page = (struct page *)(long)THIS->page;
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- if (mapping == NULL) {
- THIS->__retvalue = -1;
- } else {
- struct inode *host = kread(&(mapping->host));
- THIS->__retvalue = kread(&(host->i_ino));
- }
- CATCH_DEREF_FAULT();
-%}
-
-function __address_inode:long (page:long) %{ /* pure */
- struct page *page = (struct page *)(long)THIS->page;
- struct address_space *mapping = kread(&(page->mapping));
- if (mapping == NULL) {
- THIS->__retvalue = -1;
- } else {
- THIS->__retvalue = (long)kread(&(mapping->host));
- }
- CATCH_DEREF_FAULT();
-%}
+function __address_inode:long (page:long)
+{
+ mapping = page? @cast(page, "page", "kernel")->mapping : 0
+ if (mapping == 0)
+ return -1
+ else
+ return @cast(mapping, "address_space", "kernel")->host
+}
-function __page_dev:long (page:long) %{ /* pure */
- struct page *page = (struct page *)(long)THIS->page;
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- if (mapping == NULL) {
- THIS->__retvalue = -1;
- } else {
- struct inode *host = kread(&(mapping->host));
- struct super_block *i_sb = kread(&(host->i_sb));
- THIS->__retvalue = kread(&(i_sb->s_dev));
- }
- CATCH_DEREF_FAULT();
-%}
+function __page_ino:long (page:long)
+{
+ host = __address_inode(page)
+ if (host == -1)
+ return -1
+ else
+ return @cast(host, "inode", "kernel")->i_ino
+}
-function __page_bdev:long (page:long) %{ /* pure */
- struct page *page = (struct page *)(long)THIS->page;
- struct address_space *mapping = page? kread(&(page->mapping)) : NULL;
- if (mapping == NULL) {
- THIS->__retvalue = 0;
- } else {
- struct inode *host = kread(&(mapping->host));
- struct super_block *i_sb = kread(&(host->i_sb));
- THIS->__retvalue = (long)kread(&(i_sb->s_bdev));
+function __page_dev:long (page:long)
+{
+ host = __address_inode(page)
+ if (host == -1)
+ return -1
+ else {
+ i_sb = @cast(host, "inode", "kernel")->i_sb
+ return @cast(i_sb, "super_block", "kernel")->s_dev
}
- CATCH_DEREF_FAULT();
-%}
+}
-function __page_index:long (page:long) %{ /* pure */
- struct page *page = (struct page *)(long)THIS->page;
- THIS->__retvalue = (long)kread(&(page->index));
- CATCH_DEREF_FAULT();
-%}
+function __page_bdev:long (page:long)
+{
+ host = __address_inode(page)
+ if (host == -1)
+ return 0
+ else {
+ i_sb = @cast(host, "inode", "kernel")->i_sb
+ return @cast(i_sb, "super_block", "kernel")->s_bdev
+ }
+}
-function __file_dev:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL) {
- THIS->__retvalue = 0;
- } else {
- struct inode *d_inode = kread(&(dentry->d_inode));
- struct super_block *i_sb = kread(&(d_inode->i_sb));
- THIS->__retvalue = kread(&(i_sb->s_dev));
- }
- CATCH_DEREF_FAULT();
-%}
+function __page_index:long (page:long)
+{
+ return @cast(page, "page", "kernel")->index
+}
-function __file_bdev:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL) {
- THIS->__retvalue = 0;
- } else {
- struct inode *d_inode = kread(&(dentry->d_inode));
- struct super_block *i_sb = kread(&(d_inode->i_sb));
- THIS->__retvalue = (long)kread(&(i_sb->s_bdev));
+function __file_dev:long (file:long)
+{
+ d_inode = __file_inode(file)
+ if (d_inode == 0)
+ return 0
+ else {
+ i_sb = @cast(d_inode, "inode", "kernel")->i_sb
+ return @cast(i_sb, "super_block", "kernel")->s_dev
}
- CATCH_DEREF_FAULT();
-%}
+}
-function __file_ino:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL) {
- THIS->__retvalue = 0;
- } else {
- struct inode *d_inode = kread(&(dentry->d_inode));
- THIS->__retvalue = kread(&(d_inode->i_ino));
- }
- CATCH_DEREF_FAULT();
-%}
+function __file_bdev:long (file:long)
+{
+ d_inode = __file_inode(file)
+ if (d_inode == 0)
+ return 0
+ else {
+ i_sb = @cast(d_inode, "inode", "kernel")->i_sb
+ return @cast(i_sb, "super_block", "kernel")->s_bdev
+ }
+}
-function __file_maxbytes:long (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- if (dentry == NULL) {
- THIS->__retvalue = 0;
- } else {
- struct inode *d_inode = kread(&(dentry->d_inode));
- struct super_block *i_sb = kread(&(d_inode->i_sb));
- THIS->__retvalue = kread(&(i_sb->s_maxbytes));
- }
- CATCH_DEREF_FAULT();
-%}
+function __file_ino:long (file:long)
+{
+ d_inode = __file_inode(file)
+ if (d_inode == 0)
+ return 0
+ else
+ return @cast(d_inode, "inode", "kernel")->i_ino
+}
-function __file_filename:string (file:long) %{ /* pure */
- struct file *file = (struct file *)(long)THIS->file;
- struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
- const unsigned char *name = dentry? kread(&(dentry->d_name.name)) : NULL;
- if (name == NULL) {
- strlcpy(THIS->__retvalue, "NULL", MAXSTRINGLEN);
- } else {
- deref_string(THIS->__retvalue, name, MAXSTRINGLEN);
- }
- CATCH_DEREF_FAULT();
-%}
+function __file_maxbytes:long (file:long)
+{
+ d_inode = __file_inode(file)
+ if (d_inode == 0)
+ return 0
+ else {
+ i_sb = @cast(d_inode, "inode", "kernel")->i_sb
+ return @cast(i_sb, "super_block", "kernel")->s_maxbytes
+ }
+}
-function __inode_num:long(file:long)
-%{
- struct file *file = NULL;
- struct dentry *dentry = NULL;
- struct inode *inode = NULL;
-
- file = (struct file *)(long)THIS->file;
- dentry = file? kread(&(file->f_dentry)) : NULL;
- inode = dentry? kread(&(dentry->d_inode)) : NULL;
- THIS->__retvalue = inode? (long)(kread(&(inode->i_ino))) : 0;
- CATCH_DEREF_FAULT();
-%}
+function __file_filename:string (file:long)
+{
+%( kernel_v >= "2.6.20" %?
+ dentry = file? @cast(file, "file", "kernel")->f_path->dentry : 0
+%:
+ dentry = file? @cast(file, "file", "kernel")->f_dentry : 0
+%)
+ name = dentry? @cast(dentry, "dentry", "kernel")->d_name->name : 0
+ if (name == 0)
+ return "NULL"
+ else
+ return kernel_string(name)
+}
function _get_fopv_size:long (iov:long, nr_segs:long)
%{