Skip to contentSkip to conversation

trace-cruncher: Cleanup in class event

PATCH New Yordan Karadzhov (VMware) 1 participant 2 messages Jan 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 trace-cruncher: Cleanup in class event

The 'instance_list' field of the class event is a legacy from an old implementation of the cleanup that was done in the destructor of the class. Currently this field is useless and has to be removed.

---
 tracecruncher/ft_utils.py | 7 -------
 1 file changed, 7 deletions(-)
tracecruncher/ft_utils.py +0 -7
index ed4bdcd..e1126ad 100644
@@ -43,7 +43,6 @@ class event:
         """
         self.system = system
         self.name = name
-        self.instance_list = []
         if static:
             self.evt_id = find_event_id(system, name)
             if self.evt_id < 0:
@@ -61,22 +60,16 @@ class event:
         """
         if instance is None:
             ft.enable_event(system=self.system, event=self.name)
-            self.instance_list.append('top')
         else:
             ft.enable_event(instance=instance, system=self.system, event=self.name)
-            self.instance_list.append(instance)
-
-        self.instance_list = list(set(self.instance_list))
 
     def disable(self, instance=None):
         """ Disable this event.
         """
         if instance is None:
             ft.disable_event(system=self.system, event=self.name)
-            self.instance_list.remove('top')
         else:
             ft.disable_event(instance=instance,system=self.system, event=self.name)
-            self.instance_list.remove(instance)
 
     def set_filter(self, filter, instance=None):
         """ Define a filter for this event.
Signature · 1 line
2.32.0
#1 lore raw

PATCH 2/2 trace-cruncher: Add no_arg()

In the implementation of the low-level APIs wrapping libtracefs, a special string is used as a default value of the optional function arguments. Here we make this string available for the high-level APIs. This simplifies the implementation of the cases when optional arguments are used.

---
 src/ftracepy-utils.c      |  5 +++++
 src/ftracepy-utils.h      |  2 ++
 src/ftracepy.c            |  5 +++++
 tracecruncher/ft_utils.py | 41 +++++++++++++--------------------------
 4 files changed, 25 insertions(+), 28 deletions(-)
src/ftracepy-utils.c +5 -0
index 8c46590..8ff6601 100644
@@ -2178,6 +2178,11 @@ PyObject *PyFtrace_tc_event_system(PyObject *self)
 	return PyUnicode_FromString(TC_SYS);
 }
 
+PyObject *PyFtrace_no_arg(PyObject *self)
+{
+	return PyUnicode_FromString(NO_ARG);
+}
+
 static PyObject *dynevent_info2py(char *buff, int type)
 {
 	PyObject *ret;
src/ftracepy-utils.h +2 -0
index 7612df6..29a7312 100644
@@ -245,6 +245,8 @@ PyObject *PyFtrace_enabled_options(PyObject *self, PyObject *args,
 
 PyObject *PyFtrace_tc_event_system(PyObject *self);
 
+PyObject *PyFtrace_no_arg(PyObject *self);
+
 PyObject *PyFtrace_register_kprobe(PyObject *self, PyObject *args,
 						   PyObject *kwargs);
 
src/ftracepy.c +5 -0
index 3f71b5e..82057ed 100644
@@ -450,6 +450,11 @@ static PyMethodDef ftracepy_methods[] = {
 	 METH_NOARGS,
 	 "Get the name of the event system used by trace-cruncher."
 	},
+	{"no_arg",
+	 (PyCFunction) PyFtrace_no_arg,
+	 METH_NOARGS,
+	 "Returns a default value for an optional function argument."
+	},
 	{"register_kprobe",
 	 (PyCFunction) PyFtrace_register_kprobe,
 	 METH_VARARGS | METH_KEYWORDS,
tracecruncher/ft_utils.py +13 -28

58 lines not on this page · raw message

Signature · 1 line
2.32.0