public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Mike Galbraith <efault@gmx.de>, Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 02/13] perf annotate: Parse instruction
Date: Thu, 19 Apr 2012 17:55:57 -0600	[thread overview]
Message-ID: <4F90A60D.6090701@gmail.com> (raw)
In-Reply-To: <1334867644-2722-3-git-send-email-acme@infradead.org>

On 4/19/12 2:33 PM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo<acme@redhat.com>
>
> For lines with instructions find the name and operands, breaking those
> tokens for consumption by the browser.
>
> Cc: David Ahern<dsahern@gmail.com>
> Cc: Frederic Weisbecker<fweisbec@gmail.com>
> Cc: Mike Galbraith<efault@gmx.de>
> Cc: Namhyung Kim<namhyung@gmail.com>
> Cc: Paul Mackerras<paulus@samba.org>
> Cc: Peter Zijlstra<peterz@infradead.org>
> Cc: Stephane Eranian<eranian@google.com>
> Link: http://lkml.kernel.org/n/tip-6aazb9f5o3d9zi28e6rruv12@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo<acme@redhat.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

  reply	other threads:[~2012-04-19 23:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-19 20:33 =?y?q?=5BGIT=20PULL=2000/13=5D=20Annotation=20improvements=20=28G+=20edition=29?= Arnaldo Carvalho de Melo
2012-04-19 20:33 ` [PATCH 01/13] perf annotate: Rename objdump_line to disasm_line Arnaldo Carvalho de Melo
2012-04-19 20:33 ` [PATCH 02/13] perf annotate: Parse instruction Arnaldo Carvalho de Melo
2012-04-19 23:55   ` David Ahern [this message]
2012-04-20 10:53     ` Arnaldo Carvalho de Melo
2012-04-23  6:30   ` Namhyung Kim
2012-04-19 20:33 ` [PATCH 03/13] perf annotate browser: Use the disasm_line instruction name and operand fields Arnaldo Carvalho de Melo
2012-04-19 20:33 ` [PATCH 04/13] perf annotate: Disassembler instruction parsing Arnaldo Carvalho de Melo
2012-04-19 20:34 ` [PATCH 05/13] perf annotate: Parse call targets earlier Arnaldo Carvalho de Melo
2012-04-19 20:34 ` [PATCH 06/13] perf annotate: Introduce scnprintf ins_ops method Arnaldo Carvalho de Melo
2012-04-19 20:34 ` [PATCH 07/13] perf annotate browser: Rename disasm_line_rb_node Arnaldo Carvalho de Melo
2012-04-19 20:34 ` [PATCH 08/13] perf symbols: Introduce symbol__size method Arnaldo Carvalho de Melo
2012-04-19 20:34 ` [PATCH 09/13] perf annotate browser: Hide non jump target addresses in offset mode Arnaldo Carvalho de Melo
2012-04-20  0:01 ` [GIT PULL 00/13] Annotation improvements (G+ edition) David Ahern
2012-04-20 10:51   ` Arnaldo Carvalho de Melo
2012-04-20  0:31 ` Linus Torvalds
2012-04-20  0:40   ` Linus Torvalds
2012-04-20 10:59   ` Arnaldo Carvalho de Melo
2012-04-25  7:05 ` Ingo Molnar
2012-04-25 10:31   ` Arnaldo Carvalho de Melo
2012-04-25 10:48     ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly 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=4F90A60D.6090701@gmail.com \
    --to=dsahern@gmail.com \
    --cc=acme@ghostprotocols.net \
    --cc=acme@redhat.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox