[pypy-svn] r10169 - in pypy/dist/pypy: interpreter module/sys2

ac at codespeak.net ac at codespeak.net
Wed Mar 30 14:08:13 CEST 2005


Author: ac
Date: Wed Mar 30 14:08:13 2005
New Revision: 10169

Modified:
   pypy/dist/pypy/interpreter/executioncontext.py
   pypy/dist/pypy/module/sys2/__init__.py
   pypy/dist/pypy/module/sys2/app.py
   pypy/dist/pypy/module/sys2/vm.py
Log:
Add ssy.call_tracing() and sys.callstats()

Modified: pypy/dist/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/dist/pypy/interpreter/executioncontext.py	(original)
+++ pypy/dist/pypy/interpreter/executioncontext.py	Wed Mar 30 14:08:13 2005
@@ -146,6 +146,14 @@
         else:
             self.w_profilefunc = w_func
 
+    def call_tracing(self, w_func, w_args):
+        is_tracing = self.is_tracing
+        self.is_tracing = 0
+        try:
+            return self.space.call(w_func, w_args)
+        finally:
+            self.is_tracing = is_tracing
+
     def _trace(self, frame, event, w_arg):
         if self.is_tracing or frame.code.hidden_applevel:
             return

Modified: pypy/dist/pypy/module/sys2/__init__.py
==============================================================================
--- pypy/dist/pypy/module/sys2/__init__.py	(original)
+++ pypy/dist/pypy/module/sys2/__init__.py	Wed Mar 30 14:08:13 2005
@@ -45,6 +45,7 @@
         'exc_clear'             : 'vm.exc_clear', 
         'settrace'              : 'vm.settrace',
         'setprofile'            : 'vm.setprofile',
+        'call_tracing'          : 'vm.call_tracing',
         
         'executable'            : 'space.wrap("py.py")', 
         'copyright'             : 'space.wrap("MIT-License")', 
@@ -65,6 +66,7 @@
         '__excepthook__'        : 'app.__excepthook__', 
         'exit'                  : 'app.exit', 
         'getfilesystemencoding' : 'app.getfilesystemencoding', 
+        'callstats'             : 'app.callstats',
     }
 
     def setbuiltinmodule(self, w_module, name): 

Modified: pypy/dist/pypy/module/sys2/app.py
==============================================================================
--- pypy/dist/pypy/module/sys2/app.py	(original)
+++ pypy/dist/pypy/module/sys2/app.py	Wed Mar 30 14:08:13 2005
@@ -31,3 +31,26 @@
     else:
         encoding = None
     return encoding
+
+def callstats():
+    """callstats() -> tuple of integers
+
+Return a tuple of function call statistics, if CALL_PROFILE was defined
+when Python was built.  Otherwise, return None.
+
+When enabled, this function returns detailed, implementation-specific
+details about the number of function calls executed. The return value is
+a 11-tuple where the entries in the tuple are counts of:
+0. all function calls
+1. calls to PyFunction_Type objects
+2. PyFunction calls that do not create an argument tuple
+3. PyFunction calls that do not create an argument tuple
+   and bypass PyEval_EvalCodeEx()
+4. PyMethod calls
+5. PyMethod calls on bound methods
+6. PyType calls
+7. PyCFunction calls
+8. generator calls
+9. All other calls
+10. Number of stack pops performed by call_function()"""
+    return None

Modified: pypy/dist/pypy/module/sys2/vm.py
==============================================================================
--- pypy/dist/pypy/module/sys2/vm.py	(original)
+++ pypy/dist/pypy/module/sys2/vm.py	Wed Mar 30 14:08:13 2005
@@ -97,15 +97,20 @@
     """settrace(function)
 
 Set the global debug tracing function.  It will be called on each
-function call.  See the debugger chapter in the library manual.
-"""
+function call.  See the debugger chapter in the library manual."""
     space.getexecutioncontext().settrace(w_func)
     
 def setprofile(space, w_func):
     """setprofile(function)
 
 Set the profiling function.  It will be called on each function call
-and return.  See the profiler chapter in the library manual.
-"""
+and return.  See the profiler chapter in the library manual."""
     space.getexecutioncontext().setprofile(w_func)
 
+def call_tracing(space, w_func, w_args):
+    """call_tracing(func, args) -> object
+
+Call func(*args), while tracing is enabled.  The tracing state is
+saved, and restored afterwards.  This is intended to be called from
+a debugger from a checkpoint, to recursively debug some other code."""
+    return space.getexecutioncontext().call_tracing(w_func, w_args)



More information about the Pypy-commit mailing list