This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: access pointer and global variables
On Thu, 2007-06-07 at 13:39 -0700, Stone, Joshua I wrote:
> David Smith wrote:
> > I agree with you that this might be implementable, but is it what you
> > would really want? In a return probe would you want the original value
> > of $prev->pid or the current value (assuming the function changed the
> > data pointed to by $prev)?
> >
> > I'd guess that most times you'd want the current value.
>
> That's a hard question to answer, because it can easily go either way.
> For strace-like scripts, you generally want to say "this function with
> these arguments produced this return value" -- so you want the original
> values. But there are certainly times when you want to see how the
> arguments were updated.
I agree: it depends.
In my current application of stap, the value I'm interested in is
regs->eip. regs is the function arg, and its value doesn't change, but
the value of regs->eip does change. When I refer to $regs->eip in the
return probe, what I want is entry_value($regs)->eip, but what stap
gives me is entry_value($regs->eip).
So I had to cache the value of regs, and write an embedded-C function
(to be called from the return probe) to cast regs[tid()] back to a
struct pt_regs* and get the (updated) eip member. (Cuz stap doesn't
support casts, right?)
>
> For a lot of cases, I think the arguments aren't modified, so it
> wouldn't matter when you read them.
>
> I think we can either find a way to do both, for the best flexibility,
> or else pick the one that's the most sane (implementable? matches most
> users' expectation?) and document how it works.
I'd much rather see the former. Make stap require the script author to
specify what he/she wants -- e.g., via a built-in function such as
entry_value($arg) -- at the very least if it's a dereferenced pointer.
Even if it's just an int or something, the current practice of allowing
plain old $arg in a return probe could be misleading.
>
>
> Josh
Jim