[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090919093137.GA456@elte.hu>
Date: Sat, 19 Sep 2009 11:31:37 +0200
From: Ingo Molnar <mingo@...e.hu>
To: Arjan van de Ven <arjan@...radead.org>
Cc: linux-kernel@...r.kernel.org, fweisbec@...il.com,
peterz@...radead.org
Subject: Re: [PATCH 2/8] perf: Store trace event name/id pairs in perf.data
* Arjan van de Ven <arjan@...radead.org> wrote:
> From c9d9dfc617df7a6a6029feb486f2433b7d825ef4 Mon Sep 17 00:00:00 2001
> From: Arjan van de Ven <arjan@...ux.intel.com>
> Date: Sat, 12 Sep 2009 07:52:51 +0200
> Subject: [PATCH] perf: Store trace event name/id pairs in perf.data
>
> The trace event name<->id mapping is dynamic for each kernel compile.
> In order for perf.data to be useable outside the actual system, we thus
> need to store a table of this mapping for later use.
>
> This patch adds this table to perf.data, and provides helper functions
> for lookup up fields from this table.
>
> To avoid mistakes, lookup-from-table is kept completely seprate from
> lookup-from-local-debugfs.
>
> Signed-off-by: Arjan van de Ven <arjan@...ux.intel.com>
> ---
> tools/perf/util/header.c | 59 ++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/header.h | 6 ++++
> tools/perf/util/parse-events.c | 25 +++++++++++++++++
> 3 files changed, 90 insertions(+), 0 deletions(-)
>
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index ec4d4c2..ef91145 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -86,6 +86,44 @@ void perf_header__add_attr(struct perf_header *self,
> self->attr[pos] = attr;
> }
>
> +struct perf_trace_event_type {
> + u64 event_id;
> + char name[64];
> +};
> +
> +static int event_count;
> +static struct perf_trace_event_type *events;
> +
> +void perf_header__push_event(u64 id, const char *name)
> +{
> + if (strlen(name) > 64)
> + printf("Event %s will be truncated\n", name);
> +
> + if (!events) {
> + events = malloc(sizeof(struct perf_trace_event_type));
> + if (!events)
> + die("nomem");
> + } else {
> + events = realloc(events, (event_count + 1) * sizeof(struct perf_trace_event_type));
> + if (!events)
> + die("nomem");
> + }
> + memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
> + events[event_count].event_id = id;
> + strncpy(events[event_count].name, name, 63);
> + event_count++;
This has the string length limit '64' embedded in 3 open-coded forms...
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists