Another problem to which dynamic tracing systems face is stability of in-kernel interfaces. While system calls never change their interface due to backwards compatibility (if something need to be changed, new system call is introduced†), internal kernel function often do that especially if they not a public API for a drivers. Dynamic tracing languages provide mechanisms to avoid direct use of in-kernel interface by hiding them in abstractions:
Global variables and raw arguments like
Raw arguments like
statically defined tracing providers (like
tapset aliases, i.e.
static tracepoints with
statically defined ftrace probes like
DWARF probes like
To achieve maximum script portability, you should pick highest stability options wherever possible. Downside of that approach is that it provides fewer information than you could access with other approaches. These options will be described in Translators and tapsets section of next module.
Linux kernel is changing faster: it has stable releases each 2-3 months, and moreover, its builds are configurable, so some features present in one kernel may be disabled in another and vice versa which makes stability is much more fragile. To overcome that, SystemTap Language has conditional compilation statements which like in C allow to disable certain paths in code. Simplest conditional compilation statements are
@defined which evaluates to true if variable passed to it is present in debug information and
@choose_defined which chooses from several variables. It also support ternary conditional expression:
%( kernel_v >= "2.6.30" %? count = kernel_long($cnt) %: count = $cnt %)
kernel_v is numerical version of kernel without suffix (for version with suffix, use
kernel_vr). SystemTap also defines
arch variable and
CONFIG_* tokens similiar to configuration options. These options are not available in Embedded C, use traditional preprocessor there.
Finally, if some probe is missing from kernel, script compilation will fail. DTrace allow to ignore such errors by passing
-Z command line option. In SystemTap you may add
? at the end of probe name to make this probe optional.
† –- unless you are running Solaris 11 which was deprecated and obsoleted many of its system calls..