From: Josh Stone <jistone@redhat.com>
To: systemtap@sourceware.org
Subject: native typecasting in scripts
Date: Thu, 19 Feb 2009 12:38:00 -0000 [thread overview]
Message-ID: <499CC36C.1060502@redhat.com> (raw)
Hi all,
Today I committed support for typecasting in systemtap scripts with
@cast(). You no longer have to resort to embedded-C to access members
of arbitrary pointer types! It's also now possible to dereference
pointers to usermode C/C++ types, which embedded-C can't handle.
I've included the manpage excerpt on typecasting below. I would
appreciate any feedback and early test results while I work on proper
testcases for this feature.
Thanks!
Josh
TYPECASTING
Once a pointer has been saved into a script integer
variable, the translator loses the type information
necessary to access members from that pointer. Using
the @cast() operator tells the translator how to read
a pointer.
@cast(p, "type_name"[, "module"])->member
This will interpret p as a pointer to a struct/union
named type_name and dereference the member value. The
optional module tells the translator where to look for
information about that type. If the module is not
specified, it will default either to the probe module
for dwarf probes, or to "kernel" for functions and all
other probes types.
When in guru mode, the translator will also allow
scripts to assign new values to members of typecasted
pointers.
Typecasting is also useful in the case of void* mem-
bers whose type may be determinable at runtime.
probe foo {
if ($var->type == 1) {
value = @cast($var->data, "type1")->bar
} else {
value = @cast($var->data, "type2")->baz
}
print(value)
}
reply other threads:[~2009-02-19 2:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=499CC36C.1060502@redhat.com \
--to=jistone@redhat.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).