Blame SOURCES/00055-systemtap.patch

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