target variables : doubts on usage.

Wenji Huang wenji.huang@oracle.com
Mon Aug 25 02:01:00 GMT 2008


Om Narasimhan wrote:
> Are the variables defined by probe aliases target variables? (accessible 
> by $var?). I am getting different results in my machine.

Yes, the variable in probe point is accessible through by $var.

> 
> $ uname -a
> Linux testserv.home 2.6.23.17-88.fc7 #1 SMP Thu May 15 00:02:29 EDT 2008 
> x86_64 x86_64 x86_64 GNU/Linux
> $ stap -V
> 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.
> 
> $ sudo stap -e 'probe vm.pagefault { printf("%#x->%d\n", $address, 
> $write_access)}'
> 0x2aaaaf2d1000->1
> 0x2aaaaf2d1000->1
> 0x2aaaaf2d1000->1
> 0x3683adcfd0->0
> 0x40414d->0
> ^C
> 
> The corresponding function in tapset is,
> 
> $ grep vm.pagefault -A 5  /usr/share/systemtap/tapset/memory.stp
> 
> probe vm.pagefault = kernel.function("__handle_mm_fault@mm/memory.c") ?,
>                      kernel.function("handle_mm_fault@mm/memory.c") ?
> {
>         write_access = $write_access
>         address =  $address
> }

Attention that there are two kinds of variables in this tapset.
local defined and parameters in kernel function, share same name. So you 
can refer to both of them.

> 
> Now I do the same operation using process.stp function `process_create`
> $ sudo stap -e 'probe process.create { printf("%d\n", $new_pid) }'
> semantic error: unable to find local 'new_pid' near pc 
> 0xffffffff81034327 (alternatives: clone_flags stack_start regs 
> stack_size parent_tidptr child_tidptr pid retval p): identifier 
> '$new_pid' at <input>:1:39
> Pass 2: analysis failed.  Try again with more '-v' (verbose) options.
> 
> Corresponding code from process.stp is,
> probe process.create = kernel.function("copy_process").return {
>     task = $return
>     new_pid = task_pid(task)
>     if (_IS_ERR(task)) next
> }
> 
> Despite new_pid is used(hence defined), I can't access it as a target 
> variable. But if I omit $, it works fine.

new_pid is the local variable in tapset, directed access it by name.

> Eg,
> $ sudo stap -e 'probe process.create { printf("%d\n", new_pid) }'
> 10953
> 1095388
> 
> (Though I don't understand how can it print same pid more than once)

There are two processes created in your execution.

> 
> So, my question is how to differentiate normal variables with target 
> variables?
> 
> I would like to add that in the first example, address is accessible
> without $variable too.
See above.


Regards,
Wenji



More information about the Systemtap mailing list