1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
import sys
from pypy.interpreter.mixedmodule import MixedModule
from rpython.rlib.rvmprof import VMProfPlatformUnsupported
from rpython.rlib import rvmprof
from rpython.translator.platform import CompilationError
class Module(MixedModule):
"""
VMProf for PyPy: a statistical profiler
"""
appleveldefs = {
}
if sys.platform.startswith('linux'):
appleveldefs['resolve_addr'] = 'app_vmprof.resolve_addr'
appleveldefs['resolve_many_addrs'] = 'app_vmprof.resolve_many_addrs'
interpleveldefs = {
'enable': 'interp_vmprof.enable',
'disable': 'interp_vmprof.disable',
'is_enabled': 'interp_vmprof.is_enabled',
'get_profile_path': 'interp_vmprof.get_profile_path',
'stop_sampling': 'interp_vmprof.stop_sampling',
'start_sampling': 'interp_vmprof.start_sampling',
'VMProfError': 'space.fromcache(interp_vmprof.Cache).w_VMProfError',
}
# Force the __extend__ hacks and method replacements to occur
# early. Without this, for example, 'PyCode._init_ready' was
# already found by the annotator to be the original empty
# method, and the annotator doesn't notice that interp_vmprof.py
# (loaded later) replaces this method.
try:
import pypy.module._vmprof.interp_vmprof
except VMProfPlatformUnsupported as e:
pass
except CompilationError as e:
import sys
if sys.platform == 'win32':
pass
else:
raise
|