Red Hat ENTERPRISE LINUX 5.4 - SYSTEMTAP LANGUAGE Reference Manual page 21

Systemtap language reference
Hide thumbs Also See for ENTERPRISE LINUX 5.4 - SYSTEMTAP LANGUAGE:
Table of Contents

Advertisement

Embedded C functions
that could potentially be invalid or dangerous. If you are unsure, err on the side of caution and use
kread(). The kread() macro is one of the safety mechanisms used in code generated by embedded C.
It protects against pointer accesses that could crash the system.
For example, to access the pointer chain name = skb->dev->name in embedded C, use the
following code.
struct net_device *dev;
char *name;
dev = kread(&(skb->dev));
name = kread(&(dev->name));
The memory locations reserved for input and output values are provided to a function using a macro
named THIS
. The following are examples.
function add_one (val) %{
THIS->__retvalue = THIS->val + 1;
}
function add_one_str (val) %{
strlcpy (THIS->__retvalue, THIS->val, MAXSTRINGLEN);
strlcat (THIS->__retvalue, "one", MAXSTRINGLEN);
}
The function argument and return value types must be inferred by the translator from the call sites
in order for this method to work. You should examine C code generated for ordinary script language
functions to write compatible embedded-C. Note that all SystemTap functions and probes run with
interrupts disabled, thus you cannot call functions that might sleep from within embedded C.
13

Advertisement

Table of Contents
loading

Table of Contents