Typed locals in functions and probes? Feasibility of language enhancement?
Frank Ch. Eigler
fche@redhat.com
Thu Aug 20 23:17:24 GMT 2020
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
More information about the Systemtap
mailing list