1 --- Python-2.7.1/Makefile.pre.in.~1~ Thu Oct 14 06:37:30 2010 |
1 This patch adds Python dtrace support. Note it is necessary to modify |
2 +++ Python-2.7.1/Makefile.pre.in Mon Jul 18 14:53:46 2011 |
2 test_sys.py to add an integer to the frameobject structure size since this |
3 @@ -198,6 +198,7 @@ |
3 patch adds "int f_calllineno" to the structure, so this test does not fail. |
|
4 The patch comes from upstream: |
|
5 http://www.jcea.es/artic/python_dtrace-2_7_7_af8ecf2352e1.txt |
|
6 http://www.jcea.es/artic/python_dtrace.htm |
|
7 Follow http://bugs.python.org/issue13405 for plans to get it |
|
8 integrated into the main tree. |
|
9 |
|
10 --- Python-2.7.6/Makefile.pre.in.~1~ 2013-11-09 23:36:41.000000000 -0800 |
|
11 +++ Python-2.7.6/Makefile.pre.in 2014-05-14 12:54:43.824219677 -0700 |
|
12 @@ -218,6 +218,7 @@ |
4 # Used of signalmodule.o is not available |
13 # Used of signalmodule.o is not available |
5 SIGNAL_OBJS= @SIGNAL_OBJS@ |
14 SIGNAL_OBJS= @SIGNAL_OBJS@ |
6 |
15 |
7 +DTRACE_OBJS=Python/dtrace.o Python/phelper.o |
16 +DTRACE_OBJS=Python/dtrace.o Python/phelper.o |
8 |
17 |
9 ########################################################################## |
18 ########################################################################## |
10 # Grammar |
19 # Grammar |
11 @@ -298,6 +299,7 @@ |
20 @@ -341,6 +342,7 @@ |
12 Python/formatter_unicode.o \ |
21 Python/formatter_unicode.o \ |
13 Python/formatter_string.o \ |
22 Python/formatter_string.o \ |
14 Python/$(DYNLOADFILE) \ |
23 Python/$(DYNLOADFILE) \ |
15 + $(DTRACE_OBJS) \ |
24 + $(DTRACE_OBJS) \ |
16 $(LIBOBJS) \ |
25 $(LIBOBJS) \ |
17 $(MACHDEP_OBJS) \ |
26 $(MACHDEP_OBJS) \ |
18 $(THREADOBJ) |
27 $(THREADOBJ) |
19 @@ -599,6 +601,18 @@ |
28 @@ -664,6 +666,18 @@ |
20 Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \ |
29 Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \ |
21 $(STRINGLIB_HEADERS) |
30 $(STRINGLIB_HEADERS) |
22 |
31 |
23 +Python/phelper.o: $(srcdir)/Python/phelper.d |
32 +Python/phelper.o: $(srcdir)/Python/phelper.d |
24 + dtrace -o $@ -DPHELPER $(DFLAGS) $(CPPFLAGS) -C -G -s $(srcdir)/Python/phelper.d |
33 + dtrace -o $@ -DPHELPER $(DFLAGS) $(CPPFLAGS) -C -G -s $(srcdir)/Python/phelper.d |
33 + dtrace -o $@ $(DFLAGS) -C -G -s $(srcdir)/Python/python.d Python/ceval.o |
42 + dtrace -o $@ $(DFLAGS) -C -G -s $(srcdir)/Python/python.d Python/ceval.o |
34 + |
43 + |
35 ############################################################################ |
44 ############################################################################ |
36 # Header files |
45 # Header files |
37 |
46 |
38 --- Python-2.7.1/Include/frameobject.h.~1~ Fri May 8 17:23:21 2009 |
47 --- Python-2.7.6/Include/frameobject.h.~1~ 2013-11-09 23:36:39.000000000 -0800 |
39 +++ Python-2.7.1/Include/frameobject.h Mon Jul 18 14:53:46 2011 |
48 +++ Python-2.7.6/Include/frameobject.h 2014-05-14 13:03:19.938777249 -0700 |
40 @@ -44,6 +44,7 @@ |
49 @@ -44,6 +44,7 @@ |
41 PyCode_Addr2Line to calculate the line from the current |
50 PyCode_Addr2Line to calculate the line from the current |
42 bytecode index. */ |
51 bytecode index. */ |
43 int f_lineno; /* Current line number */ |
52 int f_lineno; /* Current line number */ |
44 + int f_calllineno; /* line number of call site */ |
53 + int f_calllineno; /* line number of call site */ |
45 int f_iblock; /* index in f_blockstack */ |
54 int f_iblock; /* index in f_blockstack */ |
46 PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ |
55 PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ |
47 PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ |
56 PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ |
48 |
57 --- Python-2.7.6/Objects/frameobject.c.~1~ 2013-11-09 23:36:41.000000000 -0800 |
49 --- Python-2.7.1/Objects/frameobject.c.~1~ Sun May 9 09:46:46 2010 |
58 +++ Python-2.7.6/Objects/frameobject.c 2014-05-14 12:56:06.970076859 -0700 |
50 +++ Python-2.7.1/Objects/frameobject.c Mon Jul 18 15:03:52 2011 |
59 @@ -738,6 +738,7 @@ |
51 @@ -736,6 +736,7 @@ |
|
52 f->f_tstate = tstate; |
60 f->f_tstate = tstate; |
53 |
61 |
54 f->f_lasti = -1; |
62 f->f_lasti = -1; |
55 + f->f_calllineno = code->co_firstlineno; |
63 + f->f_calllineno = code->co_firstlineno; |
56 f->f_lineno = code->co_firstlineno; |
64 f->f_lineno = code->co_firstlineno; |
57 f->f_iblock = 0; |
65 f->f_iblock = 0; |
58 |
66 |
59 --- Python-2.7.1/Python/ceval.c.~1~ Fri Sep 24 22:27:12 2010 |
67 --- Python-2.7.8/Python/ceval.c.~1~ 2014-06-29 19:05:46.000000000 -0700 |
60 +++ Python-2.7.1/Python/ceval.c Mon Jul 18 15:15:35 2011 |
68 +++ Python-2.7.8/Python/ceval.c 2014-07-17 20:39:49.843868592 -0700 |
61 @@ -19,6 +19,11 @@ |
69 @@ -19,6 +19,11 @@ |
62 |
70 |
63 #include <ctype.h> |
71 #include <ctype.h> |
64 |
72 |
65 +#define HAVE_DTRACE |
73 +#define HAVE_DTRACE |
83 + int lineno; |
91 + int lineno; |
84 + |
92 + |
85 + filename = PyString_AsString(f->f_code->co_filename); |
93 + filename = PyString_AsString(f->f_code->co_filename); |
86 + fname = PyString_AsString(f->f_code->co_name); |
94 + fname = PyString_AsString(f->f_code->co_name); |
87 + lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); |
95 + lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); |
88 |
96 + |
89 + PYTHON_FUNCTION_ENTRY((char *)filename, (char *)fname, lineno); |
97 + PYTHON_FUNCTION_ENTRY((char *)filename, (char *)fname, lineno); |
90 + |
98 + |
91 + /* |
99 + /* |
92 + * Currently a USDT tail-call will not receive the correct arguments. |
100 + * Currently a USDT tail-call will not receive the correct arguments. |
93 + * Disable the tail call here. |
101 + * Disable the tail call here. |
121 +#define PYTHON_FUNCTION_ENTRY_ENABLED 0 |
129 +#define PYTHON_FUNCTION_ENTRY_ENABLED 0 |
122 +#define PYTHON_FUNCTION_RETURN_ENABLED 0 |
130 +#define PYTHON_FUNCTION_RETURN_ENABLED 0 |
123 +#define dtrace_entry() |
131 +#define dtrace_entry() |
124 +#define dtrace_return() |
132 +#define dtrace_return() |
125 +#endif |
133 +#endif |
126 + |
134 |
127 /* Interpreter main loop */ |
135 /* Interpreter main loop */ |
128 |
136 |
129 PyObject * |
137 @@ -689,9 +743,84 @@ |
130 @@ -682,9 +736,84 @@ |
|
131 return PyEval_EvalFrameEx(f, 0); |
138 return PyEval_EvalFrameEx(f, 0); |
132 } |
139 } |
133 |
140 |
134 +/* |
141 +/* |
135 + * These shenanigans look like utter madness, but what we're actually doing is |
142 + * These shenanigans look like utter madness, but what we're actually doing is |
159 +PyObject *PyEval_EvalFrameExReal(long, long, long, long, long, long, |
166 +PyObject *PyEval_EvalFrameExReal(long, long, long, long, long, long, |
160 + PyFrameObject *, int throwflag); |
167 + PyFrameObject *, int throwflag); |
161 + |
168 + |
162 + |
169 + |
163 + |
170 + |
164 PyObject * |
171 +PyObject * |
165 PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) |
172 +PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) |
166 { |
173 +{ |
167 + volatile PyObject *f2; |
174 + volatile PyObject *f2; |
168 + f2 = PyEval_EvalFrameExReal(0, 0, 0, 0, 0, 0, f, throwflag); |
175 + f2 = PyEval_EvalFrameExReal(0, 0, 0, 0, 0, 0, f, throwflag); |
169 + return (PyObject *)f2; |
176 + return (PyObject *)f2; |
170 +} |
177 +} |
171 + |
178 + |
193 +PyEval_EvalFrameExReal(PyFrameObject *f, int throwflag) |
200 +PyEval_EvalFrameExReal(PyFrameObject *f, int throwflag) |
194 +{ |
201 +{ |
195 + |
202 + |
196 +#else /* __amd64 || __sparc */ |
203 +#else /* __amd64 || __sparc */ |
197 + |
204 + |
198 +PyObject * |
205 PyObject * |
199 +PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) |
206 PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) |
200 +{ |
207 { |
201 + |
208 + |
202 +#endif /* __amd64 || __sparc */ |
209 +#endif /* __amd64 || __sparc */ |
203 + |
210 + |
204 +#else /* don't HAVE_DTRACE */ |
211 +#else /* don't HAVE_DTRACE */ |
205 + |
212 + |
222 +#endif |
229 +#endif |
223 + |
230 + |
224 co = f->f_code; |
231 co = f->f_code; |
225 names = co->co_names; |
232 names = co->co_names; |
226 consts = co->co_consts; |
233 consts = co->co_consts; |
227 @@ -2659,6 +2793,9 @@ |
234 @@ -2673,6 +2807,9 @@ |
228 PyObject **sp; |
235 PyObject **sp; |
229 PCALL(PCALL_ALL); |
236 PCALL(PCALL_ALL); |
230 sp = stack_pointer; |
237 sp = stack_pointer; |
231 +#ifdef HAVE_DTRACE |
238 +#ifdef HAVE_DTRACE |
232 + f->f_calllineno = PyCode_Addr2Line(f->f_code, f->f_lasti); |
239 + f->f_calllineno = PyCode_Addr2Line(f->f_code, f->f_lasti); |
233 +#endif |
240 +#endif |
234 #ifdef WITH_TSC |
241 #ifdef WITH_TSC |
235 x = call_function(&sp, oparg, &intr0, &intr1); |
242 x = call_function(&sp, oparg, &intr0, &intr1); |
236 #else |
243 #else |
237 @@ -2700,6 +2837,9 @@ |
244 @@ -2714,6 +2851,9 @@ |
238 } else |
245 } else |
239 Py_INCREF(func); |
246 Py_INCREF(func); |
240 sp = stack_pointer; |
247 sp = stack_pointer; |
241 +#ifdef HAVE_DTRACE |
248 +#ifdef HAVE_DTRACE |
242 + f->f_calllineno = PyCode_Addr2Line(f->f_code, f->f_lasti); |
249 + f->f_calllineno = PyCode_Addr2Line(f->f_code, f->f_lasti); |
243 +#endif |
250 +#endif |
244 READ_TIMESTAMP(intr0); |
251 READ_TIMESTAMP(intr0); |
245 x = ext_do_call(func, &sp, flags, na, nk); |
252 x = ext_do_call(func, &sp, flags, na, nk); |
246 READ_TIMESTAMP(intr1); |
253 READ_TIMESTAMP(intr1); |
247 @@ -3000,6 +3140,10 @@ |
254 @@ -3014,6 +3154,10 @@ |
248 |
255 |
249 /* pop frame */ |
256 /* pop frame */ |
250 exit_eval_frame: |
257 exit_eval_frame: |
251 +#ifdef HAVE_DTRACE |
258 +#ifdef HAVE_DTRACE |
252 + if (PYTHON_FUNCTION_RETURN_ENABLED()) |
259 + if (PYTHON_FUNCTION_RETURN_ENABLED()) |
253 + dtrace_return(f); |
260 + dtrace_return(f); |
254 +#endif |
261 +#endif |
255 Py_LeaveRecursiveCall(); |
262 Py_LeaveRecursiveCall(); |
256 tstate->frame = f->f_back; |
263 tstate->frame = f->f_back; |
257 |
264 |
258 diff --git Python-2.6.4/Python/phelper.d Python-2.6.4/Python/phelper.d |
|
259 new file mode 100644 |
|
260 --- /dev/null |
265 --- /dev/null |
261 +++ Python-2.6.4/Python/phelper.d |
266 +++ Python-2.6.4/Python/phelper.d |
262 @@ -0,0 +1,139 @@ |
267 @@ -0,0 +1,139 @@ |
263 + |
268 + |
264 +/* |
269 +/* |
412 +#pragma D attributes Evolving/Evolving/Common provider python provider |
417 +#pragma D attributes Evolving/Evolving/Common provider python provider |
413 +#pragma D attributes Private/Private/Common provider python module |
418 +#pragma D attributes Private/Private/Common provider python module |
414 +#pragma D attributes Private/Private/Common provider python function |
419 +#pragma D attributes Private/Private/Common provider python function |
415 +#pragma D attributes Evolving/Evolving/Common provider python name |
420 +#pragma D attributes Evolving/Evolving/Common provider python name |
416 +#pragma D attributes Evolving/Evolving/Common provider python args |
421 +#pragma D attributes Evolving/Evolving/Common provider python args |
|
422 --- Python-2.7.7/Lib/test/test_sys.py.~1~ 2014-05-31 11:58:39.000000000 -0700 |
|
423 +++ Python-2.7.7/Lib/test/test_sys.py 2014-06-02 10:44:39.318709539 -0700 |
|
424 @@ -594,7 +594,7 @@ |
|
425 nfrees = len(x.f_code.co_freevars) |
|
426 extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\ |
|
427 ncells + nfrees - 1 |
|
428 - check(x, vsize('12P3i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P')) |
|
429 + check(x, vsize('12P4i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P')) |
|
430 # function |
|
431 def func(): pass |
|
432 check(func, size('9P')) |