python tapset

Stan Cox scox@redhat.com
Tue Nov 22 20:26:00 GMT 2011


> I think rather, since your additions are defining interesting things to
> *do*, that they should be presented as functions.  The @1/@2
> parameterization can be function args, as can the frame pointer.  Then
> if needed, add the PyEval_GetFrame() argument to the existing sdt probes
> or some new eventful probe.
>
> Then with refactored, more-general utility functions, we can write
> specific example scripts that do as your specific probes are doing,
> searching and printing vars, backtracing specific function calls, etc.

Two new probes, "function_entry" and "function_exit", which are 
triggered when a function is called and when it returns, are now used to 
inspect python's internal state.   A function iterate_over_functions has 
been added to return successive frames on the stack.  This can be used 
to drive functions that do interesting things for a frame.  Two such 
functions, backtrace and get_variable are provided.  A sample script to 
do backtracing and get variable values is shown.

stap -I $(pwd)/tapset -g -c '/usr/local/bin/python  ./celsius.py 30' 
celsius-bt.stp
30 Celsius  is 86 Farenheit
#3 <module>  at ./celsius.py:3
#0 <module>  at ./celsius.py:3
#1 main  at ./celsius.py:19
#0 main  at ./celsius.py:19
#1 <module>  at ./celsius.py:3
#2 celsius_to_farenheit (celsius:int ) at ./celsius.py:7
#0 celsius_to_farenheit (celsius:int ) at ./celsius.py:7
#1 main  at ./celsius.py:19
#2 <module>  at ./celsius.py:3

stap -I $(pwd)/tapset -g -c '/usr/local/bin/python ./celsius.py 30' 
celsius-var.stp '*'
30 Celsius  is 86 Farenheit
global str __builtins__ in <module> at ./celsius.py
global str __name__ in <module> at ./celsius.py = "__main__"
global str __file__ in <module> at ./celsius.py = "./celsius.py"
arg1 int celsius in celsius_to_farenheit at ./celsius.py = 30
tuple atuple in celsius_to_farenheit at ./celsius.py =  "a", "b", "c",
list alist in celsius_to_farenheit at ./celsius.py = [ 1, 2, 3,]
set aset in celsius_to_farenheit at ./celsius.py = { 1, 2, 3,}
dict adict in celsius_to_farenheit at ./celsius.py = { 1:"a" 2:"b" 3:"c" }
int nine in celsius_to_farenheit at ./celsius.py = 9
int five in celsius_to_farenheit at ./celsius.py = 5
int thirty_two in celsius_to_farenheit at ./celsius.py = 32
int i in celsius_to_farenheit at ./celsius.py = 1

stap -I $(pwd)/tapset -g -c '/usr/local/bin/python ./celsius.py 30' 
celsius-var.stp 'ni*'
30 Celsius  is 86 Farenheit
int nine in celsius_to_farenheit at ./celsius.py = 9
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: celsius-bt.stp
URL: <http://sourceware.org/pipermail/systemtap/attachments/20111122/75fed1bf/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: celsius-var.stp
URL: <http://sourceware.org/pipermail/systemtap/attachments/20111122/75fed1bf/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ceval.patch
URL: <http://sourceware.org/pipermail/systemtap/attachments/20111122/75fed1bf/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: python.stp
URL: <http://sourceware.org/pipermail/systemtap/attachments/20111122/75fed1bf/attachment-0003.ksh>


More information about the Systemtap mailing list