trace-cruncher: Add 'is_attached()'
PATCH 1/2 trace-cruncher: Add 'is_attached()'
We already have APIs for attaching/detaching an object from/to the 'ftracepy' module. For the sake of completeness we have to add an API that checks if the object is attached.
Signed-off-by Yordan Karadzhov (VMware) <[email protected]>
--- src/ftracepy-utils.c | 22 ++++++++++++++++++++++ src/ftracepy-utils.h | 2 ++ src/ftracepy.c | 5 +++++ 3 files changed, 29 insertions(+)
src/ftracepy-utils.c +22 -0
@@ -1037,6 +1037,28 @@ PyObject *PyFtrace_attach(PyObject *self, PyObject *args, PyObject *kwargs)return set_destroy (args, kwargs, true); } +static bool get_destroy_flag (PyObject *py_obj) +{ +PyFtrace_Object_HEAD *obj_head = (PyFtrace_Object_HEAD *)py_obj; +return obj_head->destroy; +} + +PyObject *PyFtrace_is_attached (PyObject *self,PyObject *args,PyObject *kwargs) +{ +static char *kwlist[] = {"object" ,NULL }; +PyObject *py_obj; + +if (!PyArg_ParseTupleAndKeywords (args, + kwargs, +"O" , + kwlist, + &py_obj)) { +return NULL ; + } + +return get_destroy_flag (py_obj) ? Py_True : Py_False; +} +static char aname_pool[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
src/ftracepy-utils.h +2 -0
@@ -125,6 +125,8 @@ PyObject *PyFtrace_detach(PyObject *self, PyObject *args, PyObject *kwargs);PyObject *PyFtrace_attach (PyObject *self,PyObject *args,PyObject *kwargs); +PyObject *PyFtrace_is_attached (PyObject *self,PyObject *args,PyObject *kwargs); +PyObject *PyFtrace_create_instance (PyObject *self,PyObject *args,PyObject *kwargs);
src/ftracepy.c +5 -0
@@ -237,6 +237,11 @@ static PyMethodDef ftracepy_methods[] = {METH_VARARGS |METH_KEYWORDS ,"Attach object to the \'ftracepy\' module." }, + {"is_attached", + (PyCFunction ) PyFtrace_is_attached, +METH_VARARGS |METH_KEYWORDS , +"Check if the object is attached to the \'ftracepy\' module." + }, {"create_instance", (PyCFunction ) PyFtrace_create_instance, METH_VARARGS | METH_KEYWORDS,
Signature · 1 line
2.32.0
PATCH 2/2 trace-cruncher: Fix error message typo
Signed-off-by Yordan Karadzhov (VMware) <[email protected]>
--- tracecruncher/ft_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tracecruncher/ft_utils.py +1 -1
@@ -47,7 +47,7 @@ class event: if static: self.evt_id = find_event_id(system, name) if self.evt_id < 0: - raise ValueError('Faild to find event {0}/{1}'.format(system, name)) + raise ValueError('Failed to find event {0}/{1}'.format(system, name)) else: self.evt_id = -1
Signature · 1 line
2.32.0