diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c41bcf3..610dd615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Add argument names to `TypeError` messages generated by pymethod wrappers. [#1212](https://github.com/PyO3/pyo3/pull/1212) +- Add `PyEval_SetProfile` and `PyEval_SetTrace` to FFI. [#1255](https://github.com/PyO3/pyo3/pull/1255) ### Changed - Change `PyIterator` to be consistent with other native types: it is now used as `&PyIterator` instead of `PyIterator<'a>`. [#1176](https://github.com/PyO3/pyo3/pull/1176) diff --git a/src/ffi/ceval.rs b/src/ffi/ceval.rs index 31b00d7b..5df1d8c2 100644 --- a/src/ffi/ceval.rs +++ b/src/ffi/ceval.rs @@ -1,6 +1,6 @@ use crate::ffi::code::FreeFunc; use crate::ffi::object::PyObject; -use crate::ffi::pystate::PyThreadState; +use crate::ffi::pystate::{PyThreadState, Py_tracefunc}; use std::os::raw::{c_char, c_int, c_void}; extern "C" { @@ -67,6 +67,8 @@ extern "C" { pub fn PyEval_SaveThread() -> *mut PyThreadState; #[cfg_attr(PyPy, link_name = "PyPyEval_RestoreThread")] pub fn PyEval_RestoreThread(arg1: *mut PyThreadState); + pub fn PyEval_SetProfile(trace_func: Py_tracefunc, arg1: *mut PyObject); + pub fn PyEval_SetTrace(trace_func: Py_tracefunc, arg1: *mut PyObject); } #[cfg(py_sys_config = "WITH_THREAD")] diff --git a/src/ffi/pystate.rs b/src/ffi/pystate.rs index 1eaad51d..58e98875 100644 --- a/src/ffi/pystate.rs +++ b/src/ffi/pystate.rs @@ -1,4 +1,5 @@ use crate::ffi::ceval::_PyFrameEvalFunction; +use crate::ffi::frameobject::PyFrameObject; use crate::ffi::moduleobject::PyModuleDef; use crate::ffi::object::PyObject; use std::os::raw::{c_int, c_long}; @@ -67,3 +68,10 @@ extern "C" { pub unsafe fn PyThreadState_GET() -> *mut PyThreadState { PyThreadState_Get() } + +pub type Py_tracefunc = extern "C" fn( + obj: *mut PyObject, + frame: *mut PyFrameObject, + what: c_int, + arg: *mut PyObject, +) -> c_int;