aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-03-26 17:28:45 +0200
committerMatti Picus <matti.picus@gmail.com>2020-03-26 17:28:45 +0200
commitf1147d413ba1cdade84f40558848b81cb6f2165d (patch)
tree3d6be95809e868361224e7bdad40fdf7056ef977
parenttry adding '-stdlib=libc++' for darwin (diff)
downloadpypy-f1147d413ba1cdade84f40558848b81cb6f2165d.tar.gz
pypy-f1147d413ba1cdade84f40558848b81cb6f2165d.tar.bz2
pypy-f1147d413ba1cdade84f40558848b81cb6f2165d.zip
re-sync vmprof with upstream
-rw-r--r--rpython/rlib/rvmprof/src/shared/vmp_stack.c10
-rw-r--r--rpython/rlib/rvmprof/src/shared/vmprof_common.c11
-rw-r--r--rpython/rlib/rvmprof/src/shared/vmprof_common.h11
-rw-r--r--rpython/rlib/rvmprof/src/shared/vmprof_unix.c10
-rw-r--r--rpython/rlib/rvmprof/src/shared/vmprof_win.c11
5 files changed, 31 insertions, 22 deletions
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
index fea7813f13..a03d1f578f 100644
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -189,14 +189,18 @@ int vmp_walk_and_record_stack(PY_STACK_FRAME_T *frame, void ** result,
ret = unw_getcontext(&uc);
if (ret < 0) {
// could not initialize lib unwind cursor and context
+#if DEBUG
fprintf(stderr, "WARNING: unw_getcontext did not retreive context, switching to python profiling mode \n");
+#endif
vmp_native_disable();
return vmp_walk_and_record_python_stack_only(frame, result, max_depth, 0, pc);
}
ret = unw_init_local(&cursor, &uc);
if (ret < 0) {
// could not initialize lib unwind cursor and context
+#if DEBUG
fprintf(stderr, "WARNING: unw_init_local did not succeed, switching to python profiling mode \n");
+#endif
vmp_native_disable();
return vmp_walk_and_record_python_stack_only(frame, result, max_depth, 0, pc);
}
@@ -205,7 +209,9 @@ int vmp_walk_and_record_stack(PY_STACK_FRAME_T *frame, void ** result,
while (signal < 0) {
int err = unw_step(&cursor);
if (err <= 0) {
+#if DEBUG
fprintf(stderr, "WARNING: did not find signal frame, skipping sample\n");
+#endif
return 0;
}
signal++;
@@ -220,7 +226,9 @@ int vmp_walk_and_record_stack(PY_STACK_FRAME_T *frame, void ** result,
}
int err = unw_step(&cursor);
if (err <= 0) {
+#if DEBUG
fprintf(stderr,"WARNING: did not find signal frame, skipping sample\n");
+#endif
return 0;
}
}
@@ -577,7 +585,9 @@ void vmp_native_disable(void) {
if (libhandle != NULL) {
if (dlclose(libhandle)) {
vmprof_error = dlerror();
+#if DEBUG
fprintf(stderr, "could not close libunwind at runtime. error: %s\n", vmprof_error);
+#endif
}
libhandle = NULL;
}
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_common.c b/rpython/rlib/rvmprof/src/shared/vmprof_common.c
index c54eeca960..6b968d4eaf 100644
--- a/rpython/rlib/rvmprof/src/shared/vmprof_common.c
+++ b/rpython/rlib/rvmprof/src/shared/vmprof_common.c
@@ -165,17 +165,6 @@ int opened_profile(const char *interp_name, int memory, int proflines, int nativ
}
-/* Seems that CPython 3.5.1 made our job harder. Did not find out how
- to do that without these hacks. We can't use PyThreadState_GET(),
- because that calls PyThreadState_Get() which fails an assert if the
- result is NULL. */
-#if PY_MAJOR_VERSION >= 3 && !defined(_Py_atomic_load_relaxed)
- /* this was abruptly un-defined in 3.5.1 */
-void *volatile _PyThreadState_Current;
- /* XXX simple volatile access is assumed atomic */
-# define _Py_atomic_load_relaxed(pp) (*(pp))
-#endif
-
#ifdef RPYTHON_VMPROF
#ifndef RPYTHON_LL2CTYPES
PY_STACK_FRAME_T *get_vmprof_stack(void)
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_common.h b/rpython/rlib/rvmprof/src/shared/vmprof_common.h
index 1b2278b1d1..3c313ce475 100644
--- a/rpython/rlib/rvmprof/src/shared/vmprof_common.h
+++ b/rpython/rlib/rvmprof/src/shared/vmprof_common.h
@@ -83,17 +83,6 @@ char *vmprof_init(int fd, double interval, int memory,
int opened_profile(const char *interp_name, int memory, int proflines, int native, int real_time);
-/* Seems that CPython 3.5.1 made our job harder. Did not find out how
- to do that without these hacks. We can't use PyThreadState_GET(),
- because that calls PyThreadState_Get() which fails an assert if the
- result is NULL. */
-#if PY_MAJOR_VERSION >= 3 && !defined(_Py_atomic_load_relaxed)
- /* this was abruptly un-defined in 3.5.1 */
-extern void *volatile _PyThreadState_Current;
- /* XXX simple volatile access is assumed atomic */
-# define _Py_atomic_load_relaxed(pp) (*(pp))
-#endif
-
#ifdef RPYTHON_VMPROF
#ifndef RPYTHON_LL2CTYPES
PY_STACK_FRAME_T *get_vmprof_stack(void);
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_unix.c b/rpython/rlib/rvmprof/src/shared/vmprof_unix.c
index 595fff55a6..3bd17b1674 100644
--- a/rpython/rlib/rvmprof/src/shared/vmprof_unix.c
+++ b/rpython/rlib/rvmprof/src/shared/vmprof_unix.c
@@ -127,7 +127,9 @@ PY_THREAD_STATE_T * _get_pystate_for_this_thread(void) {
mythread_id = PyThread_get_thread_ident();
istate = PyInterpreterState_Head();
if (istate == NULL) {
+#if DEBUG
fprintf(stderr, "WARNING: interp state head is null (for thread id %ld)\n", mythread_id);
+#endif
return NULL;
}
// fish fish fish, it will NOT lock the keymutex in pythread
@@ -141,7 +143,9 @@ PY_THREAD_STATE_T * _get_pystate_for_this_thread(void) {
} while ((istate = PyInterpreterState_Next(istate)) != NULL);
// uh? not found?
+#if DEBUG
fprintf(stderr, "WARNING: cannot find thread state (for thread id %ld), sample will be thrown away\n", mythread_id);
+#endif
return NULL;
}
#endif
@@ -244,7 +248,9 @@ void sigprof_handler(int sig_nr, siginfo_t* info, void *ucontext)
if (commit) {
commit_buffer(fd, p);
} else {
+#if DEBUG
fprintf(stderr, "WARNING: canceled buffer, no stack trace was written\n");
+#endif
cancel_buffer(p);
}
}
@@ -477,13 +483,17 @@ int get_stack_trace(PY_THREAD_STATE_T * current, void** result, int max_depth, i
frame = (PY_STACK_FRAME_T*)current;
#else
if (current == NULL) {
+#if DEBUG
fprintf(stderr, "WARNING: get_stack_trace, current is NULL\n");
+#endif
return 0;
}
frame = current->frame;
#endif
if (frame == NULL) {
+#if DEBUG
fprintf(stderr, "WARNING: get_stack_trace, frame is NULL\n");
+#endif
return 0;
}
return vmp_walk_and_record_stack(frame, result, max_depth, 1, pc);
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_win.c b/rpython/rlib/rvmprof/src/shared/vmprof_win.c
index 240c2e9902..daadd98fa9 100644
--- a/rpython/rlib/rvmprof/src/shared/vmprof_win.c
+++ b/rpython/rlib/rvmprof/src/shared/vmprof_win.c
@@ -104,6 +104,17 @@ int vmprof_snapshot_thread(DWORD thread_id, PY_WIN_THREAD_STATE *tstate, prof_st
#endif
}
+/* Seems that CPython 3.5.1 made our job harder. Did not find out how
+ to do that without these hacks. We can't use PyThreadState_GET(),
+ because that calls PyThreadState_Get() which fails an assert if the
+ result is NULL. */
+#if PY_MAJOR_VERSION >= 3 && !defined(_Py_atomic_load_relaxed)
+ /* this was abruptly un-defined in 3.5.1 */
+void *volatile _PyThreadState_Current;
+ /* XXX simple volatile access is assumed atomic */
+# define _Py_atomic_load_relaxed(pp) (*(pp))
+#endif
+
#ifndef RPYTHON_VMPROF
static
PY_WIN_THREAD_STATE * get_current_thread_state(void)