def traceback(estimate_number_of_entries): """Build and return a vmprof-like traceback, as a pair (array_p, array_length). The caller must free array_p. Not for signal handlers: for these, call vmprof_get_traceback() from C code. """ _cintf = rvmprof._get_vmprof().cintf size = estimate_number_of_entries * 2 + 4 stack = cintf.get_rvmprof_stack() array_p = lltype.malloc(rffi.SIGNEDP.TO, size, flavor='raw') NULL = llmemory.NULL array_length = _cintf.vmprof_get_traceback(stack, NULL, array_p, size) return (array_p, array_length)
def get_profile_path(space): vmp = _get_vmprof() if not vmp.is_enabled: return None with rffi.scoped_alloc_buffer(4096) as buf: length = vmp.cintf.vmprof_get_profile_path(buf.raw, buf.size) if length == -1: return "" return buf.str(length) return None
def start_sampling(): return _get_vmprof().start_sampling()
def stop_sampling(): return _get_vmprof().stop_sampling()
def is_enabled(): vmp = _get_vmprof() return vmp.is_enabled
def enable(fileno, interval, memory=0, native=0, real_time=0): _get_vmprof().enable(fileno, interval, memory, native, real_time)
def disable(): _get_vmprof().disable()
def register_code_object_class(CodeClass, full_name_func): _get_vmprof().register_code_object_class(CodeClass, full_name_func)
def register_code(code, name): _get_vmprof().register_code(code, name)
def enable(fileno, interval): _get_vmprof().enable(fileno, interval)
def start_sampling(space): _get_vmprof().cintf.vmprof_start_sampling()
def stop_sampling(space): fd = _get_vmprof().cintf.vmprof_stop_sampling() return rffi.cast(lltype.Signed, fd)