public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Using kernel global variables
@ 2007-08-05  3:26 David Wilder
  2007-08-06 12:08 ` Mike Mason
  0 siblings, 1 reply; 5+ messages in thread
From: David Wilder @ 2007-08-05  3:26 UTC (permalink / raw)
  To: SystemTAP

It is my understanding if we want to access a kernel global variable in 
a tap script we must be in a context that is using the variable.
for example the following script will compile:

probe kernel.function("jiffies_to_timeval")
{
        printf("%x\n", $jiffies);
}

This works because,  jiffies_to_timeval()  uses jiffies in the 
function,  thus in the scope of the probes there exists a DWARF location 
information block for the variable jiffies.

If I change the probe point to do_fork() the probe will not build,  I 
get the error:
"probe do_fork@kernel/fork.c:1369 kernel section=.text pc=0x127b00
semantic error: failed to retrieve location attribute for local 
'jiffies' (dieoffset: 0x18309f): identifier '$jiffies' at global.stp:5:17"
This is because do_fork is not using jiffies.

Is this correct?

Dave....

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using kernel global variables
  2007-08-05  3:26 Using kernel global variables David Wilder
@ 2007-08-06 12:08 ` Mike Mason
  2007-08-06 19:49   ` David Wilder
  2007-08-06 19:58   ` Frank Ch. Eigler
  0 siblings, 2 replies; 5+ messages in thread
From: Mike Mason @ 2007-08-06 12:08 UTC (permalink / raw)
  To: David Wilder; +Cc: SystemTAP

David Wilder wrote:
> It is my understanding if we want to access a kernel global variable in 
> a tap script we must be in a context that is using the variable.

I believe the variable must be within the *scope* of the probed function.  The function doesn't necessarily have to use the variable for it to be within scope.  A global defined in the same file as the function is automatically within scope.

I don't think exported symbols are within a function's scope from SystemTap's perspective, though the function can see them.  Perhaps the dwarf info doesn't allow for that.

Mike

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using kernel global variables
  2007-08-06 12:08 ` Mike Mason
@ 2007-08-06 19:49   ` David Wilder
  2007-08-06 19:58   ` Frank Ch. Eigler
  1 sibling, 0 replies; 5+ messages in thread
From: David Wilder @ 2007-08-06 19:49 UTC (permalink / raw)
  To: Mike Mason; +Cc: SystemTAP

Mike Mason wrote:
> David Wilder wrote:
>> It is my understanding if we want to access a kernel global variable 
>> in a tap script we must be in a context that is using the variable.
>
> I believe the variable must be within the *scope* of the probed 
> function.  The function doesn't necessarily have to use the variable 
> for it to be within scope.  A global defined in the same file as the 
> function is automatically within scope.
>
> I don't think exported symbols are within a function's scope from 
> SystemTap's perspective, though the function can see them.  Perhaps 
> the dwarf info doesn't allow for that.
>
> Mike
>
Thanks for the clarification Mike.
Based on question I have received about global variables I think there 
is a need to access exported variables that are outside the scope of the 
probepoint.  For example accessing a global in a begin or exit probe.   
What do you think of such a feature?
I suspect we would need a way to flag the stap compiler that we are 
referencing a exported global something like using ^var.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using kernel global variables
  2007-08-06 12:08 ` Mike Mason
  2007-08-06 19:49   ` David Wilder
@ 2007-08-06 19:58   ` Frank Ch. Eigler
  2007-08-09  7:03     ` David Wilder
  1 sibling, 1 reply; 5+ messages in thread
From: Frank Ch. Eigler @ 2007-08-06 19:58 UTC (permalink / raw)
  To: Mike Mason; +Cc: David Wilder, SystemTAP

Mike Mason <mmlnx@us.ibm.com> writes:

> I believe the variable must be within the *scope* of the probed
> function.  The function doesn't necessarily have to use the variable
> for it to be within scope.  A global defined in the same file as the
> function is automatically within scope.

Or even *declared* in the same compilation unit - that should work too.

> I don't think exported symbols are within a function's scope from
> SystemTap's perspective [...]

We could change things to search for globals in other compilation
units too - exported ones first, static ones next (with the obvious
risk of name collisions).

- FChE

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using kernel global variables
  2007-08-06 19:58   ` Frank Ch. Eigler
@ 2007-08-09  7:03     ` David Wilder
  0 siblings, 0 replies; 5+ messages in thread
From: David Wilder @ 2007-08-09  7:03 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Mike Mason, SystemTAP

Frank Ch. Eigler wrote:
> Mike Mason <mmlnx@us.ibm.com> writes:
>
>   
>> I believe the variable must be within the *scope* of the probed
>> function.  The function doesn't necessarily have to use the variable
>> for it to be within scope.  A global defined in the same file as the
>> function is automatically within scope.
>>     
>
> Or even *declared* in the same compilation unit - that should work too.
>
>   
>> I don't think exported symbols are within a function's scope from
>> SystemTap's perspective [...]
>>     
>
> We could change things to search for globals in other compilation
> units too - exported ones first, static ones next (with the obvious
> risk of name collisions).
>
> - FChE
>   
If we could specify that the variable was global it would eliminate the 
chance of name collision.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-08 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-05  3:26 Using kernel global variables David Wilder
2007-08-06 12:08 ` Mike Mason
2007-08-06 19:49   ` David Wilder
2007-08-06 19:58   ` Frank Ch. Eigler
2007-08-09  7:03     ` David Wilder

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).