[issue13405] Add DTrace probes

Marc Abramowitz report at bugs.python.org
Wed Feb 22 23:45:53 CET 2012


Marc Abramowitz <msabramo at gmail.com> added the comment:

I noticed that jcea already had some commented out stuff for OS X in his configure.in.

I tried it out and stuff builds and works in a basic way, although it might not be fully functional.

```
~/src/python-hg/cpython-2011$ hg diff configure.in
diff -r b50130b35288 configure.in
--- a/configure.in	Wed Feb 22 02:15:47 2012 +0100
+++ b/configure.in	Wed Feb 22 14:19:42 2012 -0800
@@ -2670,8 +2670,7 @@
         DFLAGS="-32"
     fi
 
-    #if dtrace -G -o /dev/null Include/pydtrace.d 2>/dev/null
-    if true
+    if dtrace -G -o /dev/null Include/pydtrace.d 2>/dev/null
     then
         DTRACE_NM=SOLARIS
         AC_DEFINE(WITH_DTRACE, 1,
```

```
~/src/python-hg/cpython-2011$ ./configure --prefix=/Users/marca/custom --enable-shared --with-dtrace
...
~/src/python-hg/cpython-2011$ make
...
~/src/python-hg/cpython-2011$ DYLD_LIBRARY_PATH=. python2.7
Python 2.7.2+ (dtrace-issue13405_2.7:b50130b35288+, Feb 22 2012, 14:11:17) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getpid()
34764

# In another tab...
$ sudo dtrace -l | grep python34764
124748 python34764 libpython2.7.dylib            PyEval_EvalFrameExReal function-entry
124749 python34764 libpython2.7.dylib            PyEval_EvalFrameExReal function-return
124750 python34764 libpython2.7.dylib                           collect gc-done
124751 python34764 libpython2.7.dylib                           collect gc-start
124752 python34764 libpython2.7.dylib                   subtype_dealloc instance-delete-done
124753 python34764 libpython2.7.dylib                  instance_dealloc instance-delete-done
124754 python34764 libpython2.7.dylib                   subtype_dealloc instance-delete-start
124755 python34764 libpython2.7.dylib                  instance_dealloc instance-delete-start
124756 python34764 libpython2.7.dylib               PyType_GenericAlloc instance-new-done
124757 python34764 libpython2.7.dylib                    PyInstance_New instance-new-done
124758 python34764 libpython2.7.dylib               PyType_GenericAlloc instance-new-start
124759 python34764 libpython2.7.dylib                    PyInstance_New instance-new-start
124760 python34764 libpython2.7.dylib            PyEval_EvalFrameExReal line
```

So it builds and works at a basic level.

However, I did see some weirdness as well:

```
$ sudo dtrace -n 'python34764::: { printf("%s (%s:%d)", copyinstr(arg1), copyinstr(arg0), arg2) }' | grep test
dtrace: description 'python34764::: ' matched 13 probes
dtrace: error on enabled probe ID 4 (ID 124751: python34764:libpython2.7.dylib:collect:gc-start): invalid address (0x2) in action #2 at DIF offset 24
dtrace: error on enabled probe ID 3 (ID 124750: python34764:libpython2.7.dylib:collect:gc-done): invalid address (0xfffffffffffffffb) in action #1 at DIF offset 24
```

and

```
~/src/python-hg/cpython-2011$ sudo DYLD_LIBRARY_PATH=. dtrace -n 'python*::: { printf("%s (%s:%d)", copyinstr(arg1), copyinstr(arg0), arg2) }' -c 'python2.7 /Users/marca/python/test.py' > /dev/null
dtrace: description 'python*::: ' matched 29 probes
dtrace: pid 34907 has exited
dtrace: error on enabled probe ID 20 (ID 126731: python34907:libpython2.7.dylib:collect:gc-start): invalid address (0x2) in action #2 at DIF offset 24
dtrace: error on enabled probe ID 19 (ID 126730: python34907:libpython2.7.dylib:collect:gc-done): invalid address (0xfffffffffffffffb) in action #1 at DIF offset 24
```

On the other hand, some stuff appears to work sometimes:

```
~/src/python-hg/cpython-2011$ sudo DYLD_LIBRARY_PATH=. dtrace -n 'python*:::function-entry { printf("%s (%s:%d)", copyinstr(arg1), copyinstr(arg0), arg2) }' -c 'python2.7 /Users/marca/python/test.py'
dtrace: description 'python*:::function-entry ' matched 9 probes
Current working directory: /Users/marca/src/python-hg/cpython-2011
11
Current working directory: /Users/marca/src/python-hg/cpython-2011
11
Current working directory: /Users/marca/src/python-hg/cpython-2011
11
dtrace: pid 34953 has exited
CPU     ID                    FUNCTION:NAME
  2 125639 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/python/test.py:1)
  2 125639 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/python/marcsmath.py:1)
  2 125639 PyEval_EvalFrameExReal:function-entry test_func (/Users/marca/python/test.py:4)
  2 125639 PyEval_EvalFrameExReal:function-entry add (/Users/marca/python/marcsmath.py:1)
  2 125639 PyEval_EvalFrameExReal:function-entry test_func (/Users/marca/python/test.py:4)
  2 125639 PyEval_EvalFrameExReal:function-entry add (/Users/marca/python/marcsmath.py:1)
  2 125639 PyEval_EvalFrameExReal:function-entry test_func (/Users/marca/python/test.py:4)
  2 125639 PyEval_EvalFrameExReal:function-entry add (/Users/marca/python/marcsmath.py:1)
  2 125639 PyEval_EvalFrameExReal:function-entry _remove (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/_weakrefset.py:38)
  2 125639 PyEval_EvalFrameExReal:function-entry _remove (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/_weakrefset.py:38)
```

```
~/src/python-hg/cpython-2011$ sudo dtrace -n 'python*::: { printf("%s (%s:%d)", copyinstr(arg1), copyinstr(arg0), arg2) }' 2> /dev/null | grep 'function-entry.*pip'
### In another tab, do: "pip install --help" ###
  1 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/bin/pip:3)
  2 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/basecommand.py:1)
  2 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/commands/__init__.py:1)
  2 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/log.py:2)
  2 124748 PyEval_EvalFrameExReal:function-entry Logger (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/log.py:8)
  2 124748 PyEval_EvalFrameExReal:function-entry __init__ (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/log.py:25)
  2 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/baseparser.py:1)
  2 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/locations.py:1)
  2 124748 PyEval_EvalFrameExReal:function-entry running_under_virtualenv (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/locations.py:8)
  2 124748 PyEval_EvalFrameExReal:function-entry UpdatingDefaultsHelpFormatter (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/baseparser.py:12)
  2 124748 PyEval_EvalFrameExReal:function-entry ConfigOptionParser (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/baseparser.py:23)
  3 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/exceptions.py:1)
  3 124748 PyEval_EvalFrameExReal:function-entry InstallationError (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/exceptions.py:4)
  3 124748 PyEval_EvalFrameExReal:function-entry UninstallationError (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/exceptions.py:8)
  3 124748 PyEval_EvalFrameExReal:function-entry DistributionNotFound (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/exceptions.py:12)
  3 124748 PyEval_EvalFrameExReal:function-entry BadCommand (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/exceptions.py:16)
  3 124748 PyEval_EvalFrameExReal:function-entry <module> (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/util.py:1)
  3 124748 PyEval_EvalFrameExReal:function-entry _Inf (/Users/marca/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/util.py:119)
```

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13405>
_______________________________________


More information about the Python-bugs-list mailing list