[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4F90A60D.6090701@gmail.com>
Date: Thu, 19 Apr 2012 17:55:57 -0600
From: David Ahern <dsahern@...il.com>
To: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
CC: Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Mike Galbraith <efault@....de>,
Namhyung Kim <namhyung@...il.com>,
Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <peterz@...radead.org>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 02/13] perf annotate: Parse instruction
On 4/19/12 2:33 PM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo<acme@...hat.com>
>
> For lines with instructions find the name and operands, breaking those
> tokens for consumption by the browser.
>
> Cc: David Ahern<dsahern@...il.com>
> Cc: Frederic Weisbecker<fweisbec@...il.com>
> Cc: Mike Galbraith<efault@....de>
> Cc: Namhyung Kim<namhyung@...il.com>
> Cc: Paul Mackerras<paulus@...ba.org>
> Cc: Peter Zijlstra<peterz@...radead.org>
> Cc: Stephane Eranian<eranian@...gle.com>
> Link: http://lkml.kernel.org/n/tip-6aazb9f5o3d9zi28e6rruv12@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo<acme@...hat.com>
> ---
> tools/perf/util/annotate.c | 65 +++++++++++++++++++++++++++++++++++++++++++-
> tools/perf/util/annotate.h | 3 ++
> 2 files changed, 67 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index ef1d57d..a72585a 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -80,16 +80,50 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
>
> static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privsize)
> {
> - struct disasm_line *dl = malloc(sizeof(*dl) + privsize);
> + struct disasm_line *dl = zalloc(sizeof(*dl) + privsize);
>
> if (dl != NULL) {
> dl->offset = offset;
> dl->line = strdup(line);
> if (dl->line == NULL)
> goto out_delete;
> +
> + if (offset != -1) {
> + char *name = dl->line, tmp;
> +
> + while (isspace(name[0]))
> + ++name;
> +
> + if (name[0] == '\0')
> + goto out_delete;
> +
> + dl->operands = name + 1;
> +
> + while (dl->operands[0] != '\0'&&
> + !isspace(dl->operands[0]))
> + ++dl->operands;
> +
> + tmp = dl->operands[0];
> + dl->operands[0] = '\0';
> + dl->name = strdup(name);
This strdup seems unnecessary. The parsing seems to be:
dl->line = "\W*name\W*operands"
dl->name = -^ ^- = dl_operands
so name and operands are 2 different parts of the same buffer.
David
--
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