In order to be consistent with the other trace-cruncher APIs for dynamic events, renamed these APIs: register_kprobe to kprobe register_kretprobe to kretprobe Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- v2 changes: - Coding style fixes. src/ftracepy-utils.c | 6 ++---- src/ftracepy-utils.h | 6 ++---- src/ftracepy.c | 8 ++++---- tracecruncher/ft_utils.py | 4 ++-- .../tests/1_unit/test_01_ftracepy_unit.py | 14 +++++--------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index 053b659..0a4092f 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -2229,8 +2229,7 @@ PyObject *PyDynevent_probe(PyDynevent *self) return dynevent_info2py(buff, type); } -PyObject *PyFtrace_register_kprobe(PyObject *self, PyObject *args, - PyObject *kwargs) +PyObject *PyFtrace_kprobe(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = {"event", "function", "probe", NULL}; const char *event, *function, *probe; @@ -2261,8 +2260,7 @@ PyObject *PyFtrace_register_kprobe(PyObject *self, PyObject *args, return PyDynevent_New(kprobe); } -PyObject *PyFtrace_register_kretprobe(PyObject *self, PyObject *args, - PyObject *kwargs) +PyObject *PyFtrace_kretprobe(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = {"event", "function", "probe", NULL}; const char *event, *function, *probe = "$retval"; diff --git a/src/ftracepy-utils.h b/src/ftracepy-utils.h index c96fd85..b7ce179 100644 --- a/src/ftracepy-utils.h +++ b/src/ftracepy-utils.h @@ -245,11 +245,9 @@ PyObject *PyFtrace_enabled_options(PyObject *self, PyObject *args, PyObject *PyFtrace_tc_event_system(PyObject *self); -PyObject *PyFtrace_register_kprobe(PyObject *self, PyObject *args, - PyObject *kwargs); +PyObject *PyFtrace_kprobe(PyObject *self, PyObject *args, PyObject *kwargs); -PyObject *PyFtrace_register_kretprobe(PyObject *self, PyObject *args, - PyObject *kwargs); +PyObject *PyFtrace_kretprobe(PyObject *self, PyObject *args, PyObject *kwargs); PyObject *PyFtrace_eprobe(PyObject *self, PyObject *args, PyObject *kwargs); diff --git a/src/ftracepy.c b/src/ftracepy.c index 464e8d3..9207c70 100644 --- a/src/ftracepy.c +++ b/src/ftracepy.c @@ -450,13 +450,13 @@ static PyMethodDef ftracepy_methods[] = { METH_NOARGS, "Get the name of the event system used by trace-cruncher." }, - {"register_kprobe", - (PyCFunction) PyFtrace_register_kprobe, + {"kprobe", + (PyCFunction) PyFtrace_kprobe, METH_VARARGS | METH_KEYWORDS, "Define a kprobe." }, - {"register_kretprobe", - (PyCFunction) PyFtrace_register_kretprobe, + {"kretprobe", + (PyCFunction) PyFtrace_kretprobe, METH_VARARGS | METH_KEYWORDS, "Define a kretprobe." }, diff --git a/tracecruncher/ft_utils.py b/tracecruncher/ft_utils.py index ed4bdcd..54cffe0 100644 --- a/tracecruncher/ft_utils.py +++ b/tracecruncher/ft_utils.py @@ -178,7 +178,7 @@ class kprobe(kprobe_base): """ probe = ' '.join('{!s}={!s}'.format(key,val) for (key, val) in self.fields.items()) - self.kp = ft.register_kprobe(event=self.name, function=self.func, probe=probe); + self.kp = ft.kprobe(event=self.name, function=self.func, probe=probe); self.evt_id = find_event_id(system=ft.tc_event_system(), event=self.name) @@ -208,7 +208,7 @@ class kretval_probe(kprobe_base): def register(self): """ Register this probe to Ftrace. """ - self.kp = ft.register_kprobe(event=self.name, function=self.func); + self.kp = ft.kprobe(event=self.name, function=self.func); self.evt_id = find_event_id(system=ft.tc_event_system(), event=self.name) diff --git a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py index d773acc..1ef8951 100644 --- a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py +++ b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py @@ -405,7 +405,7 @@ class OptionsTestCase(unittest.TestCase): class KprobeTestCase(unittest.TestCase): - def test_register_kprobe(self): + def test_kprobe(self): evt1 = 'mkdir' evt1_func = 'do_mkdirat' evt1_prove = 'path=+u0($arg2):ustring' @@ -413,14 +413,12 @@ class KprobeTestCase(unittest.TestCase): evt2_func = 'do_sys_openat2' evt2_prove = 'file=+u0($arg2):ustring' - kp1 = ft.register_kprobe(event=evt1, function=evt1_func, - probe=evt1_prove) + kp1 = ft.kprobe(event=evt1, function=evt1_func, probe=evt1_prove) self.assertEqual(evt1, kp1.event()) self.assertEqual(evt1_func, kp1.address()) self.assertEqual(evt1_prove, kp1.probe()) - kp2 = ft.register_kprobe(event=evt2, function=evt2_func, - probe=evt2_prove) + kp2 = ft.kprobe(event=evt2, function=evt2_func, probe=evt2_prove) self.assertEqual(evt2, kp2.event()) self.assertEqual(evt2_func, kp2.address()) self.assertEqual(evt2_prove, kp2.probe()) @@ -431,8 +429,7 @@ class KprobeTestCase(unittest.TestCase): evt1_prove = 'path=+u0($arg2):ustring' flt = 'path~\'/sys/fs/cgroup/*\'' - kp1 = ft.register_kprobe(event=evt1, function=evt1_func, - probe=evt1_prove) + kp1 = ft.kprobe(event=evt1, function=evt1_func, probe=evt1_prove) inst = ft.create_instance(instance_name) kp1.set_filter(instance=inst, filter=flt) @@ -447,8 +444,7 @@ class KprobeTestCase(unittest.TestCase): evt1_func = 'do_mkdirat' evt1_prove = 'path=+u0($arg2):ustring' - kp1 = ft.register_kprobe(event=evt1, function=evt1_func, - probe=evt1_prove) + kp1 = ft.kprobe(event=evt1, function=evt1_func, probe=evt1_prove) inst = ft.create_instance(instance_name) kp1.enable(instance=inst) ret = kp1.is_enabled(instance=inst) -- 2.34.1