Global constants
Stone, Joshua I
joshua.i.stone@intel.com
Mon Feb 13 20:36:00 GMT 2006
Martin Hunt wrote:
> Also it would be nice to have a way to declare these constants in
> embedded C, so we can use the C header files to get the values, rather
> than look them up.
>
> something like
> %{ const_O_CREAT = O_CREAT; %}
> instead of
> O_CREAT = 64
Along these same lines, it would be nice to have a more direct way to
access macros, instead of resorting to embedded-C. Perhaps something
like:
import O_CREAT, O_TRUNC, O_APPEND
The translator could make references to "imported" values as direct
macro accesses, instead of needing a global systemtap variable.
There are of course safety issues here - the imported name should be a
macro, and cannot have side-effects. An #ifndef,#error check fixes the
first, but the second is tricky. There are also type-safety issues to
consider.
Direct access to macros would make script parameters easy:
# openwatch.stp
import FILE_TO_WATCH
probe syscall.open {
if (FILE_TO_WATCH == filename)
log(<relevant info>)
}
$ stap openwatch.stp -D FILE_TO_WATCH="/etc/passwd"
This can be imitated with an embedded-C function and a begin probe to
read it, but guru-mode shouldn't be required for simple parameter
access.
Josh
More information about the Systemtap
mailing list