@@ -54,8 +54,9 @@ static inline void no_free(void *ptr)
#define NO_FREE no_free
-static inline void no_destroy(void *ptr)
+static inline int no_destroy(void *ptr)
{
+ return 0;
}
#define NO_DESTROY no_destroy
@@ -101,7 +102,9 @@ static int py_type##_init(py_type *self, PyObject *args, PyObject *kwargs) \
static void py_type##_dealloc(py_type *self) \
{ \
if (self->destroy) \
- obj_destroy(self->ptrObj); \
+ if (obj_destroy(self->ptrObj) < 0) \
+ printf("fracepy_error: object '%s' failed to destroy\n",\
+ c_type); \
ptr_free(self->ptrObj); \
Py_TYPE(self)->tp_free(self); \
} \
@@ -1757,9 +1757,9 @@ PyObject *PyKprobe_probe(PyKprobe *self)
return PyUnicode_FromString(self->ptrObj->probe);
}
-void ftracepy_kprobe_destroy(struct ftracepy_kprobe *kp)
+int ftracepy_kprobe_destroy(struct ftracepy_kprobe *kp)
{
- unregister_kprobe(kp->event);
+ return tracefs_kprobe_clear_probe(TC_SYS, kp-> event, true);
}
void ftracepy_kprobe_free(struct ftracepy_kprobe *kp)
@@ -26,7 +26,7 @@ C_OBJECT_WRAPPER_DECLARE(tracefs_instance, PyTfsInstance)
struct ftracepy_kprobe;
-void ftracepy_kprobe_destroy(struct ftracepy_kprobe *kp);
+int ftracepy_kprobe_destroy(struct ftracepy_kprobe *kp);
void ftracepy_kprobe_free(struct ftracepy_kprobe *kp);
Always print an error message in the case when the C object, being wrapped by the Python type failed to destroy. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/common.h | 7 +++++-- src/ftracepy-utils.c | 4 ++-- src/ftracepy-utils.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-)