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


Hi Stan,

On 11/17/2011 01:53 PM, Stan Cox wrote:
> This is a first cut at a tapset that enables probing python applications.
>   python_backtrace - get backtraces for the running python application
>   python_get_variable [VARIABLE] - get value of a running python
>          application variable.  VARIABLE can be a variable wildcard,
>          aotherwise defaults to *

Thanks for sharing!

Since this is heavily tied to cpython internals, this will be a tapset
that better belongs in their tree, much like python already ships a
tapset (at least in fedora) for the function entry/return probes.  We
can certainly hammer on it here first, though.

> --- ../../python/src/Python/ceval.c.orig	2011-11-17 15:54:06.287304375 -0500
> +++ ../../python/src/Python/ceval.c	2011-11-17 15:57:42.875596649 -0500
> @@ -19,6 +19,8 @@
>  
>  #include <ctype.h>
>  
> +#include <sys/sdt.h>
> +
>  #ifndef WITH_TSC
>  
>  #define READ_TIMESTAMP(var)
> @@ -1094,6 +1096,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int
>          }
>  #endif
>  
> +	DTRACE_PROBE1 (python, backtrace, PyEval_GetFrame());
> +	DTRACE_PROBE1 (python, get_variable, PyEval_GetFrame());
>  
>          /* Main switch on opcode */
>          READ_TIMESTAMP(inst0);

I'm sure that these will need to be transformed into properly autoconfed
additions to go upstream, like the function probes are.

I don't think the abstraction is right though.  A probe point should
define an event that is occurring (a statement eval?), but these seem to
be describing what the handler will do.  That's a bit backwards.

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.

HTH,
Josh


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