churchyard / rpms / python2

Forked from rpms/python2 6 years ago
Clone
43e7c42
diff -up Python-2.7rc1/configure.ac.systemtap Python-2.7rc1/configure.ac
43e7c42
--- Python-2.7rc1/configure.ac.systemtap	2010-06-06 10:53:15.514975012 -0400
43e7c42
+++ Python-2.7rc1/configure.ac	2010-06-06 10:53:15.520974361 -0400
c6247fd
@@ -2616,6 +2616,38 @@ if test "$with_valgrind" != no; then
5ae15cd
     )
5ae15cd
 fi
5ae15cd
 
5ae15cd
+# Check for dtrace support
5ae15cd
+AC_MSG_CHECKING(for --with-dtrace)
5ae15cd
+AC_ARG_WITH(dtrace,
5ae15cd
+            AC_HELP_STRING(--with(out)-dtrace, disable/enable dtrace support))
5ae15cd
+
5ae15cd
+if test ! -z "$with_dtrace"
5ae15cd
+then
5ae15cd
+    if dtrace -G -o /dev/null -s $srcdir/Include/pydtrace.d 2>/dev/null
5ae15cd
+    then
5ae15cd
+	AC_DEFINE(WITH_DTRACE, 1, 
5ae15cd
+	 [Define if you want to compile in Dtrace support])
5ae15cd
+	with_dtrace="Sun"
bdbb341
+	DTRACEOBJS="Python/dtrace.o"
5ae15cd
+	DTRADEHDRS=""
5ae15cd
+    elif dtrace -h -o /dev/null -s $srcdir/Include/pydtrace.d
5ae15cd
+    then
5ae15cd
+	AC_DEFINE(WITH_DTRACE, 1, 
5ae15cd
+	 [Define if you want to compile in Dtrace support])
5ae15cd
+	with_dtrace="Apple"
5ae15cd
+	DTRACEOBJS=""
bdbb341
+	DTRADEHDRS="pydtrace.h"
5ae15cd
+    else
5ae15cd
+	with_dtrace="no"
5ae15cd
+    fi
5ae15cd
+else
5ae15cd
+    with_dtrace="no"
5ae15cd
+fi
5ae15cd
+
5ae15cd
+AC_MSG_RESULT($with_dtrace)
5ae15cd
+AC_SUBST(DTRACEOBJS)
5ae15cd
+AC_SUBST(DTRACEHDRS)
5ae15cd
+
5ae15cd
 # Check for --with-wctype-functions
5ae15cd
 AC_MSG_CHECKING(for --with-wctype-functions)
5ae15cd
 AC_ARG_WITH(wctype-functions, 
c6247fd
diff -up Python-2.7rc1/Include/pydtrace.d.systemtap Python-2.7rc1/Include/pydtrace.d
c6247fd
--- Python-2.7rc1/Include/pydtrace.d.systemtap	2010-06-06 10:53:15.520974361 -0400
c6247fd
+++ Python-2.7rc1/Include/pydtrace.d	2010-06-06 10:53:15.520974361 -0400
5ae15cd
@@ -0,0 +1,10 @@
5ae15cd
+provider python {
5ae15cd
+	probe function__entry(const char *, const char *, int);
5ae15cd
+	probe function__return(const char *, const char *, int);
5ae15cd
+};
5ae15cd
+
5ae15cd
+#pragma D attributes Evolving/Evolving/Common provider python provider
5ae15cd
+#pragma D attributes Private/Private/Common provider python module
5ae15cd
+#pragma D attributes Private/Private/Common provider python function
5ae15cd
+#pragma D attributes Evolving/Evolving/Common provider python name
5ae15cd
+#pragma D attributes Evolving/Evolving/Common provider python args
c6247fd
diff -up Python-2.7rc1/Makefile.pre.in.systemtap Python-2.7rc1/Makefile.pre.in
c6247fd
--- Python-2.7rc1/Makefile.pre.in.systemtap	2010-06-06 10:53:15.488978775 -0400
c6247fd
+++ Python-2.7rc1/Makefile.pre.in	2010-06-06 11:05:30.411100568 -0400
c6247fd
@@ -298,6 +298,7 @@ PYTHON_OBJS=	\
5ae15cd
 		Python/formatter_unicode.o \
5ae15cd
 		Python/formatter_string.o \
5ae15cd
 		Python/$(DYNLOADFILE) \
5ae15cd
+		@DTRACEOBJS@ \
5ae15cd
 		$(LIBOBJS) \
5ae15cd
 		$(MACHDEP_OBJS) \
5ae15cd
 		$(THREADOBJ)
c6247fd
@@ -599,6 +600,18 @@ Python/formatter_unicode.o: $(srcdir)/Py
5ae15cd
 Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
5ae15cd
 				$(STRINGLIB_HEADERS)
5ae15cd
 
5ae15cd
+# Only needed with --with-dtrace
5ae15cd
+buildinclude:
5ae15cd
+	mkdir -p Include
5ae15cd
+
5ae15cd
+Include/pydtrace.h: buildinclude $(srcdir)/Include/pydtrace.d
5ae15cd
+	dtrace -o $@ $(DFLAGS) -C -h -s $(srcdir)/Include/pydtrace.d
5ae15cd
+
5ae15cd
+Python/ceval.o: Include/pydtrace.h
5ae15cd
+
5ae15cd
+Python/dtrace.o: buildinclude $(srcdir)/Include/pydtrace.d Python/ceval.o
5ae15cd
+	dtrace -o $@ $(DFLAGS) -C -G -s $(srcdir)/Include/pydtrace.d Python/ceval.o
5ae15cd
+
5ae15cd
 ############################################################################
5ae15cd
 # Header files
5ae15cd
 
c6247fd
@@ -1251,7 +1264,7 @@ Python/thread.o: @THREADHEADERS@
5ae15cd
 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
5ae15cd
 .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
Iryna Shcherbina 9db4c32
 .PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
Iryna Shcherbina 9db4c32
-.PHONY: smelly funny patchcheck altmaninstall commoninstall
Iryna Shcherbina 9db4c32
+.PHONY: smelly funny patchcheck altmaninstall commoninstall buildinclude
c6247fd
 .PHONY: gdbhooks
5ae15cd
 
5ae15cd
 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
c6247fd
diff -up Python-2.7rc1/pyconfig.h.in.systemtap Python-2.7rc1/pyconfig.h.in
c6247fd
--- Python-2.7rc1/pyconfig.h.in.systemtap	2010-05-08 07:04:18.000000000 -0400
c6247fd
+++ Python-2.7rc1/pyconfig.h.in	2010-06-06 10:53:15.521974070 -0400
c6247fd
@@ -1074,6 +1074,9 @@
5ae15cd
 /* Define if you want documentation strings in extension modules */
5ae15cd
 #undef WITH_DOC_STRINGS
5ae15cd
 
5ae15cd
+/* Define if you want to compile in Dtrace support */
5ae15cd
+#undef WITH_DTRACE
5ae15cd
+
5ae15cd
 /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic
5ae15cd
    linker (dyld) instead of the old-style (NextStep) dynamic linker (rld).
5ae15cd
    Dyld is necessary to support frameworks. */
c6247fd
diff -up Python-2.7rc1/Python/ceval.c.systemtap Python-2.7rc1/Python/ceval.c
c6247fd
--- Python-2.7rc1/Python/ceval.c.systemtap	2010-05-09 10:46:46.000000000 -0400
c6247fd
+++ Python-2.7rc1/Python/ceval.c	2010-06-06 11:08:40.683100500 -0400
5ae15cd
@@ -19,6 +19,10 @@
5ae15cd
 
5ae15cd
 #include <ctype.h>
5ae15cd
 
5ae15cd
+#ifdef WITH_DTRACE
5ae15cd
+#include "pydtrace.h"
5ae15cd
+#endif
5ae15cd
+
5ae15cd
 #ifndef WITH_TSC
5ae15cd
 
5ae15cd
 #define READ_TIMESTAMP(var)
c6247fd
@@ -671,6 +675,55 @@ PyEval_EvalCode(PyCodeObject *co, PyObje
c6247fd
                       NULL);
5ae15cd
 }
