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?


On Sun, Sep 07, 2008 at 07:49:34PM -0700, Om Narasimhan wrote:
> Can a system tap script access kernel global variables (which are 
> independent of the context it runs in?)
>
> 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() }'
> SystemTap translator/driver (version 0.6.2/0.127 built 2008-03-27)
> Copyright (C) 2005-2008 Red Hat, Inc. and others
> This is free software; see the source for copying conditions.
> Created temporary directory "/tmp/stappkNTb2"
> Searched '/usr/share/system tap/tapset/x86_64/*.stp', found 1
> Searched '/usr/share/system tap/tapset/*.stp', found 37
> Pass 1: parsed user script and 38 library script(s) in 120usr/10sys/163real 
> ms.
> semantic error: unresolved target-symbol expression: identifier '$pid_max' 
> at <input>:1:40
> Pass 2: analyzed script: 1 probe(s), 5 function(s), 0 embed(s), 0 global(s) 
> in 0usr/0sys/2real ms.
> Pass 2: analysis failed.  Try again with more '-v' (verbose) options.
> Running rm -rf /tmp/stappkNTb2
>
> Is it expected? Or am I doing something wrong?

Try

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.

Ananth


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