From: Yordan Karadzhov <y.karadz@gmail.com>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2] trace-cruncher: Remove "register" from k(ret)probe APIs
Date: Thu, 27 Jan 2022 12:37:32 +0200 [thread overview]
Message-ID: <e8357999-a96a-18c3-398a-71867c77d8da@gmail.com> (raw)
In-Reply-To: <20220127070244.27701-1-tz.stoyanov@gmail.com>
Applied.
Thanks Ceco!
Yordan
On 27.01.22 г. 9:02 ч., Tzvetomir Stoyanov (VMware) wrote:
> 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@gmail.com>
> ---
> 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)
>
prev parent reply other threads:[~2022-01-27 10:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 7:02 [PATCH v2] trace-cruncher: Remove "register" from k(ret)probe APIs Tzvetomir Stoyanov (VMware)
2022-01-27 10:37 ` Yordan Karadzhov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8357999-a96a-18c3-398a-71867c77d8da@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=tz.stoyanov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).