5ae15cd
 
5ae15cd
+#ifdef WITH_DTRACE
5ae15cd
+static void
5ae15cd
+dtrace_entry(PyFrameObject *f)
5ae15cd
+{
c6247fd
+    const char *filename;
c6247fd
+    const char *fname;
c6247fd
+    int lineno;
c6247fd
+
c6247fd
+    filename = PyString_AsString(f->f_code->co_filename);
c6247fd
+    fname = PyString_AsString(f->f_code->co_name);
c6247fd
+    lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
c6247fd
+
c6247fd
+    PYTHON_FUNCTION_ENTRY((char *)filename, (char *)fname, lineno);
c6247fd
+
c6247fd
+    /*
c6247fd
+     * Currently a USDT tail-call will not receive the correct arguments.
c6247fd
+     * Disable the tail call here.
c6247fd
+     */
5ae15cd
+#if defined(__sparc)
c6247fd
+    asm("nop");
5ae15cd
+#endif
5ae15cd
+}
5ae15cd
+
5ae15cd
+static void
5ae15cd
+dtrace_return(PyFrameObject *f)
5ae15cd
+{
c6247fd
+    const char *filename;
c6247fd
+    const char *fname;
c6247fd
+    int lineno;
c6247fd
+
c6247fd
+    filename = PyString_AsString(f->f_code->co_filename);
c6247fd
+    fname = PyString_AsString(f->f_code->co_name);
c6247fd
+    lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
c6247fd
+    PYTHON_FUNCTION_RETURN((char *)filename, (char *)fname, lineno);
c6247fd
+
c6247fd
+    /*
c6247fd
+     * Currently a USDT tail-call will not receive the correct arguments.
c6247fd
+     * Disable the tail call here.
c6247fd
+     */
5ae15cd
+#if defined(__sparc)
c6247fd
+    asm("nop");
5ae15cd
+#endif
5ae15cd
+}
5ae15cd
+#else
5ae15cd
+#define	PYTHON_FUNCTION_ENTRY_ENABLED() 0
5ae15cd
+#define	PYTHON_FUNCTION_RETURN_ENABLED() 0
5ae15cd
+#define	dtrace_entry(f)
5ae15cd
+#define	dtrace_return(f)
5ae15cd
+#endif
5ae15cd
 
5ae15cd
 /* Interpreter main loop */
5ae15cd
 
c6247fd
@@ -909,6 +962,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int
c6247fd
         }
c6247fd
     }
5ae15cd
 
c6247fd
+    if (PYTHON_FUNCTION_ENTRY_ENABLED())
c6247fd
+        dtrace_entry(f);
5ae15cd
+
c6247fd
     co = f->f_code;
c6247fd
     names = co->co_names;
c6247fd
     consts = co->co_consts;
c6247fd
@@ -3000,6 +3056,9 @@ fast_yield:
5ae15cd
 
c6247fd
     /* pop frame */
5ae15cd
 exit_eval_frame:
c6247fd
+    if (PYTHON_FUNCTION_RETURN_ENABLED())
c6247fd
+        dtrace_return(f);
c6247fd
+
c6247fd
     Py_LeaveRecursiveCall();
c6247fd
     tstate->frame = f->f_back;
5ae15cd