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: python tapset



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

Attachment: celsius-bt.stp
Description: Text document

Attachment: celsius-var.stp
Description: Text document

Attachment: ceval.patch
Description: Text document

Attachment: python.stp
Description: Text document


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