This is the mail archive of the systemtap@sourceware.org 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: accessing kernel global variables?


Ananth N Mavinakayanahalli wrote:
On Sun, Sep 07, 2008 at 07:49:34PM -0700, Om Narasimhan wrote:

For example, kernel/pid.c:38 in my tree defines pid_max as,


int pid_max = PID_MAX_DEFAULT;

When I try printing this value using the below scriptlet I get errors.

$ sudo stap -g -u -vv -e 'probe begin { printf("pid_max = %d\n", $pid_max) ; exit() }'
<snip>
stap -ve 'probe kernel.function("find_get_pid") {printf("pid_max = %d\n", $pid_max); exit()}'

Pass 1: parsed user script and 43 library script(s) in 330usr/0sys/453real ms.
Pass 2: analyzed script: 1 probe(s), 2 function(s), 0 embed(s), 0 global(s) in 390usr/650sys/9779real ms.
Pass 3: translated to C into "/tmp/stapAS2qBy/stap_d737858677ec9922f479339c1fe4be44_851.c" in 170usr/270sys/482real ms.
Pass 4: compiled C into "stap_d737858677ec9922f479339c1fe4be44_851.ko" in 3180usr/430sys/5443real ms.
Pass 5: starting run.
pid_max = 32768

Any function in kernel/pid.c may also be used.
Thanks.
So, the systemtap script _cannot_ access kernel global variables independent of the context it runs in. From any function context within kernel/pid.c, this variable is within scope, so are any (static/global) variables defined in that file.


Is my understanding correct?
Thanks,
Om.


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