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


Ulrich Drepper wrote:

I'll soon start looking into adding code to libdw to access variables
visible at a given address.  One thing I want to implement is to allow
accessing shadowed variables.  It always bothered me that gdb cannot do
it (directly) but at least it is possible if one manually climbs the
frames down.

For systemtap this is different.  So we need a syntax for this.  Any
suggestions?  I imagine that something like

@var\2@

could mean 'var' at least two levels/scopes up.  Is this an OK
interface?  I don't necessarily mean the syntax, but using a numeric to
mean "at least N levels up".

Alternatives would be something like

@var\fct\2@

meaning "at least two levels down in the scope of function fct".

I'm open for suggestions.



Thanks for your help in enhancing libdw.

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)
Let us say we are now probing function b, if i understand correctly this proposal is how do we provide access to variable x from caller a or to variable i from caller z in the probe handler, please correct me if i am wrong.


My questions/concerns:
My thinking is we should let probe handler have access to only the local variables that it will have access if the code was written inline in the function being probed. In the above example the probe handler will only have access to c and d but not others. If one needs access to locals in other function my thinking they should put probes in those functions.


There is nothing wrong in implementing what you have proposed but i am afraid we will be making systemtap as a scripted debugger than a tracing and profiling tool. Do we really want to expand the scope to that of a true debugger?

If we really want to implement this i would suggest doing this as a function call rather than as the language construct. A function something like getshadowvar(variable_name, function_in_which_it_is_active, levels_above)
this way we can keep language simple.


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

bye,
Vara Prasad




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