An interpreted, interactive, object-oriented programming language
CentOS Sources
2017-08-01 71084d584ff953f5463757ec6536406320560b4d
commit | author | age
6e8c2f 1 diff -up Python-2.7rc1/configure.ac.systemtap Python-2.7rc1/configure.ac
CB 2 --- Python-2.7rc1/configure.ac.systemtap    2010-06-06 10:53:15.514975012 -0400
3 +++ Python-2.7rc1/configure.ac    2010-06-06 10:53:15.520974361 -0400
4 @@ -2616,6 +2616,38 @@ if test "$with_valgrind" != no; then
5      )
6  fi
7  
8 +# Check for dtrace support
9 +AC_MSG_CHECKING(for --with-dtrace)
10 +AC_ARG_WITH(dtrace,
11 +            AC_HELP_STRING(--with(out)-dtrace, disable/enable dtrace support))
12 +
13 +if test ! -z "$with_dtrace"
14 +then
15 +    if dtrace -G -o /dev/null -s $srcdir/Include/pydtrace.d 2>/dev/null
16 +    then
17 +    AC_DEFINE(WITH_DTRACE, 1, 
18 +     [Define if you want to compile in Dtrace support])
19 +    with_dtrace="Sun"
20 +    DTRACEOBJS="Python/dtrace.o"
21 +    DTRADEHDRS=""
22 +    elif dtrace -h -o /dev/null -s $srcdir/Include/pydtrace.d
23 +    then
24 +    AC_DEFINE(WITH_DTRACE, 1, 
25 +     [Define if you want to compile in Dtrace support])
26 +    with_dtrace="Apple"
27 +    DTRACEOBJS=""
28 +    DTRADEHDRS="pydtrace.h"
29 +    else
30 +    with_dtrace="no"
31 +    fi
32 +else
33 +    with_dtrace="no"
34 +fi
35 +
36 +AC_MSG_RESULT($with_dtrace)
37 +AC_SUBST(DTRACEOBJS)
38 +AC_SUBST(DTRACEHDRS)
39 +
40  # Check for --with-wctype-functions
41  AC_MSG_CHECKING(for --with-wctype-functions)
42  AC_ARG_WITH(wctype-functions, 
43 diff -up Python-2.7rc1/Include/pydtrace.d.systemtap Python-2.7rc1/Include/pydtrace.d
44 --- Python-2.7rc1/Include/pydtrace.d.systemtap    2010-06-06 10:53:15.520974361 -0400
45 +++ Python-2.7rc1/Include/pydtrace.d    2010-06-06 10:53:15.520974361 -0400
46 @@ -0,0 +1,10 @@
47 +provider python {
48 +    probe function__entry(const char *, const char *, int);
49 +    probe function__return(const char *, const char *, int);
50 +};
51 +
52 +#pragma D attributes Evolving/Evolving/Common provider python provider
53 +#pragma D attributes Private/Private/Common provider python module
54 +#pragma D attributes Private/Private/Common provider python function
55 +#pragma D attributes Evolving/Evolving/Common provider python name
56 +#pragma D attributes Evolving/Evolving/Common provider python args
57 diff -up Python-2.7rc1/Makefile.pre.in.systemtap Python-2.7rc1/Makefile.pre.in
58 --- Python-2.7rc1/Makefile.pre.in.systemtap    2010-06-06 10:53:15.488978775 -0400
59 +++ Python-2.7rc1/Makefile.pre.in    2010-06-06 11:05:30.411100568 -0400
60 @@ -298,6 +298,7 @@ PYTHON_OBJS=    \
61          Python/formatter_unicode.o \
62          Python/formatter_string.o \
63          Python/$(DYNLOADFILE) \
64 +        @DTRACEOBJS@ \
65          $(LIBOBJS) \
66          $(MACHDEP_OBJS) \
67          $(THREADOBJ)
68 @@ -599,6 +600,18 @@ Python/formatter_unicode.o: $(srcdir)/Py
69  Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
70                  $(STRINGLIB_HEADERS)
71  
72 +# Only needed with --with-dtrace
73 +buildinclude:
74 +    mkdir -p Include
75 +
76 +Include/pydtrace.h: buildinclude $(srcdir)/Include/pydtrace.d
77 +    dtrace -o $@ $(DFLAGS) -C -h -s $(srcdir)/Include/pydtrace.d
78 +
79 +Python/ceval.o: Include/pydtrace.h
80 +
81 +Python/dtrace.o: buildinclude $(srcdir)/Include/pydtrace.d Python/ceval.o
82 +    dtrace -o $@ $(DFLAGS) -C -G -s $(srcdir)/Include/pydtrace.d Python/ceval.o
83 +
84  ############################################################################
85  # Header files
86  
87 @@ -1251,7 +1264,7 @@ Python/thread.o: @THREADHEADERS@
88  .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
89  .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
90  .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
91 -.PHONY: smelly funny patchcheck touch altmaninstall
92 +.PHONY: smelly funny patchcheck touch altmaninstall buildinclude
93  .PHONY: gdbhooks
94  
95  # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
96 diff -up Python-2.7rc1/pyconfig.h.in.systemtap Python-2.7rc1/pyconfig.h.in
97 --- Python-2.7rc1/pyconfig.h.in.systemtap    2010-05-08 07:04:18.000000000 -0400
98 +++ Python-2.7rc1/pyconfig.h.in    2010-06-06 10:53:15.521974070 -0400
99 @@ -1074,6 +1074,9 @@
100  /* Define if you want documentation strings in extension modules */
101  #undef WITH_DOC_STRINGS
102  
103 +/* Define if you want to compile in Dtrace support */
104 +#undef WITH_DTRACE
105 +
106  /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic
107     linker (dyld) instead of the old-style (NextStep) dynamic linker (rld).
108     Dyld is necessary to support frameworks. */
109 diff -up Python-2.7rc1/Python/ceval.c.systemtap Python-2.7rc1/Python/ceval.c
110 --- Python-2.7rc1/Python/ceval.c.systemtap    2010-05-09 10:46:46.000000000 -0400
111 +++ Python-2.7rc1/Python/ceval.c    2010-06-06 11:08:40.683100500 -0400
112 @@ -19,6 +19,10 @@
113  
114  #include <ctype.h>
115  
116 +#ifdef WITH_DTRACE
117 +#include "pydtrace.h"
118 +#endif
119 +
120  #ifndef WITH_TSC
121  
122  #define READ_TIMESTAMP(var)
123 @@ -671,6 +675,55 @@ PyEval_EvalCode(PyCodeObject *co, PyObje
124                        NULL);
125  }
126  
127 +#ifdef WITH_DTRACE
128 +static void
129 +dtrace_entry(PyFrameObject *f)
130 +{
131 +    const char *filename;
132 +    const char *fname;
133 +    int lineno;
134 +
135 +    filename = PyString_AsString(f->f_code->co_filename);
136 +    fname = PyString_AsString(f->f_code->co_name);
137 +    lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
138 +
139 +    PYTHON_FUNCTION_ENTRY((char *)filename, (char *)fname, lineno);
140 +
141 +    /*
142 +     * Currently a USDT tail-call will not receive the correct arguments.
143 +     * Disable the tail call here.
144 +     */
145 +#if defined(__sparc)
146 +    asm("nop");
147 +#endif
148 +}
149 +
150 +static void
151 +dtrace_return(PyFrameObject *f)
152 +{
153 +    const char *filename;
154 +    const char *fname;
155 +    int lineno;
156 +
157 +    filename = PyString_AsString(f->f_code->co_filename);
158 +    fname = PyString_AsString(f->f_code->co_name);
159 +    lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
160 +    PYTHON_FUNCTION_RETURN((char *)filename, (char *)fname, lineno);
161 +
162 +    /*
163 +     * Currently a USDT tail-call will not receive the correct arguments.
164 +     * Disable the tail call here.
165 +     */
166 +#if defined(__sparc)
167 +    asm("nop");
168 +#endif
169 +}
170 +#else
171 +#define    PYTHON_FUNCTION_ENTRY_ENABLED() 0
172 +#define    PYTHON_FUNCTION_RETURN_ENABLED() 0
173 +#define    dtrace_entry(f)
174 +#define    dtrace_return(f)
175 +#endif
176  
177  /* Interpreter main loop */
178  
179 @@ -909,6 +962,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int
180          }
181      }
182  
183 +    if (PYTHON_FUNCTION_ENTRY_ENABLED())
184 +        dtrace_entry(f);
185 +
186      co = f->f_code;
187      names = co->co_names;
188      consts = co->co_consts;
189 @@ -3000,6 +3056,9 @@ fast_yield:
190  
191      /* pop frame */
192  exit_eval_frame:
193 +    if (PYTHON_FUNCTION_RETURN_ENABLED())
194 +        dtrace_return(f);
195 +
196      Py_LeaveRecursiveCall();
197      tstate->frame = f->f_back;
198