Author: Richard Plangger <planri...@gmail.com> Branch: vmprof-0.4.8 Changeset: r91540:a4f077ba651c Date: 2017-06-05 16:25 -0400 http://bitbucket.org/pypy/pypy/changeset/a4f077ba651c/
Log: implement stop/start_sampling and copy over new implementation from vmprof-python.git 6142531a47d6c294b1fd096aec7b9f3df6b8dfb5 diff --git a/pypy/module/_vmprof/__init__.py b/pypy/module/_vmprof/__init__.py --- a/pypy/module/_vmprof/__init__.py +++ b/pypy/module/_vmprof/__init__.py @@ -14,6 +14,9 @@ 'write_all_code_objects': 'interp_vmprof.write_all_code_objects', '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', } diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -96,3 +96,10 @@ # Indicates an error! Assume platform does not implement the function call raise oefmt(space.w_NotImplementedError, "platform not implemented") return space.newtext(path) + +def stop_sampling(space): + return space.newint(rvmprof.stop_sampling(space)) + +def start_sampling(space): + rvmprof.start_sampling(space) + return space.w_None diff --git a/rpython/rlib/rvmprof/__init__.py b/rpython/rlib/rvmprof/__init__.py --- a/rpython/rlib/rvmprof/__init__.py +++ b/rpython/rlib/rvmprof/__init__.py @@ -3,7 +3,7 @@ from rpython.rlib.rvmprof.rvmprof import vmprof_execute_code, MAX_FUNC_NAME from rpython.rlib.rvmprof.rvmprof import _was_registered from rpython.rlib.rvmprof.cintf import VMProfPlatformUnsupported -from rpython.rtyper.lltypesystem import rffi +from rpython.rtyper.lltypesystem import rffi, lltype # # See README.txt. @@ -56,3 +56,9 @@ return None +def stop_sampling(space): + fd = _get_vmprof().cintf.stop_sampling() + return rffi.cast(lltype.Signed, fd) + +def start_sampling(space): + _get_vmprof().cintf.start_sampling() diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py --- a/rpython/rlib/rvmprof/cintf.py +++ b/rpython/rlib/rvmprof/cintf.py @@ -110,6 +110,12 @@ vmprof_get_profile_path = rffi.llexternal("vmprof_get_profile_path", [rffi.CCHARP, lltype.Signed], lltype.Signed, compilation_info=eci, _nowrapper=True) + vmprof_stop_sampling = rffi.llexternal("vmprof_stop_sampling", [], + rffi.INT, compilation_info=eci, + _nowrapper=True) + vmprof_start_sampling = rffi.llexternal("vmprof_start_sampling", [], + lltype.Void, compilation_info=eci, + _nowrapper=True) return CInterface(locals()) diff --git a/rpython/rlib/rvmprof/src/rvmprof.c b/rpython/rlib/rvmprof/src/rvmprof.c --- a/rpython/rlib/rvmprof/src/rvmprof.c +++ b/rpython/rlib/rvmprof/src/rvmprof.c @@ -30,8 +30,18 @@ } #endif - long vmprof_get_profile_path(const char * buffer, long size) { return vmp_fd_to_path(vmp_profile_fileno(), buffer, size); } + +int vmprof_stop_sampling(void) +{ + vmprof_ignore_signals(1); + return vmp_profile_fileno(); +} + +void vmprof_start_sampling(void) +{ + vmprof_ignore_signals(0); +} diff --git a/rpython/rlib/rvmprof/src/rvmprof.h b/rpython/rlib/rvmprof/src/rvmprof.h --- a/rpython/rlib/rvmprof/src/rvmprof.h +++ b/rpython/rlib/rvmprof/src/rvmprof.h @@ -38,6 +38,8 @@ RPY_EXTERN void vmprof_stack_free(void*); RPY_EXTERN intptr_t vmprof_get_traceback(void *, void *, intptr_t*, intptr_t); RPY_EXTERN long vmprof_get_profile_path(const char *, long); +RPY_EXTERN int vmprof_stop_sampling(void); +RPY_EXTERN void vmprof_start_sampling(void); long vmprof_write_header_for_jit_addr(intptr_t *result, long n, intptr_t addr, int max_depth); diff --git a/rpython/rlib/rvmprof/src/shared/_vmprof.c b/rpython/rlib/rvmprof/src/shared/_vmprof.c --- a/rpython/rlib/rvmprof/src/shared/_vmprof.c +++ b/rpython/rlib/rvmprof/src/shared/_vmprof.c @@ -13,7 +13,6 @@ static volatile int is_enabled = 0; static destructor Original_code_dealloc = 0; static PyObject* (*_default_eval_loop)(PyFrameObject *, int) = 0; -void vmp_scan_profile(int fileno, int dump_native, void *all_code_uids); #if VMPROF_UNIX #include "trampoline.h" @@ -82,60 +81,39 @@ return vmprof_register_virtual_function(buf, CODE_ADDR_TO_UID(co), 500000); } -static int _look_for_code_object(PyObject *o, void *all_codes) +static int _look_for_code_object(PyObject *o, void * param) { - if (PyCode_Check(o) && !PySet_Contains((PyObject *)all_codes, o)) { - Py_ssize_t i; + PyObject * all_codes = (PyObject*)((void**)param)[0]; + PyObject * seen_codes = (PyObject*)((void**)param)[1]; + if (PyCode_Check(o) && !PySet_Contains(all_codes, o)) { PyCodeObject *co = (PyCodeObject *)o; - if (emit_code_object(co) < 0) - return -1; - if (PySet_Add((PyObject *)all_codes, o) < 0) - return -1; + PyObject * id = PyLong_FromVoidPtr((void*)CODE_ADDR_TO_UID(co)); + if (PySet_Contains(seen_codes, id)) { + // only emit if the code id has been seen! + if (emit_code_object(co) < 0) + return -1; + if (PySet_Add(all_codes, o) < 0) + return -1; + } /* as a special case, recursively look for and add code objects found in the co_consts. The problem is that code objects are not created as GC-aware in CPython, so we need to hack like this to hope to find most of them. */ - i = PyTuple_Size(co->co_consts); + int i = PyTuple_Size(co->co_consts); while (i > 0) { --i; if (_look_for_code_object(PyTuple_GET_ITEM(co->co_consts, i), - all_codes) < 0) + param) < 0) return -1; } } return 0; } -static int _look_for_code_object_seen(PyObject *o, void *all_codes) -{ - if (PyCode_Check(o) && PySet_GET_SIZE(all_codes)) { - Py_ssize_t i; - PyCodeObject *co = (PyCodeObject *)o; - PyObject *uid_co = PyLong_FromVoidPtr((void*)CODE_ADDR_TO_UID(co)); - int check = PySet_Discard(all_codes, uid_co); - - Py_CLEAR(uid_co); - - if (check < 0) - return -1; - - if (check && emit_code_object(co) < 0) - return -1; - - i = PyTuple_Size(co->co_consts); - while (i > 0) { - --i; - if (_look_for_code_object(PyTuple_GET_ITEM(co->co_consts, i), - all_codes) < 0) - return -1; - } - } - return 0; -} - -static void emit_all_code_objects(void) +static +void emit_all_code_objects(PyObject * seen_code_ids) { PyObject *gc_module = NULL, *lst = NULL, *all_codes = NULL; Py_ssize_t i, size; @@ -154,11 +132,15 @@ if (all_codes == NULL) goto error; + void * param[2]; + param[0] = all_codes; + param[1] = seen_code_ids; + size = PyList_GET_SIZE(lst); for (i = 0; i < size; i++) { PyObject *o = PyList_GET_ITEM(lst, i); if (o->ob_type->tp_traverse && - o->ob_type->tp_traverse(o, _look_for_code_object, (void *)all_codes) + o->ob_type->tp_traverse(o, _look_for_code_object, (void*)param) < 0) goto error; } @@ -169,91 +151,6 @@ Py_XDECREF(gc_module); } -static int add_code_addr(void *all_code_uids, void *addr) -{ - PyObject *co_uid = PyLong_FromVoidPtr(addr); - int check = PySet_Add((PyObject*) all_code_uids, co_uid); - Py_CLEAR(co_uid); - return check; -} - -static void emit_all_code_objects_seen(int fileno) -{ - PyObject *gc_module = NULL, *lst = NULL, *all_codes = NULL; - Py_ssize_t i, size; - - gc_module = PyImport_ImportModuleNoBlock("gc"); - if (gc_module == NULL) - goto error; - - lst = PyObject_CallMethod(gc_module, "get_objects", ""); - if (lst == NULL || !PyList_Check(lst)) - goto error; - - all_codes = PySet_New(NULL); - if (all_codes == NULL) - goto error; - - // fill up all_codes with every code object found in the profile - vmp_scan_profile(fileno, 0, all_codes); - - // intersect the list with the set and dump only the code objects - // found in the set! - size = PyList_GET_SIZE(lst); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GET_ITEM(lst, i); - if (o->ob_type->tp_traverse && - o->ob_type->tp_traverse(o, _look_for_code_object_seen, (void *) all_codes) - < 0) - goto error; - } - - error: - Py_XDECREF(all_codes); - Py_XDECREF(lst); - Py_XDECREF(gc_module); -} - -static int emit_all_code_objects_helper(int only_needed, int disable_vmprof) -{ - int fd = vmp_profile_fileno(); - - if (!is_enabled) { - PyErr_SetString(PyExc_ValueError, "vmprof is not enabled"); - return -1; - } - -#if VMPROF_UNIX - if ((read(fd, NULL, 0) != 0) && (only_needed != 0)) { - PyErr_SetString(PyExc_ValueError, - "file descriptor must be readable to save only needed code objects"); - return -1; - } -#else - if (only_needed) { - PyErr_SetString(PyExc_ValueError, - "saving only needed code objects is not supported for windows"); - return -1; - } -#endif - - if (disable_vmprof) { - is_enabled = 0; - vmprof_ignore_signals(1); - } - -#if VMPROF_UNIX - if (only_needed) - emit_all_code_objects_seen(fd); - else - emit_all_code_objects(); -#else - emit_all_code_objects(); -#endif - - return 0; -} - static void cpyprof_code_dealloc(PyObject *co) { if (is_enabled) { @@ -283,7 +180,7 @@ } if ((read(fd, NULL, 0) != 0) && (native != 0)) { - PyErr_SetString(PyExc_ValueError, "file descriptor must be readable for native profiling"); + PyErr_SetString(PyExc_ValueError, "file descriptor must be readable"); return NULL; } @@ -330,21 +227,15 @@ } static PyObject * -disable_vmprof(PyObject *module, PyObject *args) +disable_vmprof(PyObject *module, PyObject *noargs) { - int only_needed = 0; - - if (!PyArg_ParseTuple(args, "|i", &only_needed)) - return NULL; - - if (emit_all_code_objects_helper(only_needed, 1)) - return NULL; - if (vmprof_disable() < 0) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } + is_enabled = 0; + if (PyErr_Occurred()) return NULL; @@ -352,23 +243,18 @@ } static PyObject * -write_all_code_objects(PyObject *module, PyObject *args) +write_all_code_objects(PyObject *module, PyObject * seen_code_ids) { - int only_needed = 0; - - if (!PyArg_ParseTuple(args, "|i", &only_needed)) - return NULL; - - if (emit_all_code_objects_helper(only_needed, 0)) - return NULL; + // assumptions: signals must be disabled (see stop_sampling) + emit_all_code_objects(seen_code_ids); if (PyErr_Occurred()) return NULL; - Py_RETURN_NONE; } + static PyObject * sample_stack_now(PyObject *module, PyObject * args) { @@ -447,7 +333,6 @@ if (o_srcfile == NULL) goto error; // return PyTuple_Pack(3, o_name, o_lineno, o_srcfile); - error: Py_XDECREF(o_name); Py_XDECREF(o_lineno); @@ -457,6 +342,20 @@ } #endif +static PyObject * +stop_sampling(PyObject *module, PyObject *noargs) +{ + vmprof_ignore_signals(1); + return PyLong_NEW(vmp_profile_fileno()); +} + +static PyObject * +start_sampling(PyObject *module, PyObject *noargs) +{ + vmprof_ignore_signals(0); + Py_RETURN_NONE; +} + #ifdef VMPROF_UNIX static PyObject * vmp_get_profile_path(PyObject *module, PyObject *noargs) { PyObject * o; @@ -523,23 +422,30 @@ } #endif - static PyMethodDef VMProfMethods[] = { {"enable", enable_vmprof, METH_VARARGS, "Enable profiling."}, - {"disable", disable_vmprof, METH_VARARGS, "Disable profiling."}, - {"write_all_code_objects", write_all_code_objects, METH_VARARGS, - "Write eagerly all the IDs of code objects"}, - {"sample_stack_now", sample_stack_now, METH_VARARGS, "Sample the stack now"}, - {"is_enabled", vmp_is_enabled, METH_NOARGS, "Indicates if vmprof is currently sampling."}, + {"disable", disable_vmprof, METH_NOARGS, "Disable profiling."}, + {"write_all_code_objects", write_all_code_objects, METH_O, + "Write eagerly all the IDs of code objects"}, + {"sample_stack_now", sample_stack_now, METH_VARARGS, + "Sample the stack now"}, + {"is_enabled", vmp_is_enabled, METH_NOARGS, + "Indicates if vmprof is currently sampling."}, + {"stop_sampling", stop_sampling, METH_NOARGS, + "Blocks signals to occur and returns the file descriptor"}, + {"start_sampling", start_sampling, METH_NOARGS, + "Unblocks vmprof signals. After compeltion vmprof will sample again"}, #ifdef VMP_SUPPORTS_NATIVE_PROFILING - {"resolve_addr", resolve_addr, METH_VARARGS, "Return the name of the addr"}, + {"resolve_addr", resolve_addr, METH_VARARGS, + "Returns the name of the given address"}, #endif #ifdef VMPROF_UNIX - {"get_profile_path", vmp_get_profile_path, METH_NOARGS, "Profile path the profiler logs to."}, + {"get_profile_path", vmp_get_profile_path, METH_NOARGS, + "Profile path the profiler logs to."}, {"insert_real_time_thread", insert_real_time_thread, METH_NOARGS, - "Insert a thread into the real time profiling list."}, + "Insert a thread into the real time profiling list."}, {"remove_real_time_thread", remove_real_time_thread, METH_NOARGS, - "Remove a thread from the real time profiling list."}, + "Remove a thread from the real time profiling list."}, #endif {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/rpython/rlib/rvmprof/src/shared/compat.c b/rpython/rlib/rvmprof/src/shared/compat.c --- a/rpython/rlib/rvmprof/src/shared/compat.c +++ b/rpython/rlib/rvmprof/src/shared/compat.c @@ -87,7 +87,9 @@ } buf.tv_sec = tv.tv_sec; buf.tv_usec = tv.tv_usec; - strncpy(((char*)buffer)+__SIZE-8, tm.tm_zone, 8); + // IF we really support time zones: + // use a cross platform datetime library that outputs iso8601 strings + // strncpy(((char*)buffer)+__SIZE-8, tm.tm_zone, 8); buffer[0] = marker; (void)memcpy(buffer+1, &buf, sizeof(struct timezone_buf)); @@ -128,8 +130,9 @@ buf.tv_usec = (system_time.wMilliseconds * 1000); // time zone not implemented on windows + // IF we really support time zones: + // use a cross platform datetime library that outputs iso8601 strings memset(((char*)buffer)+__SIZE-8, 0, 8); - (void)memcpy(((char*)buffer)+__SIZE-8, "UTC", 3); buffer[0] = marker; (void)memcpy(buffer+1, &buf, sizeof(struct timezone_buf)); diff --git a/rpython/rlib/rvmprof/src/shared/symboltable.c b/rpython/rlib/rvmprof/src/shared/symboltable.c --- a/rpython/rlib/rvmprof/src/shared/symboltable.c +++ b/rpython/rlib/rvmprof/src/shared/symboltable.c @@ -11,7 +11,6 @@ #include <assert.h> #include <dlfcn.h> -#include <errno.h> #if defined(VMPROF_LINUX) #include <link.h> @@ -266,272 +265,3 @@ #endif return 0; } - -#define WORD_SIZE sizeof(long) -#define ADDR_SIZE sizeof(void*) -#define MAXLEN 1024 - -void _dump_native_symbol(int fileno, void * addr, char * sym, int linenumber, char * filename) { - char natsym[64]; - off_t pos_before; - struct str { - void * addr; - // NOTE windows, not supported yet would be a problem for 64 bit - // hint: alignment - long size; - char str[1024]; - } s; - fsync(fileno); - pos_before = lseek(fileno, 0, SEEK_CUR); - lseek(fileno, 0, SEEK_END); - - s.addr = addr; - /* must mach '<lang>:<name>:<line>:<file>' - * 'n' has been chosen as lang here, because the symbol - * can be generated from several languages (e.g. C, C++, ...) - */ - // MARKER_NATIVE_SYMBOLS is \x08 - write(fileno, "\x08", 1); - if (sym == NULL || sym[0] == '\x00') { - snprintf(natsym, 64, "<native symbol %p>", addr); - sym = natsym; - } - if (filename != NULL) { - s.size = snprintf(s.str, 1024, "n:%s:%d:%s", sym, linenumber, filename); - } else { - s.size = snprintf(s.str, 1024, "n:%s:%d:-", sym, linenumber); - } - write(fileno, &s, sizeof(void*)+sizeof(long)+s.size); - - lseek(fileno, pos_before, SEEK_SET); -} - -static -int cannot_read_profile = 0; - -ssize_t read_exactly(int fileno, void * buf, ssize_t size) { - assert(size >= 0 && "size parameter must be positive"); - - ssize_t r = 0; - if ((r = read(fileno, buf, (size_t)size)) == size) { - return r; - } - - if (r == -1) { - while (errno == EINTR) { - if ((r = read(fileno, buf, (size_t)size)) == size) { - return r; - } - } - } - - fprintf(stderr, "unhandled error in read_exactly. cannot proceed! could not read %d bytes", size); - cannot_read_profile = 1; - return -1; -} - -int _skip_string(int fileno) -{ - long chars; - ssize_t count = read_exactly(fileno, &chars, sizeof(long)); - //LOG("reading string of %d chars\n", chars); - if (count <= 0) { - return 1; - } - lseek(fileno, chars, SEEK_CUR); - - return 0; -} - -int _skip_header(int fileno, int * version, int * flags) -{ - unsigned char r[4]; - (void)read_exactly(fileno, r, 4); - unsigned char count = r[3]; - *version = (r[0] & 0xff) << 8 | (r[1] & 0xff); - *flags = r[2]; - lseek(fileno, (int)count, SEEK_CUR); - return 0; -} - -long _read_word(int fileno) -{ - long w; - (void)read_exactly(fileno, &w, WORD_SIZE); - return w; -} - -void * _read_addr(int fileno) -{ - void * a; - (void)read_exactly(fileno, &a, ADDR_SIZE); - return a; -} - -int _skip_word(int fileno) -{ - lseek(fileno, WORD_SIZE, SEEK_CUR); - return 0; -} - -int _skip_addr(int fileno) -{ - lseek(fileno, ADDR_SIZE, SEEK_CUR); - return 0; -} - -int _skip_time_and_zone(int fileno) -{ - lseek(fileno, sizeof(int64_t)*2 + 8, SEEK_CUR); - return 0; -} - -KHASH_MAP_INIT_INT64(ptr, int) - -void vmp_scan_profile(int fileno, int dump_nat_sym, void *all_code_uids) -{ - off_t orig_pos, cur_pos; - char marker; - ssize_t count; - int version; - int flags; - int memory = 0, lines = 0, native = 0; - fsync(fileno); - orig_pos = lseek(fileno, 0, SEEK_CUR); - - khash_t(ptr) * nat_syms = kh_init(ptr); - khiter_t it; - - lseek(fileno, 5*WORD_SIZE, SEEK_SET); - - while (1) { - if (cannot_read_profile == 1) { - cannot_read_profile = 0; - break; - } - count = read_exactly(fileno, &marker, 1); - if (count <= 0) { - break; - } - cur_pos = lseek(fileno, 0, SEEK_CUR); - LOG("posss 0x%llx %d\n", cur_pos-1, cur_pos-1); - switch (marker) { - case MARKER_HEADER: { - LOG("header 0x%llx\n", cur_pos); - if (_skip_header(fileno, &version, &flags) != 0) { - kh_destroy(ptr, nat_syms); - return; - } - memory = (flags & PROFILE_MEMORY) != 0; - native = (flags & PROFILE_NATIVE) != 0; - lines = (flags & PROFILE_LINES) != 0; - if (!native && dump_nat_sym) { - lseek(fileno, 0, SEEK_END); - kh_destroy(ptr, nat_syms); - return; - } - break; - } case MARKER_META: { - LOG("meta 0x%llx\n", cur_pos); - if (_skip_string(fileno) != 0) { return; } - if (_skip_string(fileno) != 0) { return; } - break; - } case MARKER_TIME_N_ZONE: - case MARKER_TRAILER: { - LOG("tnz or trailer 0x%llx\n", cur_pos); - if (_skip_time_and_zone(fileno) != 0) { return; } - break; - } case MARKER_VIRTUAL_IP: - case MARKER_NATIVE_SYMBOLS: { - //LOG("virtip 0x%llx\n", cur_pos); - if (_skip_addr(fileno) != 0) { return; } - if (_skip_string(fileno) != 0) { return; } - break; - } case MARKER_STACKTRACE: { - long trace_count = _read_word(fileno); - long depth = _read_word(fileno); - long i; - - LOG("stack 0x%llx %d %d\n", cur_pos, trace_count, depth); - -#ifdef RPYTHON_VMPROF - for (i = depth/2-1; i >= 0; i--) { - long kind = (long)_read_addr(fileno); - void * addr = _read_addr(fileno); - if (kind == VMPROF_NATIVE_TAG) { -#else - for (i = 0; i < depth; i++) { - void * addr = _read_addr(fileno); - if (lines && i % 2 == 0) { - continue; - } - if (((intptr_t)addr & 0x1) == 1) { -#endif - /* dump the native symbol to disk */ - if (dump_nat_sym) { - LOG("found kind %p\n", addr); - - // if the address has already been dumped, - // do not log it again! - it = kh_get(ptr, nat_syms, (khint64_t)addr); - if (it == kh_end(nat_syms)) { - char name[MAXLEN]; - char srcfile[MAXLEN]; - name[0] = 0; - srcfile[0] = 0; - int lineno = 0; - if (vmp_resolve_addr(addr, name, MAXLEN, &lineno, srcfile, MAXLEN) == 0) { - LOG("dumping add %p, name %s, %s:%d\n", addr, name, srcfile, lineno); - _dump_native_symbol(fileno, addr, name, lineno, srcfile); - int ret; - it = kh_put(ptr, nat_syms, (khint64_t)addr, &ret); - kh_value(nat_syms, it) = 1; - } - } - } -#ifdef RPYTHON_VMPROF - } -#else - } else { - // cpython adds all addresses into a set to get the intersection - // of all gc known code addresses - if (all_code_uids != NULL) { - PyObject *co_uid = PyLong_FromVoidPtr(addr); - int check = PySet_Add(all_code_uids, co_uid); - Py_CLEAR(co_uid); - } - } -#endif - } - LOG("passed memory %d \n", memory); - - if (version >= VERSION_THREAD_ID) { - if (_skip_addr(fileno) != 0) { return; } // thread id - } - if (memory) { - if (_skip_addr(fileno) != 0) { return; } // profile memory - } - - break; - } default: { - fprintf(stderr, "unknown marker 0x%x\n", marker); - lseek(fileno, 0, SEEK_END); - kh_destroy(ptr, nat_syms); - return; - } - } - - cur_pos = lseek(fileno, 0, SEEK_CUR); - if (cur_pos >= orig_pos) { - break; - } - } - - kh_destroy(ptr, nat_syms); - lseek(fileno, 0, SEEK_END); -} - -void dump_native_symbols(int fileno) -{ - vmp_scan_profile(fileno, 1, NULL); -} diff --git a/rpython/rlib/rvmprof/src/shared/symboltable.h b/rpython/rlib/rvmprof/src/shared/symboltable.h --- a/rpython/rlib/rvmprof/src/shared/symboltable.h +++ b/rpython/rlib/rvmprof/src/shared/symboltable.h @@ -2,22 +2,5 @@ #define _GNU_SOURCE 1 -/** - * Extract all the known symbols from the current process and - * log them to the file descriptor. To read them see binary.py funcs: - * - * # encoded as a mapping - * addr = read_word(fd); name = read_string(fd) - * - * A) It is not allowed to have two addresses (virtual ones are only valid - * in the curent process) in this mapping to point to several symbols. - * B) No duplicates are logged - * - * Deprecated, do not use - */ -void dump_all_known_symbols(int fd); - -void dump_native_symbols(int fd); - int vmp_resolve_addr(void * addr, char * name, int name_len, int * lineno, char * srcfile, int srcfile_len); diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_common.h b/rpython/rlib/rvmprof/src/shared/vmprof_common.h --- a/rpython/rlib/rvmprof/src/shared/vmprof_common.h +++ b/rpython/rlib/rvmprof/src/shared/vmprof_common.h @@ -39,7 +39,7 @@ static inline ssize_t search_thread(pthread_t tid, ssize_t i) { if (i < 0) i = 0; - while (i < thread_count) { + while ((size_t)i < thread_count) { if (pthread_equal(threads[i], tid)) return i; i++; diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_main.h b/rpython/rlib/rvmprof/src/shared/vmprof_main.h --- a/rpython/rlib/rvmprof/src/shared/vmprof_main.h +++ b/rpython/rlib/rvmprof/src/shared/vmprof_main.h @@ -166,7 +166,7 @@ mythread_id = PyThread_get_thread_ident(); istate = PyInterpreterState_Head(); if (istate == NULL) { - fprintf(stderr, "WARNING: interp state head is null (for thread id %d)\n", mythread_id); + fprintf(stderr, "WARNING: interp state head is null (for thread id %ld)\n", mythread_id); return NULL; } // fish fish fish, it will NOT lock the keymutex in pythread @@ -180,7 +180,7 @@ } while ((istate = PyInterpreterState_Next(istate)) != NULL); // uh? not found? - fprintf(stderr, "WARNING: cannot find thread state (for thread id %d), sample will be thrown away\n", mythread_id); + fprintf(stderr, "WARNING: cannot find thread state (for thread id %ld), sample will be thrown away\n", mythread_id); return NULL; } #endif @@ -462,13 +462,9 @@ { int fileno = vmp_profile_fileno(); fsync(fileno); - dump_native_symbols(fileno); - (void)vmp_write_time_now(MARKER_TRAILER); - teardown_rss(); - /* don't close() the file descriptor from here */ vmp_set_profile_fileno(-1); return 0; @@ -483,13 +479,16 @@ disable_cpyprof(); #endif - if (remove_sigprof_timer() == -1) + if (remove_sigprof_timer() == -1) { return -1; - if (remove_sigprof_handler() == -1) + } + if (remove_sigprof_handler() == -1) { return -1; + } #ifdef VMPROF_UNIX - if ((signal_type == SIGALRM) && remove_threads() == -1) + if ((signal_type == SIGALRM) && remove_threads() == -1) { return -1; + } #endif flush_codes(); if (shutdown_concurrent_bufs(vmp_profile_fileno()) < 0) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit