problem about tapset script
Adrien Kunysz
adrien@kunysz.be
Tue Mar 20 08:19:00 GMT 2012
On Tue, Mar 20, 2012 at 04:07:22PM +0800, ch huang wrote:
> i read tcp.stp script and see the following code ,this is Embedded C
> code ,i do not know why each function has THIS->xxx and
> CATCH_DEREF_FAULT()
> and i can not find the explain in systemtap language reference
> document ,any one can help?
THIS is to access arguments and return value as documented in the
SystemTap Language Reference: http://sourceware.org/systemtap/langref/Components_SystemTap_script.html#SECTION00046000000000000000
The CATCH_DEREF_FAULT macro is defined and documented in runtime/loc2c-runtime.h:
58 /* The deref and store_deref macros are called to safely access addresses
59 in the probe context. These macros are used only for kernel addresses.
60 The macros must handle bogus addresses here gracefully (as from
61 corrupted data structures, stale pointers, etc), by doing a "goto
62 deref_fault".
..
979 #define CATCH_DEREF_FAULT() \
980 if (0) { \
981 deref_fault: ; \
982 }
> %{ /* pure */
> struct sock *sk = (struct sock *)(long) THIS->sock;
> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
> struct tcp_opt *tp = tcp_sk(sk);
> THIS->__retvalue = (int64_t) jiffies_to_usecs(kread(&(tp->rto)));
> #else
> const struct inet_connection_sock *icsk = inet_csk(sk);
> THIS->__retvalue = (int64_t) jiffies_to_usecs(kread(&(icsk->icsk_rto)));
> #endif
> CATCH_DEREF_FAULT();
> %}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/systemtap/attachments/20120320/3fd4cfb0/attachment.sig>
More information about the Systemtap
mailing list