Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: John Koepi <john.koepi@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH bpf] traceevent: ignore __attribute__ in fields format
Date: Wed, 15 Jan 2020 20:47:47 +0200
Message-ID: <CAJ8z9b0fHwOUgF_AgXED3wuZpOVbQTfGA3WkNbNFCmiY_Br3Tw@mail.gmail.com> (raw)
In-Reply-To: <20200115180645.53331-1-john.koepi@gmail.com>

I am not sure this is the right mailing list (I was not sure about
@netdev). If it is not - I am sorry, I can resend it. The test for
this change is at https://github.com/sitano/traceevent_attribute.

On Wed, Jan 15, 2020 at 8:06 PM Ivan Prisyazhnyy <john.koepi@gmail.com> wrote:
>
> To support kernel (e.g. Arch linux) tracing that
> have events fields with C attributes (__attribute__((xxx))),
> traceevent must ignore __attribute__ parts when
> parsing fields types.
>
> An example from Arch linux kernel 4.2:
>
>   $ cat /sys/kernel/.../sys_enter_io_submit/format
>   ...
>   field:struct iocb __attribute__((user)) * ...
>                     ^^^
>
> This fix adds support for fields types C attributes
> parsing to event_read_fields function. When it sees
> __attribute__ ((attribute-list)) expression it skips
> it.
>
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=205857
> Base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/
> Signed-off-by: Ivan Prisyazhnyy <john.koepi@gmail.com>
> ---
>  tools/lib/traceevent/event-parse.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index beaa8b8c08ff..fbc1ea536742 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -1486,6 +1486,28 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field **
>                             (event->flags & TEP_EVENT_FL_ISFTRACE &&
>                              type == TEP_EVENT_OP && strcmp(token, ".") == 0)) {
>
> +                               /* ignore C attributes: __attribute__((expr)) */
> +                               if (strcmp(token, "__attribute__") == 0) {
> +                                       free(token);
> +                                       for (int i = 0; i < 2; i++) {
> +                                               if (read_expected_item(TEP_EVENT_DELIM, "(") < 0) {
> +                                                       goto fail_expect;
> +                                               }
> +                                       }
> +                                       for (int brackets = 2; brackets > 0;) {
> +                                               if (read_token(&token) == TEP_EVENT_NONE) {
> +                                                       do_warning_event(event, "%s: __attribute__ not full", __func__);
> +                                                       goto fail_expect;
> +                                               }
> +                                               if (strcmp(token, "(") == 0)
> +                                                       brackets++;
> +                                               else if (strcmp(token, ")") == 0)
> +                                                       brackets--;
> +                                               free(token);
> +                                       }
> +                                       continue;
> +                               }
> +
>                                 if (strcmp(token, "*") == 0)
>                                         field->flags |= TEP_FIELD_IS_POINTER;
>
> --
> 2.24.1
>


-- 
-- Ivan

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 17:07 traceevent support for kernels with CONFIG_GCC_PLUGIN_STRUCTLEAK=y John Koepi
2019-12-12 17:25 ` Steven Rostedt
2019-12-14 15:38   ` John Koepi
2020-01-15 18:06     ` [PATCH bpf] traceevent: ignore __attribute__ in fields format Ivan Prisyazhnyy
2020-01-15 18:47       ` John Koepi [this message]
2020-01-15 19:31         ` Steven Rostedt

Reply instructions:

You may reply publically 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=CAJ8z9b0fHwOUgF_AgXED3wuZpOVbQTfGA3WkNbNFCmiY_Br3Tw@mail.gmail.com \
    --to=john.koepi@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git