Re: [RFC][PATCH v5 3/4] trace/objtrace: Add testcases for objtrace trigger parsing

From: Jeff Xie
Date: Sun Nov 21 2021 - 12:16:37 EST


Hi Masami,

On Fri, Nov 19, 2021 at 10:09 PM Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:
>
> On Sat, 13 Nov 2021 20:06:31 +0800
> Jeff Xie <xiehuan09@xxxxxxxxx> wrote:
>
> Please add a patch description here.
>
> > Signed-off-by: Jeff Xie <xiehuan09@xxxxxxxxx>
> > ---
> > .../ftrace/test.d/trigger/trigger-objtrace.tc | 41 +++++++++++++++++++
> > 1 file changed, 41 insertions(+)
> > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> >
> > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> > new file mode 100644
> > index 000000000000..4efcd7eee694
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> > @@ -0,0 +1,41 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +# description: event trigger - test objtrace-trigger
> > +# requires: kprobe_events
>
> Hmm, didn't you add something for this in <tracefs>/README?

Sorry, I ignored it.

> Instead of checking trigger file, I recommend to update
>
> There is a text data in the kernel/trace/trace.c;
> static const char readme_msg[] =
> ...
> "\t trigger: traceon, traceoff\n"
> "\t enable_event:<system>:<event>\n"
> "\t disable_event:<system>:<event>\n"
> #ifdef CONFIG_HIST_TRIGGERS
> "\t enable_hist:<system>:<event>\n"
> "\t disable_hist:<system>:<event>\n"
> #endif
>
> You can add somewhere near there as
>
> #ifdef CONFIG_TRACE_OBJECT
> "\t objtrace:add:..." // fill syntax.
> #endif
>
> And then, you can write the pattern in the requires line, like
>
> # requires: kprobe_events "objtrace":README
>
> Thank you,

Thanks, I will add them to <tracefs>/README, and modify the
trigger-objtrace.tc file.

> > +
> > +fail() { #msg
> > + echo $1
> > + exit_fail
> > +}
> > +
> > +echo 'p bio_add_page arg1=$arg1' > kprobe_events
> > +
> > +FEATURE=`grep objtrace events/kprobes/p_bio_add_page_0/trigger`
> > +if [ -z "$FEATURE" ]; then
> > + echo "objtrace trigger is not supported"
> > + exit_unsupported
> > +fi
>
>
> > +
> > +echo "Test objtrace trigger"
> > +echo 'objtrace:add:0x28(arg1):u32:1 if comm == "cat"' > \
> > + events/kprobes/p_bio_add_page_0/trigger
> > +if [ -z $? ]; then
> > + fail "objtrace trigger syntax error"
> > +fi
> > +
> > +echo "Test objtrace semantic errors"
> > +
> > +# Being lack of type size
> > +! echo 'objtrace:add:0x28(arg1):1' > events/kprobes/p_bio_add_page_0/trigger
> > +# Being lack of objtrace command
> > +! echo 'objtrace:0x28(arg1):u32:1' > events/kprobes/p_bio_add_page_0/trigger
> > +# Bad parameter name
> > +! echo 'objtrace:add:argx:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> > +
> > +echo "reset objtrace trigger"
> > +
> > +echo '!objtrace:add:0x28(arg1):u32' > \
> > + events/kprobes/p_bio_add_page_0/trigger
> > +echo '-:p_bio_add_page_0' >> ./kprobe_events
> > +
> > +exit 0
> > --
> > 2.25.1
> >
>
>
> --
> Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Thanks,
---
JeffXie