This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem about tapset script


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();
> %}

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]