lkml.org 
[lkml]   [2009]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/8] perf: Store trace event name/id pairs in perf.data

* Arjan van de Ven <arjan@infradead.org> wrote:

> From c9d9dfc617df7a6a6029feb486f2433b7d825ef4 Mon Sep 17 00:00:00 2001
> From: Arjan van de Ven <arjan@linux.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@linux.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


\
 
 \ /
  Last update: 2009-09-19 11:35    [W:0.053 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site