This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: Global constants
- From: "Stone, Joshua I" <joshua dot i dot stone at intel dot com>
- To: "Martin Hunt" <hunt at redhat dot com>, "Frank Ch. Eigler" <fche at redhat dot com>
- Cc: "Mark McLoughlin" <markmc at redhat dot com>, <systemtap at sourceware dot org>
- Date: Mon, 13 Feb 2006 12:36:15 -0800
- Subject: RE: Global constants
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