linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Taeung Song <treeze.taeung@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Wang Nan <wangnan0@huawei.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 06/20] perf annotate: More exactly grep -v of the objdump command
Date: Fri, 24 Mar 2017 11:57:17 -0300	[thread overview]
Message-ID: <20170324145731.29350-7-acme@kernel.org> (raw)
In-Reply-To: <20170324145731.29350-1-acme@kernel.org>

From: Taeung Song <treeze.taeung@gmail.com>

The 'grep -v "filename"' applied to the objdump command output cause a
side effect eliminating filename:linenr of output of 'objdump -l' if the
object file name and source file name are the same, fix it.

E.g. the output of the following objdump command in symbol__disassemble():

    $ objdump -l -d -S -C /home/taeung/hello --start-address=...

    /home/taeung/hello:     file format elf64-x86-64

    Disassembly of section .text:

    0000000000400526 <main>:
    main():
    /home/taeung/hello.c:4

    void main()
    {
      400526:	55                   	push   %rbp
      400527:	48 89 e5             	mov    %rsp,%rbp
    /home/taeung/hello.c:5
    ...

But it uses grep -v "filename" e.g. "/home/taeung/hello" in the objdump
command to remove the first line containing file name and file format
("/home/taeung/hello:     file format elf64-x86-64"):

Before:

    $ objdump -l -d -S -C /home/taeung/hello | grep /home/taeung/hello

But this causes a side effect, removing filename:linenr too, because the
object file and source file have the same name e.g. "/home/taueng/hello",
"/home/taeung/hello.c"

So more do a better match by using grep -v as below to correctly remove
that first line:

    "/home/taeung/hello:     file format elf64-x86-64"

After:

    $ objdump -l -d -S -C /home/taeung/hello | grep /home/taeung/hello:

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1489978617-31396-5-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 273f21fa32b5..4d325cdcb732 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1435,7 +1435,7 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na
 	snprintf(command, sizeof(command),
 		 "%s %s%s --start-address=0x%016" PRIx64
 		 " --stop-address=0x%016" PRIx64
-		 " -l -d %s %s -C %s 2>/dev/null|grep -v %s|expand",
+		 " -l -d %s %s -C %s 2>/dev/null|grep -v %s:|expand",
 		 objdump_path ? objdump_path : "objdump",
 		 disassembler_style ? "-M " : "",
 		 disassembler_style ? disassembler_style : "",
-- 
2.9.3

  parent reply	other threads:[~2017-03-24 15:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 14:57 [GIT PULL 00/20] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 01/20] perf probe: Change MAX_CMDLEN Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 02/20] perf probe: Return errno when not hitting any event Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 03/20] perf sdt: Add scanning of sdt probes arguments Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 04/20] perf probe: Add sdt probes arguments into the uprobe cmd string Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 05/20] perf sdt x86: Add renaming logic for rNN and other registers Arnaldo Carvalho de Melo
2017-03-24 14:57 ` Arnaldo Carvalho de Melo [this message]
2017-03-24 14:57 ` [PATCH 07/20] perf annotate: Add comment clarifying how the source code line is parsed Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 08/20] perf stat: Factor out callback for collecting event values Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 09/20] perf stat: Collapse identically named events Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 10/20] perf stat: Handle partially bad results with merging Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 11/20] perf tools: Factor out PMU matching in parser Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 12/20] perf pmu: Expand PMU events by prefix match Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 13/20] perf pmu: Special case uncore_ prefix Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 14/20] perf tools: Add a simple expression parser for JSON Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 15/20] perf vendor events intel: Update Intel uncore JSON event files Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 16/20] perf pmu: Support MetricExpr header in JSON event list Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 17/20] perf stat: Output JSON MetricExpr metric Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 18/20] perf list: Support printing MetricExpr with --debug Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 19/20] perf pmu: Add support for MetricName JSON attribute Arnaldo Carvalho de Melo
2017-03-24 14:57 ` [PATCH 20/20] perf list: Move extra details printing to new option Arnaldo Carvalho de Melo
2017-03-24 18:39 ` [GIT PULL 00/20] perf/core improvements and fixes Ingo Molnar

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=20170324145731.29350-7-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=treeze.taeung@gmail.com \
    --cc=wangnan0@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).