From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jiri Olsa <jolsa@redhat.com>,
Stephane Eranian <eranian@google.com>,
Andi Kleen <ak@linux.intel.com>, David Ahern <dsahern@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>
Subject: [PATCH 01/13] perf annotate: Parse --asm-raw output properly
Date: Sat, 10 Nov 2012 02:27:12 +0900 [thread overview]
Message-ID: <1352482044-3443-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1352482044-3443-1-git-send-email-namhyung@kernel.org>
From: Namhyung Kim <namhyung.kim@lge.com>
If --asm-raw option was given, objdump output will contain hex numbers
of the instruction before the symbolic name. However current parser
code doesn't handle it properly. Fix it.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/browsers/annotate.c | 2 ++
tools/perf/util/annotate.c | 36 ++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 3eff17f703f3..aec11f34d394 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -117,6 +117,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
ab->addr_width, " ");
slsmg_write_nstring(bf, printed);
slsmg_write_nstring(dl->line, width - printed - 6);
+ } else if (!dl->name) {
+ slsmg_write_nstring(" ", width - 7);
} else {
u64 addr = dl->offset;
int color = -1;
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b14d4df9f149..0565558b6184 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -162,7 +162,7 @@ static int comment__symbol(char *raw, char *comment, u64 *addrp, char **namep)
static int lock__parse(struct ins_operands *ops)
{
- char *name;
+ char *name = NULL;
ops->locked.ops = zalloc(sizeof(*ops->locked.ops));
if (ops->locked.ops == NULL)
@@ -171,7 +171,10 @@ static int lock__parse(struct ins_operands *ops)
if (disasm_line__parse(ops->raw, &name, &ops->locked.ops->raw) < 0)
goto out_free_ops;
- ops->locked.ins = ins__find(name);
+ if (name == NULL)
+ goto out_free_ops;
+
+ ops->locked.ins = ins__find(name);
if (ops->locked.ins == NULL)
goto out_free_ops;
@@ -492,6 +495,9 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
static void disasm_line__init_ins(struct disasm_line *dl)
{
+ if (dl->name == NULL)
+ return;
+
dl->ins = ins__find(dl->name);
if (dl->ins == NULL)
@@ -514,6 +520,32 @@ static int disasm_line__parse(char *line, char **namep, char **rawp)
if (name[0] == '\0')
return -1;
+ if (symbol_conf.annotate_asm_raw) {
+ /*
+ * If --asm-raw option was given, objdump output will contain
+ * hex numbers of the instructions before the symbolic name.
+ * They are separated by at least two space characters:
+ *
+ * 400540: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
+ * 400547: 00
+ *
+ * It sometimes was broken to multiple lines due to a limited
+ * width. In this case following condition will be met:
+ *
+ * dl->offset != -1 && dl->name == NULL.
+ */
+ name = strstr(name, " ");
+ if (name == NULL)
+ return 0;
+
+ while (isspace(name[0]))
+ ++name;
+
+ if (name[0] == '\0')
+ return -1;
+
+ }
+
*rawp = name + 1;
while ((*rawp)[0] != '\0' && !isspace((*rawp)[0]))
--
1.7.9.2
next prev parent reply other threads:[~2012-11-09 17:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 17:27 [PATCHSET 00/13] perf annotate: Add support for event group view (v1) Namhyung Kim
2012-11-09 17:27 ` Namhyung Kim [this message]
2012-11-09 17:27 ` [PATCH 02/13] perf annotate: Whitespace fixups Namhyung Kim
2012-11-14 7:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-09 17:27 ` [PATCH 03/13] perf annotate: Merge same lines in summary view Namhyung Kim
2012-11-09 17:27 ` [PATCH 04/13] perf annotate: Don't try to follow jump target on PLT symbols Namhyung Kim
2012-11-14 7:43 ` [tip:perf/core] perf annotate: Don' t " tip-bot for Namhyung Kim
2012-11-09 17:27 ` [PATCH 05/13] perf annotate: Pass evsel instead of evidx on annotation functions Namhyung Kim
2012-11-09 17:27 ` [PATCH 06/13] perf annotate: Factor out disasm__calc_percent() Namhyung Kim
2012-11-09 17:27 ` [PATCH 07/13] perf annotate: Basic support for event group view Namhyung Kim
2012-11-09 17:27 ` [PATCH 08/13] perf annotate: Factor out struct source_line_percent Namhyung Kim
2012-11-09 17:27 ` [PATCH 09/13] perf annotate: Support event group view for --print-line Namhyung Kim
2012-11-09 17:27 ` [PATCH 10/13] perf annotate browser: Make browser_disasm_line->percent an array Namhyung Kim
2012-11-09 17:27 ` [PATCH 11/13] perf annotate browser: Use disasm__calc_percent() Namhyung Kim
2012-11-09 17:27 ` [PATCH 12/13] perf annotate browser: Support event group view on TUI Namhyung Kim
2012-11-09 17:27 ` [PATCH 13/13] perf annotate: Add --group option Namhyung Kim
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=1352482044-3443-2-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@ghostprotocols.net \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--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
Powered by JetHome