This is the mail archive of the systemtap@sources.redhat.com mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: variables in scopes


Vara Prasad wrote:

> Let me make sure i understand your proposal.
> Let us say if function z calls function a and then function a calls
> function b like in the following.
> z(i,j)->a(x,y)->b(c,d)

That's not really possible.  This would require that we can do all this
work at runtime since there is no guarantee that b is called from a alone.

I'm talking about either inlined functions or code like this:

int foo (int a, int b) {
  int c = a;
  if (c != 0) {
    int a = 42 + b;
    bar(&a);
    c += a;
  }
  return c;
}

Here 'a' is shadowed.  You can easily construct a similar case with
inlining.  And both variables could be parameters, of local variables,
or any combination.

In DWARF the if block is encoded with DW_TAG_lexical_block.  This is one
level down from the block of the function.  So the variable could
theoretically be accessed for a probe at the call to 'bar' with

  @a@

and the parameter with

  @a\1@

meaning, one level up.


> Can you give me some example usage for this feature in a systemtap script?

I think you see that the misunderstanding has prevented you from seeing
an application.  A probe at the call to 'bar' certainly might want to
look at the parameter 'a'.

-- 
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]