diff options
author | Fedora Python maintainers <python-devel@lists.fedoraproject.org> | 2020-07-15 13:18:18 (GMT) |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2020-09-29 13:59:00 (GMT) |
commit | 1a334c0c655353d22d23dbf2bc9221fbe8350472 (patch) | |
tree | 037f3b7a777830f1852b559f751c01ae1dc60525 /Python | |
parent | 996f8b4c275bb89513d326cac50f50a78ab4d58c (diff) | |
download | cpython-1a334c0c655353d22d23dbf2bc9221fbe8350472.zip cpython-1a334c0c655353d22d23dbf2bc9221fbe8350472.tar.gz cpython-1a334c0c655353d22d23dbf2bc9221fbe8350472.tar.bz2 |
00055-systemtap.patch
00055 #
Systemtap support: add statically-defined probe points
Patch based on upstream bug: http://bugs.python.org/issue4111
fixed up by mjw and wcohen for 2.6.2, then fixed up by dmalcolm for 2.6.4
then rewritten by mjw (attachment 390110 of rhbz 545179), then reformatted
for 2.7rc1 by dmalcolm:
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index e1140a8..b7427f9 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -19,6 +19,10 @@ #include <ctype.h> +#ifdef WITH_DTRACE +#include "pydtrace.h" +#endif + #ifndef WITH_TSC #define READ_TIMESTAMP(var) @@ -674,6 +678,55 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) NULL); } +#ifdef WITH_DTRACE +static void +dtrace_entry(PyFrameObject *f) +{ + const char *filename; + const char *fname; + int lineno; + + filename = PyString_AsString(f->f_code->co_filename); + fname = PyString_AsString(f->f_code->co_name); + lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); + + PYTHON_FUNCTION_ENTRY((char *)filename, (char *)fname, lineno); + + /* + * Currently a USDT tail-call will not receive the correct arguments. + * Disable the tail call here. + */ +#if defined(__sparc) + asm("nop"); +#endif +} + +static void +dtrace_return(PyFrameObject *f) +{ + const char *filename; + const char *fname; + int lineno; + + filename = PyString_AsString(f->f_code->co_filename); + fname = PyString_AsString(f->f_code->co_name); + lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); + PYTHON_FUNCTION_RETURN((char *)filename, (char *)fname, lineno); + + /* + * Currently a USDT tail-call will not receive the correct arguments. + * Disable the tail call here. + */ +#if defined(__sparc) + asm("nop"); +#endif +} +#else +#define PYTHON_FUNCTION_ENTRY_ENABLED() 0 +#define PYTHON_FUNCTION_RETURN_ENABLED() 0 +#define dtrace_entry(f) +#define dtrace_return(f) +#endif /* Interpreter main loop */ @@ -1021,6 +1074,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) } } + if (PYTHON_FUNCTION_ENTRY_ENABLED()) + dtrace_entry(f); + co = f->f_code; names = co->co_names; consts = co->co_consts; @@ -3357,6 +3413,9 @@ fast_yield: /* pop frame */ exit_eval_frame: + if (PYTHON_FUNCTION_RETURN_ENABLED()) + dtrace_return(f); + Py_LeaveRecursiveCall(); tstate->frame = f->f_back; |