public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* native typecasting in scripts
@ 2009-02-19 12:38 Josh Stone
  0 siblings, 0 replies; only message in thread
From: Josh Stone @ 2009-02-19 12:38 UTC (permalink / raw)
  To: systemtap

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)
               }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-19  2:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-19 12:38 native typecasting in scripts Josh Stone

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).