Re: [PATCH 4/7] tracing: add format file to describe event structfields

From: Andrew Morton
Date: Mon Mar 02 2009 - 16:13:32 EST


On Mon, 02 Mar 2009 15:29:29 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> From: Steven Rostedt <srostedt@xxxxxxxxxx>
>
> This patch adds the "format" file to the trace point event directory.
> This is based off of work by Tom Zanussi, in which a file is exported
> to be tread from user land such that a user space app may read the

s/tread/read/

> binary record stored in the ring buffer.
>
> ...
>
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -3,6 +3,9 @@
> *
> * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@xxxxxxxxxx>
> *
> + * - Added format output of fields of the trace point.
> + * This was based off of work by Tom Zanussi <tzanussi@xxxxxxxxx>.

ick. "based on"

> + *
> */
>
> #include <linux/debugfs.h>
> @@ -444,6 +447,42 @@ event_available_types_read(struct file *filp, char __user *ubuf, size_t cnt,
> return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
> }
>
> +static ssize_t
> +event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
> + loff_t *ppos)
> +{
> + struct ftrace_event_call *call = filp->private_data;
> + struct trace_seq *s;
> + char *buf;
> + int r;
> +
> + s = kmalloc(sizeof(*s), GFP_KERNEL);
> + if (!s)
> + return -ENOMEM;
> +
> + trace_seq_init(s);
> +
> + if (*ppos)
> + return 0;

Someone get this man a bucket!

> + r = call->show_format(s);
> + if (!r) {
> + /*
> + * ug! The format output is bigger than a PAGE!!
> + */
> + buf = "FORMAT TOO BIG\n";
> + r = simple_read_from_buffer(ubuf, cnt, ppos,
> + buf, strlen(buf));
> + goto out;
> + }
> +
> + r = simple_read_from_buffer(ubuf, cnt, ppos,
> + s->buffer, s->len);
> + out:
> + kfree(s);
> + return r;
> +}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/