Author: Matti Picus <[email protected]>
Branch: 
Changeset: r97150:8cb85ca95940
Date: 2019-08-11 22:44 +0300
http://bitbucket.org/pypy/pypy/changeset/8cb85ca95940/

Log:    sync with upstream vmprof

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
@@ -383,8 +383,22 @@
 
 #ifdef VMPROF_UNIX
 static PyObject *
-insert_real_time_thread(PyObject *module, PyObject * noargs) {
+insert_real_time_thread(PyObject *module, PyObject * args) {
     ssize_t thread_count;
+    unsigned long thread_id = 0;
+    pthread_t th = pthread_self();
+
+    if (!PyArg_ParseTuple(args, "|k", &thread_id)) {
+        return NULL;
+    }
+
+    if (thread_id) {
+#if SIZEOF_LONG <= SIZEOF_PTHREAD_T
+        th = (pthread_t) thread_id;
+#else
+        th = (pthread_t) *(unsigned long *) &thread_id;
+#endif
+    }
 
     if (!vmprof_is_enabled()) {
         PyErr_SetString(PyExc_ValueError, "vmprof is not enabled");
@@ -397,15 +411,29 @@
     }
 
     vmprof_aquire_lock();
-    thread_count = insert_thread(pthread_self(), -1);
+    thread_count = insert_thread(th, -1);
     vmprof_release_lock();
 
     return PyLong_FromSsize_t(thread_count);
 }
 
 static PyObject *
-remove_real_time_thread(PyObject *module, PyObject * noargs) {
+remove_real_time_thread(PyObject *module, PyObject * args) {
     ssize_t thread_count;
+    unsigned long thread_id = 0;
+    pthread_t th = pthread_self();
+
+    if (!PyArg_ParseTuple(args, "|k", &thread_id)) {
+        return NULL;
+    }
+
+    if (thread_id) {
+#if SIZEOF_LONG <= SIZEOF_PTHREAD_T
+        th = (pthread_t) thread_id;
+#else
+        th = (pthread_t) *(unsigned long *) &thread_id;
+#endif
+    }
 
     if (!vmprof_is_enabled()) {
         PyErr_SetString(PyExc_ValueError, "vmprof is not enabled");
@@ -418,7 +446,7 @@
     }
 
     vmprof_aquire_lock();
-    thread_count = remove_thread(pthread_self(), -1);
+    thread_count = remove_thread(th, -1);
     vmprof_release_lock();
 
     return PyLong_FromSsize_t(thread_count);
@@ -445,9 +473,9 @@
 #ifdef VMPROF_UNIX
     {"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_real_time_thread", insert_real_time_thread, METH_VARARGS,
         "Insert a thread into the real time profiling list."},
-    {"remove_real_time_thread", remove_real_time_thread, METH_NOARGS,
+    {"remove_real_time_thread", remove_real_time_thread, METH_VARARGS,
         "Remove a thread from the real time profiling list."},
 #endif
     {NULL, NULL, 0, NULL}        /* Sentinel */
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c 
b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -280,7 +280,7 @@
             // this is possible because compiler align to 8 bytes.
             //
             if (func_addr != 0x0) {
-                depth = _write_native_stack((void*)(((intptr_t)func_addr) | 
0x1), result, depth, max_depth);
+                depth = _write_native_stack((void*)(((uint64_t)func_addr) | 
0x1), result, depth, max_depth);
             }
         }
 
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_unix.c 
b/rpython/rlib/rvmprof/src/shared/vmprof_unix.c
--- a/rpython/rlib/rvmprof/src/shared/vmprof_unix.c
+++ b/rpython/rlib/rvmprof/src/shared/vmprof_unix.c
@@ -244,11 +244,7 @@
             if (commit) {
                 commit_buffer(fd, p);
             } else {
-#ifndef RPYTHON_VMPROF
                 fprintf(stderr, "WARNING: canceled buffer, no stack trace was 
written\n");
-#else
-                fprintf(stderr, "WARNING: canceled buffer, no stack trace was 
written\n");
-#endif
                 cancel_buffer(p);
             }
         }
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to