public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: fche@redhat.com (Frank Ch. Eigler)
To: Craig Ringer <craig@2ndquadrant.com>
Cc: systemtap@sourceware.org
Subject: Re: Typed locals in functions and probes? Feasibility of language enhancement?
Date: Thu, 20 Aug 2020 19:17:24 -0400	[thread overview]
Message-ID: <87eeo07vqn.fsf@redhat.com> (raw)
In-Reply-To: <CAMsr+YGv1wWciZDs6DC6md2HuJq7wAJ424uvFsfdS-v4eVRgfw@mail.gmail.com>


craig wrote:

> I find that I write things like this a lot:
>
> if (foo && (@cast(foo)->bar)
>     return @cast(foo)->bar->baz
>
> Because systemtap type-erases locals to long or string, code for member
> access gets repetitive fast. I can @define macros for shorthand, but that
> only goes so far, and it obfuscates the code a bit.
> Is there an accepted pattern for this that I'm missing?

Systemtap actually tries to associate some dwarf-based typing with local
variables.  For example, this works:

  probe kernel.function("work_busy") { f($work) }
  function f(w) { ww = & @cast(w,"work_struct");
                  println(ww->data->counter) }

This is due to the "auto-casting" facility added to systemtap
back in 2014.  I ... can't seem to find the facility actually
documented in the stap or stapprobes man page tho.  See this
bit of the systemtap 2.6 release notes:

https://sourceware.org/legacy-ml/systemtap/2014-q3/msg00231.html

We could probably start tracking these types across function call
parameter-passing boundaries also.  Via PR25841, functions called from a
probe handler also have some connection to the dwarf context.


- FChE


      reply	other threads:[~2020-08-20 23:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21  2:48 Craig Ringer
2020-08-20 23:17 ` Frank Ch. Eigler [this message]

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=87eeo07vqn.fsf@redhat.com \
    --to=fche@redhat.com \
    --cc=craig@2ndquadrant.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).